在下面的MySQL存储函数调用中,我不想手动输入lat long坐标,而是想从另一个表中选择一个多边形进行测试。我在解决语法问题上遇到了问题。
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.40884544242924,-72.53695249557495 43.38754804789373,-72.5437331199646 43.378580946950244,-72.58398771286011 43.40930419213147,-72.5537109375
相反,我想使用这个选择语句:
SELECT neighborhood_polygon FROM `neighborhood_shapes` WHERE neighborhood="XYZ neighborhood"
我有多边形存储在neighborhood_shapes中。其结构如下:
其他信息:
IS_POINT_IN_POLYGON的调用方式如下:IS_POINT_IN_POLYGON(p POINT,poly POLYGON)
有什么建议吗?
答案 0 :(得分:0)
尝试这样做。
... POLYFROMTEXT(
(SELECT neighborhood_polygon
FROM neighborhood_shapes
Where neighborhood = "XYZ neighborhood") as coords)