Skip to content

Commit

Permalink
[opensearch-project#7101] Fixing the GeoTileIT#testMultivaluedGeoPoin…
Browse files Browse the repository at this point in the history
…tsAggregation test case.

The issue was happening because we encode the GeoPoint as long and error comes in the precision due to that encoding. The error was not taken care while generating the exepected tiles count for execpected output.

Signed-off-by: Navneet Verma <[email protected]>
  • Loading branch information
navneet1v committed Apr 14, 2023
1 parent 632eb44 commit c041702
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.opensearch.geo.search.aggregations.bucket;

import org.apache.lucene.geo.GeoEncodingUtils;
import org.hamcrest.MatcherAssert;
import org.opensearch.action.search.SearchResponse;
import org.opensearch.common.geo.GeoBoundingBox;
Expand Down Expand Up @@ -160,7 +161,11 @@ protected Set<String> generateBucketsForGeometry(final Geometry geometry, final
protected Set<String> generateBucketsForGeoPoint(final GeoPoint geoPoint) {
Set<String> buckets = new HashSet<>();
for (int precision = GEOPOINT_MAX_PRECISION; precision > 0; precision--) {
final String tile = GeoTileUtils.stringEncode(geoPoint.getLon(), geoPoint.getLat(), precision);
final String tile = GeoTileUtils.stringEncode(
GeoEncodingUtils.decodeLongitude(GeoEncodingUtils.encodeLongitude(geoPoint.getLon())),
GeoEncodingUtils.decodeLatitude(GeoEncodingUtils.encodeLatitude(geoPoint.getLat())),
precision
);
buckets.add(tile);
}
return buckets;
Expand Down

0 comments on commit c041702

Please sign in to comment.