Geo: implement proper handling of out of bounds geo points (#47734)
This is the first iteration in improving of handling of out of bounds geopoints with a latitude outside of the -90 - +90 range and a longitude outside of the -180 - +180 range. Relates to #43916
This commit is contained in:
parent
f8b8afdc70
commit
12e4e7ef54
|
@ -51,6 +51,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
import static org.apache.lucene.geo.GeoUtils.orient;
|
||||
import static org.elasticsearch.common.geo.GeoUtils.normalizeLat;
|
||||
import static org.elasticsearch.common.geo.GeoUtils.normalizeLon;
|
||||
import static org.elasticsearch.common.geo.GeoUtils.normalizePoint;
|
||||
|
||||
/**
|
||||
* Utility class that converts geometries into Lucene-compatible form
|
||||
|
@ -161,8 +162,9 @@ public final class GeoShapeIndexer implements AbstractGeometryFieldMapper.Indexe
|
|||
|
||||
@Override
|
||||
public Geometry visit(Point point) {
|
||||
//TODO: Just remove altitude for now. We need to add normalization later
|
||||
return new Point(point.getX(), point.getY());
|
||||
double[] latlon = new double[]{point.getX(), point.getY()};
|
||||
normalizePoint(latlon);
|
||||
return new Point(latlon[0], latlon[1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -222,6 +222,15 @@ public class GeometryIndexerTests extends ESTestCase {
|
|||
|
||||
point = new Point(2, 1, 3);
|
||||
assertEquals(indexed, indexer.prepareForIndexing(point));
|
||||
|
||||
point = new Point(362, 1);
|
||||
assertEquals(indexed, indexer.prepareForIndexing(point));
|
||||
|
||||
point = new Point(-178, 179);
|
||||
assertEquals(indexed, indexer.prepareForIndexing(point));
|
||||
|
||||
point = new Point(180, 180);
|
||||
assertEquals(new Point(0, 0), indexer.prepareForIndexing(point));
|
||||
}
|
||||
|
||||
public void testMultiPoint() {
|
||||
|
|
Loading…
Reference in New Issue