Open gcollot opened 3 years ago
Hello There,
we noticed that Contains method returns false sometimes.
Contains
false
Ex: https://play.golang.org/p/WqDx36fG4rG
package main import ( "fmt" "github.com/golang/geo/s2" ) func main() { polygon := s2.PolygonFromLoops([]*s2.Loop{ s2.LoopFromPoints([]s2.Point{ s2.PointFromLatLng(s2.LatLngFromDegrees(-38.0, -135.0)), s2.PointFromLatLng(s2.LatLngFromDegrees(-38.0, 149.0)), s2.PointFromLatLng(s2.LatLngFromDegrees(77.0, 149.0)), s2.PointFromLatLng(s2.LatLngFromDegrees(77.0, -135.0)), s2.PointFromLatLng(s2.LatLngFromDegrees(-38.0, -135.0)), }), }) tile := s2.PolygonFromLoops([]*s2.Loop{ s2.LoopFromPoints([]s2.Point{ s2.PointFromLatLng(s2.LatLngFromDegrees(37.99616267972809, 13.007812500000002)), s2.PointFromLatLng(s2.LatLngFromDegrees(37.99616267972809, 13.359375000000002)), s2.PointFromLatLng(s2.LatLngFromDegrees(38.272819658516866, 13.359375000000002)), s2.PointFromLatLng(s2.LatLngFromDegrees(38.272819658516866, 13.007812500000002)), s2.PointFromLatLng(s2.LatLngFromDegrees(37.99616267972809, 13.007812500000002)), }), }) // +0.2 lat +0.2 lon tileExtended := s2.PolygonFromLoops([]*s2.Loop{ s2.LoopFromPoints([]s2.Point{ s2.PointFromLatLng(s2.LatLngFromDegrees(37.99616267972809, 13.007812500000002)), s2.PointFromLatLng(s2.LatLngFromDegrees(37.99616267972809, 13.559375000000002)), s2.PointFromLatLng(s2.LatLngFromDegrees(38.472819658516866, 13.559375000000002)), s2.PointFromLatLng(s2.LatLngFromDegrees(38.472819658516866, 13.007812500000002)), s2.PointFromLatLng(s2.LatLngFromDegrees(37.99616267972809, 13.007812500000002)), }), }) fmt.Println(polygon.Contains(tile)) fmt.Println(polygon.Contains(tileExtended)) }
Returns
false true Program exited.
However, all these geometries (tile & tileExtended) are contained in polygon.
Maybe, this might be linked to https://github.com/golang/geo/issues/77
Yes @gcollot, this is related to #77.
Hello There,
we noticed that
Contains
method returnsfalse
sometimes.Ex: https://play.golang.org/p/WqDx36fG4rG
Returns
However, all these geometries (tile & tileExtended) are contained in polygon.
Maybe, this might be linked to https://github.com/golang/geo/issues/77