Hi,
I'm using the go version of s2 to build some services and I come across to this behavior of the Intersection function of a Rect that I cannot understand.
This is a snippet of the code:
rectA := s2.RectFromCenterSize(s2.LatLngFromDegrees(45, 10.5), s2.LatLngFromDegrees(2, 1))
rectB := s2.RectFromCenterSize(s2.LatLngFromDegrees(0, -4.5), s2.LatLngFromDegrees(8, 11))
intersection := rectA.Intersection(rectB)
fmt.Printf("Intersects? %t Valid? %t\n", rectA.Intersects(rectB), intersection.IsValid())
fmt.Printf("Rect A: %+v\n", rectA)
fmt.Printf("Rect B: %+v\n", rectB)
fmt.Printf("Intersection: %+v\n", intersection)
and this is the output:
Intersects? false Valid? true
Rect A: [Lo[44.0000000, 10.0000000], Hi[46.0000000, 11.0000000]]
Rect B: [Lo[-4.0000000, -10.0000000], Hi[4.0000000, 1.0000000]]
Intersection: [Lo[57.2957795, 180.0000000], Hi[0.0000000, -180.0000000]]
The Intersects() correctly returns false, but why the intersection is non-empty and valid?
On the godoc ther's no reference to the intersection of two disjoints Rect.
I will check if the two Rects intersects before to calculate the intersection, but the Intersection() behaviour remains a little strange.. or maybe I missed something?
Thanks a lot.
Diego