Test bug RE assertIntersect and non-normalized rectangles
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 38/100
Research direction
Review RandomizedShapeTest._assertIntersect and BBoxCalculatorTest.testGeoLongitude, then reproduce the reported failure involving vertical rectangles at -180 and +180. Check the existing handling for degenerate polar points before choosing an approach. Done means the dateline case passes without breaking the surrounding intersection assertions.
Written by the indexing model from the issue text.
Description
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).
- Dominant language
- Java
- Stars
- 961
- Forks
- 172
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from locationtech/spatial4j
-
question
Difficulty 5/5 Over a week Newbie friendliness 20/100
locationtech/spatial4j#233 · 1 comment ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 35/100
locationtech/spatial4j#232 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
locationtech/spatial4j#231 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
locationtech/spatial4j#230 · 2 comments ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 45/100
locationtech/spatial4j#227 · 2 comments ·
All issues in locationtech/spatial4j
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100