Also removing InternalPolygonBuilder
This commit is contained in:
parent
12941bd4b7
commit
39f45496f2
|
@ -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<Shape> 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<InternalPolygonBuilder> {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue