Also removing InternalPolygonBuilder

This commit is contained in:
Christoph Büscher 2015-11-03 18:04:52 +01:00
parent 12941bd4b7
commit 39f45496f2
2 changed files with 25 additions and 75 deletions

View File

@ -48,16 +48,6 @@ public class MultiPolygonBuilder extends ShapeBuilder {
return this; 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 @Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(); builder.startObject();
@ -100,20 +90,5 @@ public class MultiPolygonBuilder extends ShapeBuilder {
//note: ShapeCollection is probably faster than a Multi* geom. //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;
}
}
} }

View File

@ -175,52 +175,27 @@ public class GeoFilterIT extends ESIntegTestCase {
} catch (InvalidShapeException e) { } 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 // Multipolygon: polygon with hole and polygon within the whole
ShapeBuilders.newMultiPolygon() ShapeBuilder
.polygon() .newMultiPolygon()
.point(-10, -10).point(-10, 10).point(10, 10).point(10, -10) .polygon(new PolygonBuilder()
.hole() .point(-10, -10)
.point(-5, -5).point(-5, 5).point(5, 5).point(5, -5) .point(-10, 10)
.close() .point(10, 10)
.close() .point(10, -10)
.polygon() .hole().point(-5, -5)
.point(-4, -4).point(-4, 4).point(4, 4).point(4, -4) .point(-5, 5)
.close() .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(); .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 { 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 // 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 // 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 // the second polygon of size 4x4 equidistant from all sites
MultiPolygonBuilder polygon = ShapeBuilders.newMultiPolygon() MultiPolygonBuilder polygon = ShapeBuilder.newMultiPolygon()
.polygon() .polygon(new PolygonBuilder()
.point(-10, -10).point(-10, 10).point(10, 10).point(10, -10) .point(-10, -10).point(-10, 10).point(10, 10).point(10, -10)
.hole() .hole()
.point(-5, -5).point(-5, 5).point(5, 5).point(5, -5) .point(-5, -5).point(-5, 5).point(5, 5).point(5, -5)
.close() .close()
.close() .close())
.polygon() .polygon(new PolygonBuilder()
.point(-4, -4).point(-4, 4).point(4, 4).point(4, -4) .point(-4, -4).point(-4, 4).point(4, 4).point(4, -4)
.close(); .close());
BytesReference data = jsonBuilder().startObject().field("area", polygon).endObject().bytes(); BytesReference data = jsonBuilder().startObject().field("area", polygon).endObject().bytes();