简体   繁体   English

MySQL POLYGON查询没有结果

[英]MySQL POLYGON query no results

Database table with a POINT datatype. 具有POINT数据类型的数据库表。 I can't get any results from a MySQL POLYGON query. 我无法从MySQL POLYGON查询中获得任何结果。 Any idea what I am doing wrong? 知道我做错了什么吗? The polygon is closed. 多边形已关闭。

id  location
1   POINT(-37.816652 144.964595)    
2   POINT(-37.788132 144.931183)
3   POINT(-37.811291 144.985916)
4   POINT(-37.8389571 144.9656531000001)
5   POINT(-37.851038 144.993205)
6   POINT(-37.8029679 144.9501126)

/* 
 north = -37.711586434367305
 east = 145.45740074179685
 south = -37.92854972934211
 west = 144.6142000582031
*/

SELECT * FROM `properties` WHERE Contains (GeomFromText('POLYGON((145.45740074179685, -37.711586434367305, 144.6142000582031, -37.711586434367305, 144.6142000582031, -37.92854972934211, 145.45740074179685, -37.92854972934211, 145.45740074179685, -37.711586434367305))'), location)

SELECT * FROM `properties` WHERE Contains (PolygonFromText('POLYGON((145.45740074179685, -37.711586434367305, 144.6142000582031, -37.711586434367305, 144.6142000582031, -37.92854972934211, 145.45740074179685, -37.92854972934211, 145.45740074179685, -37.711586434367305))'), location)

You seem to have got your cordinates in the wrong order. 你好像让你的坐在错误的顺序。

GeomFromText('POLYGON((-37.711586434367305,145.45740074179685,
  -37.711586434367305, 144.6142000582031,  ....)))

Also Contains has been deprecated. 另外,Contains已被弃用。 better to use MBRContains. 更好地使用MBRContains。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM