【问题标题】:Mysql st_intersects + st_buffer doesn't workMysql st_intersects + st_buffer 不起作用
【发布时间】:2015-08-17 04:53:31
【问题描述】:

我试图测试一条线是否在距一点一定距离处相遇。 St_distance 只是给了我我想要的。但是,我对 st_intersects + st_buffer 很好奇:

$ mysql --version
mysql  Ver 14.14 Distrib 5.6.24, for Linux (x86_64) using  EditLine wrapper


mysql> set @l4=st_geomfromtext('LINESTRING(50 50, 52 45)');
mysql> set @g4=st_geomfromtext('POINT(50 49)');
mysql> select st_distance(@l4, @g4);
--------------
select st_distance(@l4, @g4)
--------------

+-----------------------+
| st_distance(@l4, @g4) |
+-----------------------+
|    0.3713906763541037 |
+-----------------------+
1 row in set (0.00 sec)

我认为这一点非常接近这条线,但显然 MySQL 不同意:

mysql> select st_intersects(st_buffer(@g4, 1), @l4);                                                                                                              
--------------
select st_intersects(st_buffer(@g4, 1), @l4)
--------------

+---------------------------------------+
| st_intersects(st_buffer(@g4, 1), @l4) |
+---------------------------------------+
|                                     0 |
+---------------------------------------+
1 row in set (0.00 sec)

为什么?我错过了什么吗?

附: 我已经在 H2GIS 中尝试过上面的命令,它说它确实是真的!

【问题讨论】:

    标签: mysql gis geospatial spatial


    【解决方案1】:

    ST_Intersects 在这种情况下应该返回 true。

    这似乎是此处报告的错误:https://bugs.mysql.com/bug.php?id=71076,并已在 MySQL 5.7.6 中修复,根据此处的发行说明:http://forums.mysql.com/read.php?3,629183,629183

    “这项工作还纠正了 [...] 的问题,以及 ST_Intersects() 有时会错误地计算 LineString 和 Polygon 相交的结果。"

    【讨论】:

    • 谢谢@Ireeder。我考虑过发布错误报告,但不确定。很高兴知道它已经完成了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-02-27
    • 2013-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多