使用pointfromtext和geometry o multipolygon指向多边形内的点

问题描述 投票:-1回答:3

我想确定给定的点是在哪个多边形。我正在使用mysql数据库。 Point来自text,multipolygon在Shape列中作为geometry.i使用以下查询。

SELECT ap.ac_name
FROM andrapradesh ap
WHERE ST_Contains(PointFromText('POINT(16.504181 78.161779)'), ap.SHAPE)=1;
mysql gis spatial-query
3个回答
0
投票

如果你想使用ST_Contains()你应该使用

SELECT ap.ac_name 
FROM andrapradesh ap
WHERE ST_Contains(ap.SHAPE, PointFromText('POINT(16.504181 78.161779)');

ST_Contains(g1,g2)

返回1或0以指示g1是否完全包含g2。这测试了与ST_Within()相反的关系。

如果要将包含的元素用作第一个参数,则需要ST_Within

SELECT ap.ac_name 
FROM andrapradesh ap 
WHERE ST_Within(PointFromText('POINT(16.504181 78.161779)'),ap.SHAPE);

ST_Within(g1,g2)

返回1或0以指示g1是否在空间上在g2内。这将测试与ST_Contains()相反的关系。


0
投票

是的,我有输出。 id做的是我聊天很长。

SELECT ap.ac_name 
FROM andrapradesh ap 
WHERE ST_Within(PointFromText('POINT(78.161779 16.504181)'),ap.SHAPE);

0
投票
ST_Intersection(g1, g2)

返回表示几何值g1和g2的点集交集的几何。如果任何参数为NULL,则返回值为NULL。

mysql> SET @g1 = ST_GeomFromText('LineString(1 1, 3 3)');
mysql> SET @g2 = ST_GeomFromText('LineString(1 3, 3 1)');
mysql> SELECT ST_AsText(ST_Intersection(@g1, @g2));

+--------------------------------------+
| ST_AsText(ST_Intersection(@g1, @g2)) |
+--------------------------------------+
| POINT(2 2)                           |
+--------------------------------------+
© www.soinside.com 2019 - 2024. All rights reserved.