Search in sources :

Example 41 with LinearRing

use of org.locationtech.jts.geom.LinearRing in project hale by halestudio.

the class MultiPolygonGeometryTest 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());
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) LinearRing(org.locationtech.jts.geom.LinearRing) Polygon(org.locationtech.jts.geom.Polygon) MultiPolygon(org.locationtech.jts.geom.MultiPolygon)

Example 42 with LinearRing

use of org.locationtech.jts.geom.LinearRing in project hale by halestudio.

the class MultiSurfaceGeometryTest 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;
    Polygon polygon2 = geomFactory.createPolygon(shell, holes);
    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) });
    holes = new LinearRing[2];
    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);
    Polygon[] polygons = new Polygon[] { polygon1, polygon2 };
    reference = geomFactory.createMultiPolygon(polygons);
    checker = referenceChecker(reference);
    gridChecker = combine(referenceChecker(reference, maxPositionalError), gridConfig.geometryChecker());
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) LinearRing(org.locationtech.jts.geom.LinearRing) Polygon(org.locationtech.jts.geom.Polygon) MultiPolygon(org.locationtech.jts.geom.MultiPolygon)

Example 43 with LinearRing

use of org.locationtech.jts.geom.LinearRing in project hale by halestudio.

the class PolyhedralSurfaceGeometryTest 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;
    reference = geomFactory.createPolygon(shell, holes);
    checker = combine(noCoordinatePairs(), referenceChecker(reference));
    gridChecker = combine(noCoordinatePairs(), referenceChecker(reference, InterpolationHelper.DEFAULT_MAX_POSITION_ERROR), gridConfig.geometryChecker());
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) LinearRing(org.locationtech.jts.geom.LinearRing)

Example 44 with LinearRing

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());
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) LinearRing(org.locationtech.jts.geom.LinearRing)

Example 45 with LinearRing

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();
    }
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) Instance(eu.esdihumboldt.hale.common.instance.model.Instance) InstanceCollection(eu.esdihumboldt.hale.common.instance.model.InstanceCollection) LinearRing(org.locationtech.jts.geom.LinearRing) Polygon(org.locationtech.jts.geom.Polygon) MultiPolygon(org.locationtech.jts.geom.MultiPolygon) Test(org.junit.Test) AbstractHandlerTest(eu.esdihumboldt.hale.io.gml.geometry.handler.internal.AbstractHandlerTest)

Aggregations

LinearRing (org.locationtech.jts.geom.LinearRing)66 Coordinate (org.locationtech.jts.geom.Coordinate)39 Polygon (org.locationtech.jts.geom.Polygon)33 Test (org.junit.Test)27 MultiPolygon (org.locationtech.jts.geom.MultiPolygon)23 LineString (org.locationtech.jts.geom.LineString)14 CustomCoordinateSequence (org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence)10 Geometry (org.locationtech.jts.geom.Geometry)10 GeometryFactory (org.locationtech.jts.geom.GeometryFactory)8 Point (org.locationtech.jts.geom.Point)8 MultiPoint (org.locationtech.jts.geom.MultiPoint)7 ArrayList (java.util.ArrayList)6 DimensionInfo (org.apache.jena.geosparql.implementation.DimensionInfo)6 GeometryWrapper (org.apache.jena.geosparql.implementation.GeometryWrapper)6 Test (org.junit.jupiter.api.Test)4 DefaultGeometryProperty (eu.esdihumboldt.hale.common.instance.geometry.DefaultGeometryProperty)3 Instance (eu.esdihumboldt.hale.common.instance.model.Instance)3 CRSDefinition (eu.esdihumboldt.hale.common.schema.geometry.CRSDefinition)3 GeometryProperty (eu.esdihumboldt.hale.common.schema.geometry.GeometryProperty)3 GeometryNotSupportedException (eu.esdihumboldt.hale.io.gml.geometry.GeometryNotSupportedException)3