I have a problem with mySQL spatial functions. My target is to find out if a LINESTRING object is passing through a POLYGON object or not. To determine that I've tried to experiment with two LINESTRING objects to determine if they cross or not.
SET @ls='LINESTRING (0 0, 1 1, 2 2, 3 3)'; -- original linestring
SET @lp='LINESTRING (0 1, 1 2, 2 3, 3 4)'; -- parallel linestring
SET @lx='LINESTRING (0 3, 1 2, 2 1, 3 0)'; -- crossed linestring
i've tried several functions to reach my goal:
SELECT crosses(GeomFromText(@ls), GeomFromText(@lx)); -- crossing linestrings
returns 0;
SELECT intersects(GeomFromText(@ls), GeomFromText(@lp)); -- parallel linestrings
returns 1;
SELECT overlaps(GeomFromText(@ls), GeomFromText(@lp)); -- parallel linestrings
returns 1;
I understand that it is the question of boundary comparison or sth but is there a way (or a function, or a simple solution) how to reach my goal? Other possibility would be to check if a POINT in LINESTRING is within a POLYGON but I was wondering if there's another way to do this?
solution provided in MySQL Great Circle intersection (do two roads cross?) doesn't help me unfortunately..