简体   繁体   English

Mysql检索多边形数据

[英]Mysql retrieve polygon data

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. 我想知道如何在mysql中检索多边形数据。

I have seen this sample query to insert a polygon data: http://amper.110mb.com/SPAT/mysql_initgeometry2.htm 我已经看到这个示例查询插入多边形数据: 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" Also how do i find whether a point lies inside or outside of a polygon "where latitude < 9.33 and longitude > 22.4"我如何找到一个点位于多边形的内部或外部

Here is a page with lots of examples: http://howto-use-mysql-spatial-ext.blogspot.com/ 这是一个包含大量示例的页面: 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) );

The MySQL documentation says these spatial functions also work with geometries (Looks like a Point is also a Geometry). MySQL文档说这些空间函数也适用于几何(看起来像Point也是几何)。 So you can check if the geometry in the database intersects with the one you specify in the select statement. 因此,您可以检查数据库中的几何是否与您在select语句中指定的几何相交。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM