google / s2-geometry-library-java

Automatically exported from code.google.com/p/s2-geometry-library-java
Apache License 2.0
533 stars 230 forks source link

S2ContainsPointQuery - Different Result between Java and CPP #42

Closed stavdav143 closed 1 year ago

stavdav143 commented 1 year ago

Hello, maybe I am doing something wrong here but I notice the following:

I am querying to find out if the S2LatLng.fromDegrees(-16.8583,-72.3417).toPoint() is inside the polygon: # # -16.8583:-72.3453,-17.2876:-72.3453,-17.2876:-71.8962,-16.8583:-71.8962,-16.8583:-72.345. From my point of view it is touching the edge so the distance is zero i.e the point is contained.

S2ShapeIndex index = S2TextFormat.makeIndex("# #16.8583:-72.3453,-17.2876:-72.3453,-17.2876:-71.8962,-16.8583:-71.8962,-16.8583:-72.345") S2ContainsPointQuery query= new S2ContainsPointQuery(index); index.contains(S2LatLng.fromDegrees(-16.8583,-72.3417).toPoint());

False //!!

Or  equivalently for distance:

S2ClosestEdgeQuery.Query query = S2ClosestEdgeQuery.builder() .setMaxDistance(S1ChordAngle.fromDegrees(60)) .setMaxError(S1ChordAngle.fromDegrees(0.0001)) .setMaxResults(1) .build(index);

S2ClosestEdgeQuery.PointTarget target =new S2ClosestEdgeQuery.PointTarget(pt);



`S1ChordAngle = 3.5607445507733077E-6d` instead of Zero

Any hint to what might be wrong here? 
stavdav143 commented 1 year ago

I think I get the same distance with S2 C++, the error might have been on the R side. Thanks !