diff --git a/core/src/main/java/org/elasticsearch/common/geo/builders/MultiPolygonBuilder.java b/core/src/main/java/org/elasticsearch/common/geo/builders/MultiPolygonBuilder.java index ee06fa64376..b2d5fd85a93 100644 --- a/core/src/main/java/org/elasticsearch/common/geo/builders/MultiPolygonBuilder.java +++ b/core/src/main/java/org/elasticsearch/common/geo/builders/MultiPolygonBuilder.java @@ -48,16 +48,6 @@ public class MultiPolygonBuilder extends ShapeBuilder { return this; } - public InternalPolygonBuilder polygon() { - return polygon(Orientation.RIGHT); - } - - public InternalPolygonBuilder polygon(Orientation orientation) { - InternalPolygonBuilder polygon = new InternalPolygonBuilder(this, orientation); - this.polygon(polygon); - return polygon; - } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); @@ -81,7 +71,7 @@ public class MultiPolygonBuilder extends ShapeBuilder { public Shape build() { List shapes = new ArrayList<>(this.polygons.size()); - + if(wrapdateline) { for (BasePolygonBuilder polygon : this.polygons) { for(Coordinate[][] part : polygon.coordinates()) { @@ -100,20 +90,5 @@ public class MultiPolygonBuilder extends ShapeBuilder { //note: ShapeCollection is probably faster than a Multi* geom. } - public static class InternalPolygonBuilder extends BasePolygonBuilder { - private final MultiPolygonBuilder collection; - - private InternalPolygonBuilder(MultiPolygonBuilder collection, Orientation orientation) { - super(orientation); - this.collection = collection; - this.shell = new Ring<>(this); - } - - @Override - public MultiPolygonBuilder close() { - super.close(); - return collection; - } - } } diff --git a/core/src/test/java/org/elasticsearch/search/geo/GeoFilterIT.java b/core/src/test/java/org/elasticsearch/search/geo/GeoFilterIT.java index 407d9791d87..da83a4ed9ed 100644 --- a/core/src/test/java/org/elasticsearch/search/geo/GeoFilterIT.java +++ b/core/src/test/java/org/elasticsearch/search/geo/GeoFilterIT.java @@ -175,52 +175,27 @@ public class GeoFilterIT extends ESIntegTestCase { } catch (InvalidShapeException e) { } -// Not specified -// try { -// // two overlapping polygons within a multipolygon -// ShapeBuilder.newMultiPolygon() -// .polygon() -// .point(-10, -10) -// .point(-10, 10) -// .point(10, 10) -// .point(10, -10) -// .close() -// .polygon() -// .point(-5, -5).point(-5, 5).point(5, 5).point(5, -5) -// .close().build(); -// fail("Polygon intersection not detected"; -// } catch (InvalidShapeException e) {} - // Multipolygon: polygon with hole and polygon within the whole - ShapeBuilders.newMultiPolygon() - .polygon() - .point(-10, -10).point(-10, 10).point(10, 10).point(10, -10) - .hole() - .point(-5, -5).point(-5, 5).point(5, 5).point(5, -5) - .close() - .close() - .polygon() - .point(-4, -4).point(-4, 4).point(4, 4).point(4, -4) - .close() + ShapeBuilder + .newMultiPolygon() + .polygon(new PolygonBuilder() + .point(-10, -10) + .point(-10, 10) + .point(10, 10) + .point(10, -10) + .hole().point(-5, -5) + .point(-5, 5) + .point(5, 5) + .point(5, -5) + .close() + .close()) + .polygon(new PolygonBuilder() + .point(-4, -4) + .point(-4, 4) + .point(4, 4) + .point(4, -4) + .close()) .build(); - -// Not supported -// try { -// // Multipolygon: polygon with hole and polygon within the hole but overlapping -// ShapeBuilder.newMultiPolygon() -// .polygon() -// .point(-10, -10).point(-10, 10).point(10, 10).point(10, -10) -// .hole() -// .point(-5, -5).point(-5, 5).point(5, 5).point(5, -5) -// .close() -// .close() -// .polygon() -// .point(-4, -4).point(-4, 6).point(4, 6).point(4, -4) -// .close() -// .build(); -// fail("Polygon intersection not detected"; -// } catch (InvalidShapeException e) {} - } public void testShapeRelations() throws Exception { @@ -247,16 +222,16 @@ public class GeoFilterIT extends ESIntegTestCase { // Create a multipolygon with two polygons. The first is an rectangle of size 10x10 // with a hole of size 5x5 equidistant from all sides. This hole in turn contains // the second polygon of size 4x4 equidistant from all sites - MultiPolygonBuilder polygon = ShapeBuilders.newMultiPolygon() - .polygon() + MultiPolygonBuilder polygon = ShapeBuilder.newMultiPolygon() + .polygon(new PolygonBuilder() .point(-10, -10).point(-10, 10).point(10, 10).point(10, -10) .hole() .point(-5, -5).point(-5, 5).point(5, 5).point(5, -5) .close() - .close() - .polygon() + .close()) + .polygon(new PolygonBuilder() .point(-4, -4).point(-4, 4).point(4, 4).point(4, -4) - .close(); + .close()); BytesReference data = jsonBuilder().startObject().field("area", polygon).endObject().bytes();