0

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

skaffman
  • 398,947
  • 96
  • 818
  • 769
monk.e.boy
  • 337
  • 3
  • 11

2 Answers2

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));
Joseph Lust
  • 19,340
  • 7
  • 85
  • 83
  • I can't believe I missed that function :( duh! I'm going to leave my question as unanswered as I'd like to see if anyone has an INTERSECTS that works on a sphere. – monk.e.boy Jan 06 '11 at 10:15
  • SET @aa = 'LineString(0 3, 5 10)'; SET @bb = 'LineString(0 0, 10 10)'; select INTERSECTS(GeomFromText(@aa), GeomFromText(@bb)) AS i; returns 1 - these lines don't intersect? Or am I being thick? – monk.e.boy Jan 06 '11 at 12:28
  • OK, INTERSECTS is flawed: http://stackoverflow.com/questions/4610762/mysql-geometry-intersection-produces-non-intersecting-results – monk.e.boy Jan 06 '11 at 12:41
0

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

monk.e.boy
  • 337
  • 3
  • 11