Skip to content

Commit 9904fcf

Browse files
authored
Adjust BoundedGeoHexGridTiler#FACTOR to prevent missing hits (#96088)
Adjust the percentage we are using to inflate the bounding box on the bounded case of geohex to fix a test failure.
1 parent e9cfd81 commit 9904fcf

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

docs/changelog/96088.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 96088
2+
summary: Adjust `BoundedGeoHexGridTiler#FACTOR` to prevent missing hits
3+
area: Geo
4+
type: bug
5+
issues:
6+
- 96057

x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/search/aggregations/bucket/geogrid/GeoHexGridTiler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ static class BoundedGeoHexGridTiler extends GeoHexGridTiler {
240240
private final GeoBoundingBox bbox;
241241
private final GeoHexVisitor visitor;
242242
private final int resolution;
243-
private static final double FACTOR = 0.35;
243+
private static final double FACTOR = 0.36;
244244

245245
BoundedGeoHexGridTiler(int resolution, GeoBoundingBox bbox) {
246246
super(resolution);

x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/search/aggregations/bucket/geogrid/GeoHexTilerTests.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
import org.elasticsearch.common.geo.GeoPoint;
1414
import org.elasticsearch.geo.GeometryTestUtils;
1515
import org.elasticsearch.geometry.Geometry;
16+
import org.elasticsearch.geometry.LinearRing;
1617
import org.elasticsearch.geometry.Point;
18+
import org.elasticsearch.geometry.Polygon;
1719
import org.elasticsearch.geometry.Rectangle;
1820
import org.elasticsearch.geometry.utils.StandardValidator;
1921
import org.elasticsearch.geometry.utils.WellKnownText;
@@ -230,6 +232,31 @@ public void testTroublesomeCellLevel4_BoundedGeoShapeCellValues() throws Excepti
230232
assertThat("[" + precision + "] bucket count", numBuckets, equalTo(expected));
231233
}
232234

235+
public void testIssue96057() throws Exception {
236+
int precision = 3;
237+
Geometry geometry = new Polygon(
238+
new LinearRing(
239+
new double[] { 47.0, 47.0, -98.41711495022405, -98.41711495022405, 47.0 },
240+
new double[] { -43.27504297314639, 23.280704041384652, 23.280704041384652, -43.27504297314639, -43.27504297314639 }
241+
)
242+
);
243+
GeoBoundingBox geoBoundingBox = new GeoBoundingBox(
244+
new GeoPoint(-44.363846082646845, 55.61563600452277),
245+
new GeoPoint(-75.8747796394427, 42.12290817616412)
246+
);
247+
GeoShapeValues.GeoShapeValue value = geoShapeValue(geometry);
248+
GeoShapeCellValues cellValues = new GeoShapeCellValues(
249+
makeGeoShapeValues(value),
250+
getGridTiler(geoBoundingBox, precision),
251+
NOOP_BREAKER
252+
);
253+
254+
assertTrue(cellValues.advanceExact(0));
255+
int numBuckets = cellValues.docValueCount();
256+
int expected = expectedBuckets(value, precision, geoBoundingBox);
257+
assertThat(numBuckets, equalTo(expected));
258+
}
259+
233260
private void assertCorner(long[] h3bins, Point point, int precision, String msg) throws IOException {
234261
GeoShapeValues.GeoShapeValue cornerValue = geoShapeValue(point);
235262
GeoShapeCellValues cornerValues = new GeoShapeCellValues(makeGeoShapeValues(cornerValue), getGridTiler(precision), NOOP_BREAKER);

0 commit comments

Comments
 (0)