在 MySQL 函数调用中使用 Select 语句
在下面的 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.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中。其结构如下:
- Neighborhood_index Smallint(3)
- Neighborhood varchar(50)
- Neighborhood_Polygon(geometry)
附加信息:
IS_POINT_IN_POLYGON 的调用方式如下: IS_POINT_IN_POLYGON(p POINT, poly POLYGON)
有什么建议吗?
In the following MySQL stored function call, instead of having to manually type in the lat long coordinates, I'd like to select a polygon from another table to be tested. I'm having problems getting the syntax right.
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
And instead, I'd like to use this select statement:
SELECT neighborhood_polygon FROM `neighborhood_shapes` WHERE neighborhood="XYZ neighborhood"
I have polygons stored in neighborhood_shapes. Its structure is as follows:
- neighborhood_index smallint(3)
- neighborhood varchar(50)
- neighborhood_polygon(geometry)
Additional Info:
The IS_POINT_IN_POLYGON is called as follows: IS_POINT_IN_POLYGON(p POINT, poly POLYGON)
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试这样做。
Try doing this.