MySQL POLYGON查询没有结果

时间:2016-04-29 01:27:25

标签: mysql point-in-polygon

具有POINT数据类型的数据库表。我无法从MySQL POLYGON查询中获得任何结果。知道我做错了什么吗?多边形已关闭。

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)

1 个答案:

答案 0 :(得分:0)

你好像让你的坐在错误的顺序。

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

此外,不推荐使用Contains。最好使用MBRContains。