2

在下面的 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;

So, I'd like to remove 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"

我有多边形存储在neighbor_shapes 中。其结构如下:

  • 邻域索引 smallint(3)
  • 邻里 varchar(50)
  • 邻域多边形(几何)

附加信息:

IS_POINT_IN_POLYGON 调用如下: IS_POINT_IN_POLYGON(p POINT, poly POLYGON)

有什么建议么?

4

1 回答 1

0

尝试这样做。

... POLYFROMTEXT(
    (SELECT neighborhood_polygon 
      FROM neighborhood_shapes 
      Where neighborhood = "XYZ neighborhood") as coords)
于 2011-08-26T03:59:27.700 回答