40
40
import java .util .Arrays ;
41
41
import java .util .List ;
42
42
43
+ import static org .elasticsearch .common .geo .GeoTestUtils .encodeDecodeLat ;
44
+ import static org .elasticsearch .common .geo .GeoTestUtils .encodeDecodeLon ;
43
45
import static org .elasticsearch .common .geo .GeoTestUtils .triangleTreeReader ;
44
- import static org .elasticsearch .search .aggregations .bucket .geogrid .GeoTileUtils .LATITUDE_MASK ;
46
+ import static org .elasticsearch .search .aggregations .bucket .geogrid .GeoTileUtils .NORMALIZED_LATITUDE_MASK ;
47
+ import static org .elasticsearch .search .aggregations .bucket .geogrid .GeoTileUtils .NORMALIZED_NEGATIVE_LATITUDE_MASK ;
45
48
import static org .hamcrest .Matchers .equalTo ;
46
49
47
50
public class GeoGridTilerTests extends ESTestCase {
@@ -178,14 +181,12 @@ public void testGeoTileSetValuesBoundingBoxes_UnboundedGeoShapeCellValues() thro
178
181
}
179
182
}
180
183
181
- @ AwaitsFix (bugUrl = "https://github.com/elastic/elasticsearch/issues/37206" )
182
184
public void testTilerMatchPoint () throws Exception {
183
185
int precision = randomIntBetween (0 , 4 );
184
186
Point originalPoint = GeometryTestUtils .randomPoint (false );
185
187
int xTile = GeoTileUtils .getXTile (originalPoint .getX (), 1 << precision );
186
188
int yTile = GeoTileUtils .getYTile (originalPoint .getY (), 1 << precision );
187
189
Rectangle bbox = GeoTileUtils .toBoundingBox (xTile , yTile , precision );
188
- long originalTileHash = GeoTileUtils .longEncode (originalPoint .getX (), originalPoint .getY (), precision );
189
190
190
191
Point [] pointCorners = new Point [] {
191
192
// tile corners
@@ -207,7 +208,7 @@ public void testTilerMatchPoint() throws Exception {
207
208
int numTiles = GEOTILE .setValues (unboundedCellValues , value , precision );
208
209
assertThat (numTiles , equalTo (1 ));
209
210
long tilerHash = unboundedCellValues .getValues ()[0 ];
210
- long pointHash = GeoTileUtils .longEncode (point .getX (), point .getY (), precision );
211
+ long pointHash = GeoTileUtils .longEncode (encodeDecodeLon ( point .getX ()), encodeDecodeLat ( point .getY () ), precision );
211
212
assertThat (tilerHash , equalTo (pointHash ));
212
213
}
213
214
}
@@ -270,8 +271,8 @@ private int numTiles(MultiGeoValues.GeoValue geoValue, int precision) {
270
271
return 1 ;
271
272
}
272
273
273
- if ((bounds .top > LATITUDE_MASK && bounds .bottom > LATITUDE_MASK )
274
- || (bounds .top < - LATITUDE_MASK && bounds .bottom < - LATITUDE_MASK )) {
274
+ if ((bounds .top > NORMALIZED_LATITUDE_MASK && bounds .bottom > NORMALIZED_LATITUDE_MASK )
275
+ || (bounds .top < NORMALIZED_NEGATIVE_LATITUDE_MASK && bounds .bottom < NORMALIZED_NEGATIVE_LATITUDE_MASK )) {
275
276
return 0 ;
276
277
}
277
278
0 commit comments