在下面的MySQL存储函数调用中,我希望从另一个要测试的表中选择一个多边形,而不必手动键入长纬度坐标。我在语法上有问题。

SELECT IS_POINT_IN_POLYGON(
POINTFROMTEXT( CONCAT( 'POINT(', latitude, ' ', longitude, ')' ) ) , POLYFROMTEXT( 'POLYGON((43.40930419213147, -72.5537109375
43.40884544242924, -72.53695249557495
43.38754804789373, -72.5437331199646
43.378580946950244, -72.58398771286011
43.40930419213147, -72.5537109375 ))' )
)AS result, latitude, longitude
FROM sport
WHERE sport_type = 'lacrosse' AND IS_POINT_IN_POLYGON(
POINTFROMTEXT( CONCAT( 'POINT(', latitude, ' ', longitude, ')' ) ) , POLYFROMTEXT( 'POLYGON((43.40930419213147, -72.5537109375
43.40884544242924, -72.53695249557495
43.38754804789373, -72.5437331199646
43.378580946950244, -72.58398771286011
43.40930419213147, -72.5537109375))' )
) = 1;

所以,我想删除
43.40930419213147,-72.5537109375
43.4088454242924,-72.53695249557495
43.3875484789373,-72.5437331199646
43.378580946950244,-72.58398771286011
43.40930419213147,-72.5537109375
相反,我想使用这个select语句:
SELECT neighborhood_polygon FROM `neighborhood_shapes` WHERE neighborhood="XYZ neighborhood"

我把多边形存储在邻近的图形中。其结构如下:
邻域索引smallint(3)
varchar社区(50)
邻域多边形(几何)
其他信息:
多边形中的IS_POINT_称为:IS_POINT_IN_POLYGON(p POINT,poly POLYGON)
有什么建议吗?

最佳答案

试着做这个。

... POLYFROMTEXT(
    (SELECT neighborhood_polygon
      FROM neighborhood_shapes
      Where neighborhood = "XYZ neighborhood") as coords)

关于mysql - 在MySQL函数调用中使用Select语句,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7199857/

10-13 09:14