use of com.vividsolutions.jts.geom.LinearRing in project elasticsearch by elastic.
the class PolygonBuilder method polygon.
protected static Polygon polygon(GeometryFactory factory, Coordinate[][] polygon) {
LinearRing shell = factory.createLinearRing(polygon[0]);
LinearRing[] holes;
if (polygon.length > 1) {
holes = new LinearRing[polygon.length - 1];
for (int i = 0; i < holes.length; i++) {
holes[i] = factory.createLinearRing(polygon[i + 1]);
}
} else {
holes = null;
}
return factory.createPolygon(shell, holes);
}
use of com.vividsolutions.jts.geom.LinearRing in project elasticsearch by elastic.
the class GeoJSONShapeParserTests method testParsePolygonWithHole.
public void testParsePolygonWithHole() throws IOException {
XContentBuilder polygonGeoJson = XContentFactory.jsonBuilder().startObject().field("type", "Polygon").startArray("coordinates").startArray().startArray().value(100.0).value(1.0).endArray().startArray().value(101.0).value(1.0).endArray().startArray().value(101.0).value(0.0).endArray().startArray().value(100.0).value(0.0).endArray().startArray().value(100.0).value(1.0).endArray().endArray().startArray().startArray().value(100.2).value(0.8).endArray().startArray().value(100.2).value(0.2).endArray().startArray().value(100.8).value(0.2).endArray().startArray().value(100.8).value(0.8).endArray().startArray().value(100.2).value(0.8).endArray().endArray().endArray().endObject();
// add 3d point to test ISSUE #10501
List<Coordinate> shellCoordinates = new ArrayList<>();
shellCoordinates.add(new Coordinate(100, 0, 15.0));
shellCoordinates.add(new Coordinate(101, 0));
shellCoordinates.add(new Coordinate(101, 1));
shellCoordinates.add(new Coordinate(100, 1, 10.0));
shellCoordinates.add(new Coordinate(100, 0));
List<Coordinate> holeCoordinates = new ArrayList<>();
holeCoordinates.add(new Coordinate(100.2, 0.2));
holeCoordinates.add(new Coordinate(100.8, 0.2));
holeCoordinates.add(new Coordinate(100.8, 0.8));
holeCoordinates.add(new Coordinate(100.2, 0.8));
holeCoordinates.add(new Coordinate(100.2, 0.2));
LinearRing shell = GEOMETRY_FACTORY.createLinearRing(shellCoordinates.toArray(new Coordinate[shellCoordinates.size()]));
LinearRing[] holes = new LinearRing[1];
holes[0] = GEOMETRY_FACTORY.createLinearRing(holeCoordinates.toArray(new Coordinate[holeCoordinates.size()]));
Polygon expected = GEOMETRY_FACTORY.createPolygon(shell, holes);
assertGeometryEquals(jtsGeom(expected), polygonGeoJson);
}
use of com.vividsolutions.jts.geom.LinearRing in project hale by halestudio.
the class PolygonHandlerTest method init.
// XXX no test for geometry properties
@Override
public void init() {
super.init();
LinearRing shell = geomFactory.createLinearRing(new Coordinate[] { new Coordinate(0.01, 3.2), new Coordinate(3.33, 3.33), new Coordinate(0.01, -3.2), new Coordinate(-3.33, -3.2), new Coordinate(0.01, 3.2) });
LinearRing[] holes = new LinearRing[2];
LinearRing hole1 = geomFactory.createLinearRing(new Coordinate[] { new Coordinate(0, 1), new Coordinate(1, 1), new Coordinate(0, -1), new Coordinate(-1, -1), new Coordinate(0, 1) });
LinearRing hole2 = geomFactory.createLinearRing(new Coordinate[] { new Coordinate(0, 2), new Coordinate(2, 2), new Coordinate(0, -2), new Coordinate(-2, -2), new Coordinate(0, 2) });
holes[0] = hole1;
holes[1] = hole2;
reference = geomFactory.createPolygon(shell, holes);
checker = combine(noCoordinatePairs(), referenceChecker(reference));
gridChecker = combine(noCoordinatePairs(), referenceChecker(reference, InterpolationHelper.DEFAULT_MAX_POSITION_ERROR), gridConfig.geometryChecker());
}
use of com.vividsolutions.jts.geom.LinearRing in project hale by halestudio.
the class CompositeSurfaceGeometryTest method init.
@Override
public void init() {
super.init();
LinearRing shell = geomFactory.createLinearRing(new Coordinate[] { new Coordinate(0.01, 3.2), new Coordinate(3.33, 3.33), new Coordinate(0.01, -3.2), new Coordinate(-3.33, -3.2), new Coordinate(0.01, 3.2) });
LinearRing[] holes = new LinearRing[2];
LinearRing hole1 = geomFactory.createLinearRing(new Coordinate[] { new Coordinate(0, 1), new Coordinate(1, 1), new Coordinate(0, -1), new Coordinate(-1, -1), new Coordinate(0, 1) });
LinearRing hole2 = geomFactory.createLinearRing(new Coordinate[] { new Coordinate(0, 2), new Coordinate(2, 2), new Coordinate(0, -2), new Coordinate(-2, -2), new Coordinate(0, 2) });
holes[0] = hole1;
holes[1] = hole2;
Polygon polygon1 = geomFactory.createPolygon(shell, holes);
shell = geomFactory.createLinearRing(new Coordinate[] { new Coordinate(6.01, 9.2), new Coordinate(9.33, 9.33), new Coordinate(6.01, -9.2), new Coordinate(-9.33, -9.2), new Coordinate(6.01, 9.2) });
holes = new LinearRing[2];
hole1 = geomFactory.createLinearRing(new Coordinate[] { new Coordinate(2, 3), new Coordinate(3, 3), new Coordinate(2, -3), new Coordinate(-3, -3), new Coordinate(2, 3) });
hole2 = geomFactory.createLinearRing(new Coordinate[] { new Coordinate(2, 4), new Coordinate(4, 4), new Coordinate(2, -4), new Coordinate(-4, -4), new Coordinate(2, 4) });
holes[0] = hole1;
holes[1] = hole2;
Polygon polygon2 = geomFactory.createPolygon(shell, holes);
Polygon[] polygons = new Polygon[] { polygon1, polygon2 };
reference = geomFactory.createMultiPolygon(polygons);
checker = referenceChecker(reference);
gridChecker = combine(referenceChecker(reference, InterpolationHelper.DEFAULT_MAX_POSITION_ERROR), gridConfig.geometryChecker());
}
use of com.vividsolutions.jts.geom.LinearRing in project hale by halestudio.
the class OrientableSurfaceGeometryTest method init.
@Override
public void init() {
super.init();
LinearRing shell = geomFactory.createLinearRing(new Coordinate[] { new Coordinate(-122.44, 37.80), new Coordinate(-122.45, 37.80), new Coordinate(-122.45, 37.78), new Coordinate(-122.44, 37.78), new Coordinate(-122.44, 37.80) });
LinearRing[] holes = new LinearRing[1];
LinearRing hole1 = geomFactory.createLinearRing(new Coordinate[] { new Coordinate(-122.24, 37.60), new Coordinate(-122.25, 37.60), new Coordinate(-122.25, 37.58), new Coordinate(-122.24, 37.58), new Coordinate(-122.24, 37.60) });
holes[0] = hole1;
reference = geomFactory.createPolygon(shell, holes);
checker = referenceChecker(reference);
gridChecker = combine(referenceChecker(reference, maxPositionalError), gridConfig.geometryChecker());
}
Aggregations