Fix TestShapeDocValues.testLatLonPolygonBBox (#13743)

This commit is contained in:
Shubham Chaudhary 2024-09-15 22:50:50 +05:30 committed by GitHub
parent 568d1f3fbe
commit 111ccf6c30
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 6 deletions

View File

@ -56,12 +56,14 @@ public class TestShapeDocValues extends LuceneTestCase {
public void testLatLonPolygonBBox() {
Polygon p = GeoTestUtil.nextPolygon();
Rectangle expected = (Rectangle) computeBoundingBox(p);
LatLonShapeDocValuesField dv = LatLonShape.createDocValueField(FIELD_NAME, p);
assertEquals(expected.minLat, dv.getBoundingBox().minLat, TOLERANCE);
assertEquals(expected.maxLat, dv.getBoundingBox().maxLat, TOLERANCE);
assertEquals(expected.minLon, dv.getBoundingBox().minLon, TOLERANCE);
assertEquals(expected.maxLon, dv.getBoundingBox().maxLon, TOLERANCE);
if (area(p) != 0) {
Rectangle expected = (Rectangle) computeBoundingBox(p);
LatLonShapeDocValuesField dv = LatLonShape.createDocValueField(FIELD_NAME, p);
assertEquals(expected.minLat, dv.getBoundingBox().minLat, TOLERANCE);
assertEquals(expected.maxLat, dv.getBoundingBox().maxLat, TOLERANCE);
assertEquals(expected.minLon, dv.getBoundingBox().minLon, TOLERANCE);
assertEquals(expected.maxLon, dv.getBoundingBox().maxLon, TOLERANCE);
}
}
public void testXYPolygonBBox() {
@ -255,4 +257,9 @@ public class TestShapeDocValues extends LuceneTestCase {
}
return tess;
}
/** Compute signed area of rectangle */
private static double area(Polygon p) {
return (p.maxLon - p.minLon) * (p.maxLat - p.minLat);
}
}