use of org.elasticsearch.common.geo.builders.CoordinatesBuilder in project elasticsearch by elastic.
the class ShapeBuilderTests method testBoundaryShape.
/**
* Test an enveloping polygon around the max mercator bounds
*/
public void testBoundaryShape() {
PolygonBuilder builder = ShapeBuilders.newPolygon(new CoordinatesBuilder().coordinate(-180, 90).coordinate(180, 90).coordinate(180, -90).coordinate(-180, 90));
Shape shape = builder.close().build();
assertPolygon(shape);
}
use of org.elasticsearch.common.geo.builders.CoordinatesBuilder in project elasticsearch by elastic.
the class ShapeBuilderTests method testPolygonWrapping.
public void testPolygonWrapping() {
Shape shape = ShapeBuilders.newPolygon(new CoordinatesBuilder().coordinate(-150.0, 65.0).coordinate(-250.0, 65.0).coordinate(-250.0, -65.0).coordinate(-150.0, -65.0).close()).build();
assertMultiPolygon(shape);
}
use of org.elasticsearch.common.geo.builders.CoordinatesBuilder in project elasticsearch by elastic.
the class ShapeBuilderTests method testNewPolygon_coordinates.
public void testNewPolygon_coordinates() {
Polygon polygon = ShapeBuilders.newPolygon(new CoordinatesBuilder().coordinates(new Coordinate(-45, 30), new Coordinate(45, 30), new Coordinate(45, -30), new Coordinate(-45, -30), new Coordinate(-45, 30))).toPolygon();
LineString exterior = polygon.getExteriorRing();
assertEquals(exterior.getCoordinateN(0), new Coordinate(-45, 30));
assertEquals(exterior.getCoordinateN(1), new Coordinate(45, 30));
assertEquals(exterior.getCoordinateN(2), new Coordinate(45, -30));
assertEquals(exterior.getCoordinateN(3), new Coordinate(-45, -30));
}
use of org.elasticsearch.common.geo.builders.CoordinatesBuilder in project elasticsearch by elastic.
the class ShapeBuilderTests method testBoundaryShapeWithInvalidTangentialHole.
public void testBoundaryShapeWithInvalidTangentialHole() {
// test shape with two tangential (shared) vertices (should throw exception)
PolygonBuilder builder = ShapeBuilders.newPolygon(new CoordinatesBuilder().coordinate(-177, 10).coordinate(176, 15).coordinate(172, 0).coordinate(176, -15).coordinate(-177, -10).coordinate(-177, 10));
builder.hole(new LineStringBuilder(new CoordinatesBuilder().coordinate(-177, 10).coordinate(172, 0).coordinate(180, -5).coordinate(176, -10).coordinate(-177, 10)));
Exception e = expectThrows(InvalidShapeException.class, () -> builder.close().build());
assertThat(e.getMessage(), containsString("interior cannot share more than one point with the exterior"));
}
use of org.elasticsearch.common.geo.builders.CoordinatesBuilder in project elasticsearch by elastic.
the class ShapeBuilderTests method testShapeWithPointOnDateline.
public void testShapeWithPointOnDateline() {
PolygonBuilder builder = ShapeBuilders.newPolygon(new CoordinatesBuilder().coordinate(180, 0).coordinate(176, 4).coordinate(176, -4).coordinate(180, 0));
Shape shape = builder.close().build();
assertPolygon(shape);
}
Aggregations