具有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)

最佳答案

您似乎坐标顺序错误。

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

还不推荐包含。最好使用MBRContains。

关于mysql - MySQL POLYGON查询无结果,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36928083/

10-13 07:50