mirror of https://github.com/apache/lucene.git
LUCENE-8299: Geo3D wrapper uses new polygon method factory that gives better support for polygons with many points (>100)
This commit is contained in:
parent
0358fcb175
commit
af7dfb182e
|
@ -267,6 +267,9 @@ Other
|
|||
|
||||
* LUCENE-8301: Update randomizedtesting to 2.6.0. (Dawid Weiss)
|
||||
|
||||
* LUCENE-8299: Geo3D wrapper uses new polygon method factory that gives better
|
||||
support for polygons with many points (>100). (Ignacio vera)
|
||||
|
||||
* LUCENE-8261: InterpolatedProperties.interpolate and recursive property
|
||||
references. (Steve Rowe, Dawid Weiss)
|
||||
|
||||
|
|
|
@ -311,7 +311,7 @@ public class Geo3dShapeFactory implements S2ShapeFactory {
|
|||
*/
|
||||
private class Geo3dPolygonBuilder extends Geo3dPointBuilder<PolygonBuilder> implements PolygonBuilder {
|
||||
|
||||
List<GeoPolygon> polyHoles;
|
||||
List<GeoPolygonFactory.PolygonDescription> polyHoles = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public HoleBuilder hole() {
|
||||
|
@ -321,10 +321,7 @@ public class Geo3dShapeFactory implements S2ShapeFactory {
|
|||
class Geo3dHoleBuilder extends Geo3dPointBuilder<PolygonBuilder.HoleBuilder> implements PolygonBuilder.HoleBuilder {
|
||||
@Override
|
||||
public PolygonBuilder endHole() {
|
||||
if (polyHoles == null) {
|
||||
polyHoles = new ArrayList<>();
|
||||
}
|
||||
polyHoles.add(GeoPolygonFactory.makeGeoPolygon(planetModel, points));
|
||||
polyHoles.add(new GeoPolygonFactory.PolygonDescription(points));
|
||||
return Geo3dPolygonBuilder.this;
|
||||
}
|
||||
}
|
||||
|
@ -332,7 +329,8 @@ public class Geo3dShapeFactory implements S2ShapeFactory {
|
|||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Shape build() {
|
||||
GeoPolygon polygon = GeoPolygonFactory.makeGeoPolygon(planetModel, points, polyHoles);
|
||||
GeoPolygonFactory.PolygonDescription description = new GeoPolygonFactory.PolygonDescription(points, polyHoles);
|
||||
GeoPolygon polygon = GeoPolygonFactory.makeGeoPolygon(planetModel, description);
|
||||
return new Geo3dShape<>(polygon, context);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,9 +18,11 @@ package org.apache.lucene.spatial.spatial4j;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.annotations.Repeat;
|
||||
import org.apache.lucene.spatial.SpatialTestData;
|
||||
import org.apache.lucene.spatial.composite.CompositeSpatialStrategy;
|
||||
import org.apache.lucene.spatial.prefix.RandomSpatialOpStrategyTestCase;
|
||||
import org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy;
|
||||
|
@ -96,7 +98,7 @@ public class Geo3dRptTest extends RandomSpatialOpStrategyTestCase {
|
|||
points.add(new GeoPoint(planetModel, 14 * DEGREES_TO_RADIANS, -180 * DEGREES_TO_RADIANS));
|
||||
points.add(new GeoPoint(planetModel, -15 * DEGREES_TO_RADIANS, 153 * DEGREES_TO_RADIANS));
|
||||
|
||||
final Shape triangle = new Geo3dShape(GeoPolygonFactory.makeGeoPolygon(planetModel, points),ctx);
|
||||
final Shape triangle = new Geo3dShape<>(GeoPolygonFactory.makeGeoPolygon(planetModel, points),ctx);
|
||||
final Rectangle rect = ctx.makeRectangle(-49, -45, 73, 86);
|
||||
testOperation(rect,SpatialOperation.Intersects,triangle, false);
|
||||
}
|
||||
|
@ -116,7 +118,7 @@ public class Geo3dRptTest extends RandomSpatialOpStrategyTestCase {
|
|||
new GeoPoint(planetModel, 54.0 * DEGREES_TO_RADIANS, 165.0 * DEGREES_TO_RADIANS),
|
||||
new GeoPoint(planetModel, -90.0 * DEGREES_TO_RADIANS, 0.0)};
|
||||
final GeoPath path = GeoPathFactory.makeGeoPath(planetModel, 29 * DEGREES_TO_RADIANS, pathPoints);
|
||||
final Shape shape = new Geo3dShape(path,ctx);
|
||||
final Shape shape = new Geo3dShape<>(path,ctx);
|
||||
final Rectangle rect = ctx.makeRectangle(131, 143, 39, 54);
|
||||
testOperation(rect,SpatialOperation.Intersects,shape,true);
|
||||
}
|
||||
|
@ -146,6 +148,23 @@ public class Geo3dRptTest extends RandomSpatialOpStrategyTestCase {
|
|||
return new Geo3dShape<>(areaShape, ctx);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOperationsFromFile() throws IOException {
|
||||
setupStrategy();
|
||||
final Iterator<SpatialTestData> indexedSpatialData = getSampleData( "states-poly.txt");
|
||||
final List<Shape> indexedShapes = new ArrayList<>();
|
||||
while(indexedSpatialData.hasNext()) {
|
||||
indexedShapes.add(indexedSpatialData.next().shape);
|
||||
}
|
||||
final Iterator<SpatialTestData> querySpatialData = getSampleData( "states-bbox.txt");
|
||||
final List<Shape> queryShapes = new ArrayList<>();
|
||||
while(querySpatialData.hasNext()) {
|
||||
queryShapes.add(querySpatialData.next().shape);
|
||||
queryShapes.add(randomQueryShape());
|
||||
}
|
||||
testOperation(SpatialOperation.Intersects, indexedShapes, queryShapes, random().nextBoolean());
|
||||
}
|
||||
|
||||
//TODO move to a new test class?
|
||||
@Test
|
||||
public void testWKT() throws Exception {
|
||||
|
|
Loading…
Reference in New Issue