tidwall / tile38

Real-time Geospatial and Geofencing
https://tile38.com
MIT License
9.16k stars 570 forks source link

INTERSECTS with LineString returns wrong results. #305

Open yorkxiao opened 6 years ago

yorkxiao commented 6 years ago

@tidwall hi, I test INTERSECTS with LineString, but I gets wrong results. It seems that the first point and the last point of a LineString has been connected when doing INTERSECTS . Can you check it and fix it if the bug exists? Here is my test demo:

set fences cross1 object {"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[24,21],[25,21],[25,19],[24,19],[24,21]]]}}
set fences none1 object {"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[24,18],[25,18],[25,8],[24,8],[24,18]]]}}
intersects fences ids object {"type":"LineString","coordinates":[[20,20],[30,20],[30,10]]}

the above linestring cross only the fence cross1 , but ["cross1","none1"] is returned, because line [30,10],[20,20] cross the fence none1.

intersects fences ids object {"type":"LineString","coordinates":[[20,20],[30,20],[30,10]**,[30,0],[10,0]**]}

correct result returned when testing another linestring, because line [10,0],[20,20] do not cross the fence none1.

qq 20180423160951

tidwall commented 6 years ago

Very strange indeed. I'll need to do some testing on my side and let you know if I get the same results. Stay tuned.

melbania commented 5 years ago

Hi, I recently tested this issue on my machine and was unable to reproduce the problem: the INTERSECTS query with the defined LineString returned ["cross1"] only.

Are you still seeing this problem on your side @yorkxiao ?

@tidwall , given that this issue was reported more than a year ago, perhaps it was resolved in a newer release of Tile38?