[OpenLayers-Dev] LineString Intersects method

Tim Schaub tschaub at opengeo.org
Thu Jul 1 01:53:19 EDT 2010


On 6/30/10 10:52 PM, Gagan Bansal wrote:
>
> Hi,
>
> I am trying to check if the line and point intersects using :
> OpenLayers.Geometry.LineString.intersects(). Many times it returns false,
> even if line and point intersects.
>
> I am using OpenLayers-2.9.1.
>
> Here is the test case:
> Line - "LINESTRING(-120.5859375 33.2666015625,-119.3994140625
> 34.4970703125,-114.85107421875 35.31005859375,-112.587890625 33.3984375)"
> Point - "POINT(-118.67393030208639 34.62674615373335)"
>

For what it's worth, JTS reports that those two geometries don't 
intersect.  It also reports that they are 2.8834296948952665e-16 units 
apart.

Where do those geometries come from that make you think they intersect? 
  (I don't mean to imply that they aren't very very close together.)

There are certainly numerical precision issues in our geometry 
operations, but for the stuff I've worked on, I've tried to make it so 
things are internally consistent.  That is, if you snap a point to 
another geometry, the intersects method should return true.  If you 
split geometries, they should touch.  Etc.

I grant that the return from distanceTo is misleading.  I see why this 
returns zero in this case.  It would take a bit of work to make this 
different.

Tim

> If I calculate the distance between these two, Line and Point using
> distanceTo(), the distance is 0 as well as source point and target point
> coordinates are same.
>
> Please check where I am doing wrong or is this a bug.
>
> Regards,
> Gagan


-- 
Tim Schaub
OpenGeo - http://opengeo.org
Expert service straight from the developers.



More information about the Dev mailing list