MySQL Great Circle intersection (do two roads cross?)

不问归期 提交于 2020-01-22 02:55:08

问题


MySQL OpenGIS CROSSES doesn't seem to work for me:

SET @ls = 'LineString(1 1, 2 2, 3 3)';
SET @xx = 'LineString(0 2, 10 2)';

# SELECT AsText(EndPoint(GeomFromText(@ls)));
select crosses(GeomFromText(@ls), GeomFromText(@xx))

returns 0 - expected 1

How would I rewrite this as a MySQL function?

Bonus points for using lat, lon and spherical projection (and maybe the Great Circle.)

PS I can't create tags and I have lost my old login: Useful tags would be: MySQL OpenGIS CROSSES greatcircle lat lon - :)


回答1:


Just use INTERSECTS(line1,line2)

SET @ls = 'LineString(1 0,1 2)';
SET @xx = 'LineString(0 1, 2 1)';
select INTERSECTS(GeomFromText(@ls), GeomFromText(@xx));



回答2:


OK, in the end I just implemented this: http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/



来源:https://stackoverflow.com/questions/4604430/mysql-great-circle-intersection-do-two-roads-cross

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!