Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test bug RE assertIntersect and non-normalized rectangles #141

Open
dsmiley opened this issue Apr 15, 2016 · 0 comments
Open

Test bug RE assertIntersect and non-normalized rectangles #141

dsmiley opened this issue Apr 15, 2016 · 0 comments
Labels

Comments

@dsmiley
Copy link
Contributor

dsmiley commented Apr 15, 2016

I got this failure:

Tests run: 100, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.437 sec <<< FAILURE! - in org.locationtech.spatial4j.shape.impl.BBoxCalculatorTest
testGeoLongitude { seed=[859E55631A6DA980:F0F85AA453DFE02B]}(org.locationtech.spatial4j.shape.impl.BBoxCalculatorTest)  Time elapsed: 0.016 sec  <<< FAILURE!
java.lang.AssertionError: Rect(minX=180.0,maxX=180.0,minY=-90.0,maxY=60.0) intersect Rect(minX=-180.0,maxX=-180.0,minY=-90.0,maxY=60.0) expected:<Rect(minX=180.0,maxX=180.0,minY=-90.0,maxY=60.0)> but was:<Rect(minX=-180.0,maxX=-180.0,minY=-90.0,maxY=60.0)>
    at __randomizedtesting.SeedInfo.seed([859E55631A6DA980:F0F85AA453DFE02B]:0)
    at org.junit.Assert.fail(Assert.java:88)
    at org.junit.Assert.failNotEquals(Assert.java:834)
    at org.junit.Assert.assertEquals(Assert.java:118)
    at org.locationtech.spatial4j.shape.RandomizedShapeTest._assertIntersect(RandomizedShapeTest.java:151)
    at org.locationtech.spatial4j.shape.RandomizedShapeTest.assertRelation(RandomizedShapeTest.java:141)
    at org.locationtech.spatial4j.shape.RandomizedShapeTest.assertRelation(RandomizedShapeTest.java:135)
    at org.locationtech.spatial4j.shape.impl.BBoxCalculatorTest.testGeoLongitude(BBoxCalculatorTest.java:61)

These are two rectangles that are vertical lines along the dateline, but one of them is defined with -180 and the other with +180. They are otherwise equal (same latitude range). But they don't report themselves as equal.

If we normalized zero-width rectangles at construction then we wouldn't have this problem. That's one way to fix, though loses the input coordinates as given and I'm not sure if that matters?

Alternatively, assertIntersect could be smarter to try and detect this. It already detects rectangles that are actually degenerate points at the pole. That could have been handled via rectangle normalization as well (zero height rects at the pole could have their longitudes normalized, to say, 0,0). Given this precedent, I guess we could continue with it and have assertIntersects detect this scenario. I'm inclined to go with that as it's least risky (will impact nobody; just updating a test to not fail).

@dsmiley dsmiley added the bug label Apr 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant