Closed kishorenc closed 2 years ago
Your vertices look like they're counterclockwise, so that's good. That's the most common cause of these "Contains is broken" bug reports.
What makes you think this point should be contained in this loop?
Edges in S2 are geodesics. The top and bottom edges start and end at the same latitude, but span 152 degrees, so they're going to go quite far north.
http://www.gcmap.com/mapui?P=60N+118W+-+60N+34E,+23N+118W+-+23N+34E,+42.716450N+W67.079284
From this it looks like the point isn't in the loop.
@jmr
Thank you for your prompt response. I was actually plotting these points on Google maps to verify but it looks very different on Google Maps: is that because Google Maps does not represent points as they look on a spherical surface?
The points are in the right place. It's just that the geodesic (shortest path) connecting them is not a straight line on this projection (Mercator). If you drew the lines with geodesic: true
in the maps API, you would also see them going far north.
https://developers.google.com/maps/documentation/javascript/geometry#SphericalGeometry
If you actually want to just compare lat/lng, use S2LatLngRect
.
I'm checking whether a given geo point is within a large polygon. The following assertion should pass, but is failing:
I'm not able to figure out what's going wrong, because I have other examples where this is working in an expected fashion.