Search code examples
mysqlgreat-circleopengis

MySQL Great Circle intersection (do two roads cross?)


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 - :)


Solution

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