Search in sources :

Example 46 with LinearRing

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

the class InteriorPointTest method testTriangleHole.

/**
 * Test with a triangular polygon with a hole in the middle.
 *
 * @throws Exception if an error occurs
 */
@Test
public void testTriangleHole() throws Exception {
    LinearRing outer = factory.createLinearRing(new Coordinate[] { new Coordinate(49.87401, 8.65491), new Coordinate(49.87318, 8.65606), new Coordinate(49.87297, 8.6545), new Coordinate(49.87401, 8.65491) });
    LinearRing inner = factory.createLinearRing(new Coordinate[] { new Coordinate(49.87374, 8.65501), new Coordinate(49.87327, 8.65566), new Coordinate(49.87313, 8.65478), new Coordinate(49.87374, 8.65501) });
    Polygon geom = factory.createPolygon(outer, new LinearRing[] { inner });
    testPointWithin(geom);
}
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) Test(org.junit.Test)

Example 47 with LinearRing

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

the class PolygonPatchGeometryTest 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 48 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 49 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 50 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)

Aggregations

LinearRing (org.locationtech.jts.geom.LinearRing)69 Coordinate (org.locationtech.jts.geom.Coordinate)42 Polygon (org.locationtech.jts.geom.Polygon)34 Test (org.junit.Test)27 MultiPolygon (org.locationtech.jts.geom.MultiPolygon)23 LineString (org.locationtech.jts.geom.LineString)15 CustomCoordinateSequence (org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence)10 Geometry (org.locationtech.jts.geom.Geometry)10 GeometryFactory (org.locationtech.jts.geom.GeometryFactory)10 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