MySQL检索多边形数据 [英] Mysql retrieve polygon data

查看:164
本文介绍了MySQL检索多边形数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在开发一个站点,以多边形(经度和纬度)的形式在mysql数据库中存储空间数据,例如建筑物,花园等.

i have been developing a site that stores spatial data in mysql database, like that of buildings, gardens, etc. in the form of polygons (latitudes and longitudes).

我想知道如何在mysql中检索多边形数据.

I want to know how to retrieve polygon data in mysql.

我已经看到了以下示例查询来插入面数据: http://amper.110mb.com/SPAT/mysql_initgeometry2.htm

I have seen this sample query to insert a polygon data: http://amper.110mb.com/SPAT/mysql_initgeometry2.htm

但是现在我想知道如何基于某些约束,例如从表中检索数据:

But now i want to know how to retrieve data from the table, based on certain constraints like:

"where latitude < 9.33 and longitude > 22.4" 另外,我如何找到一个点位于多边形的内部还是外部

"where latitude < 9.33 and longitude > 22.4" Also how do i find whether a point lies inside or outside of a polygon

推荐答案

这是一个包含许多示例的页面: http://howto-use-mysql-spatial-ext.blogspot.com/

Here is a page with lots of examples: http://howto-use-mysql-spatial-ext.blogspot.com/

这是检索与指定边界框相交的行的示例之一:

This is one of the examples to retrieve rows which points intersect with a specified bounding box:

SET @bbox = 'POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))'; 
SELECT name, AsText(location) FROM Points
    WHERE Intersects( location, GeomFromText(@bbox) );

MySQL文档表示,这些空间功能也可用于几何图形(看起来像点也是几何图形).因此,您可以检查数据库中的几何是否与您在select语句中指定的几何相交.

The MySQL documentation says these spatial functions also work with geometries (Looks like a Point is also a Geometry). So you can check if the geometry in the database intersects with the one you specify in the select statement.

这篇关于MySQL检索多边形数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆