use of org.locationtech.jts.geom.LinearRing in project hale by halestudio.
the class SurfaceGeometryTest 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 = combine(noCoordinatePairs(), referenceChecker(reference));
gridChecker = combine(noCoordinatePairs(), referenceChecker(reference, maxPositionalError), gridConfig.geometryChecker());
}
use of org.locationtech.jts.geom.LinearRing in project hale by halestudio.
the class SurfaceGeometryTest method testSurfaceGml32_patches_hole.
/**
* Test surface geometry consisting of multiple patches (including holes)
* read from a GML 3.2 file.
*
* @throws Exception if an error occurs
*/
@Test
public void testSurfaceGml32_patches_hole() throws Exception {
InstanceCollection instances = AbstractHandlerTest.loadXMLInstances(getClass().getResource("/data/gml/geom-gml32.xsd").toURI(), getClass().getResource("/data/surface/sample-surface-gml32_patches_hole.xml").toURI());
LinearRing shell = geomFactory.createLinearRing(new Coordinate[] { new Coordinate(-4.5, 3), new Coordinate(0.5, 4.5), new Coordinate(5, 3), new Coordinate(8.5, 2), new Coordinate(3, -4.5), new Coordinate(1, 1), new Coordinate(-3, -1), new Coordinate(-4.5, 3) });
LinearRing[] holes = new LinearRing[] { geomFactory.createLinearRing(new Coordinate[] { new Coordinate(3, 0.5), new Coordinate(4, -2), new Coordinate(6.5, 1.5), new Coordinate(4.5, 2), new Coordinate(3, 0.5) }) };
Polygon composedPolygon = geomFactory.createPolygon(shell, holes);
// one instance expected
ResourceIterator<Instance> it = instances.iterator();
try {
// PolygonPatch with LinearRings defined through coordinates
assertTrue("First sample feature missing", it.hasNext());
Instance instance = it.next();
checkSingleGeometry(instance, referenceChecker(composedPolygon));
} finally {
it.close();
}
}
use of org.locationtech.jts.geom.LinearRing in project series-rest-api by 52North.
the class GeoJSONTest method randomLinearRing.
private LinearRing randomLinearRing(int srid) {
Coordinate p = randomCoordinate();
LinearRing geometry = geometryFactory.createLinearRing(new Coordinate[] { p, randomCoordinate(), randomCoordinate(), randomCoordinate(), p });
geometry.setSRID(srid);
return geometry;
}
use of org.locationtech.jts.geom.LinearRing in project graphhopper by graphhopper.
the class AreaIndexTest method testHole.
@Test
public void testHole() {
GeometryFactory gf = new GeometryFactory();
LinearRing shell = gf.createLinearRing(new Coordinate[] { new Coordinate(1, 1), new Coordinate(7, 1), new Coordinate(7, 7), new Coordinate(1, 7), new Coordinate(1, 1) });
LinearRing hole = gf.createLinearRing(new Coordinate[] { new Coordinate(4, 2), new Coordinate(6, 2), new Coordinate(6, 4), new Coordinate(4, 6), new Coordinate(4, 2) });
{
Polygon p = gf.createPolygon(shell, new LinearRing[] { hole });
AreaIndex<CustomArea> index = new AreaIndex<>(Collections.singletonList(createCustomArea("1", p)));
testQuery(index, 3, 5);
}
{
Polygon p = gf.createPolygon(hole);
AreaIndex<CustomArea> index = new AreaIndex<>(Collections.singletonList(createCustomArea("2", p)));
testQuery(index, 3, 5, "2");
}
}
use of org.locationtech.jts.geom.LinearRing in project ddf by codice.
the class Polygon method buildPolygon.
public static org.locationtech.jts.geom.Polygon buildPolygon(List coordinates) {
// according to the GeoJson specification, first ring is the exterior
LinearRing exterior = GEOMETRY_FACTORY.createLinearRing(getCoordinates((List) coordinates.get(0)));
LinearRing[] interiorHoles = new LinearRing[coordinates.size() - 1];
for (int i = 1; i < coordinates.size(); i++) {
interiorHoles[i - 1] = GEOMETRY_FACTORY.createLinearRing(getCoordinates((List) coordinates.get(i)));
}
return GEOMETRY_FACTORY.createPolygon(exterior, interiorHoles);
}
Aggregations