Search in sources :

Example 56 with Coordinate

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

the class SplitInterpolationTest method test90Deegrees.

@Test
public void test90Deegrees() throws IOException {
    ArcByCenterPoint arc = new ArcByCenterPointImpl(new Coordinate(0, 0), Math.sqrt(2.0), Angle.fromDegrees(45), Angle.fromDegrees(135), false);
    splitInterpolationTest(arc, 0.1);
}
Also used : ArcByCenterPoint(eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint) Coordinate(org.locationtech.jts.geom.Coordinate) ArcByCenterPointImpl(eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByCenterPointImpl) AbstractArcTest(eu.esdihumboldt.util.geometry.interpolation.AbstractArcTest) Test(org.junit.Test)

Example 57 with Coordinate

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

the class SplitInterpolationTest method testByPoints1.

@Test
public void testByPoints1() throws IOException {
    Arc arc = new ArcByPointsImpl(new Coordinate(-3, 2), new Coordinate(-2, 4), new Coordinate(0, 4));
    splitInterpolationTest(arc, 0.1);
}
Also used : ArcByPointsImpl(eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByPointsImpl) Arc(eu.esdihumboldt.util.geometry.interpolation.model.Arc) Coordinate(org.locationtech.jts.geom.Coordinate) AbstractArcTest(eu.esdihumboldt.util.geometry.interpolation.AbstractArcTest) Test(org.junit.Test)

Example 58 with Coordinate

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

the class SplitInterpolationTest method testArcString.

@Test
public void testArcString() throws IOException {
    List<Arc> arcs = new ArrayList<>();
    arcs.add(new ArcByPointsImpl(new Coordinate(-3, 2), new Coordinate(-2, 4), new Coordinate(0, 4)));
    arcs.add(new ArcByPointsImpl(new Coordinate(0, 4), new Coordinate(2, 3), new Coordinate(4, 4)));
    arcs.add(new ArcByPointsImpl(new Coordinate(4, 4), new Coordinate(4, 6), new Coordinate(2, 6)));
    splitInterpolationTest(new ArcStringImpl(arcs), 0.1);
}
Also used : ArcByPointsImpl(eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByPointsImpl) Arc(eu.esdihumboldt.util.geometry.interpolation.model.Arc) Coordinate(org.locationtech.jts.geom.Coordinate) ArrayList(java.util.ArrayList) ArcStringImpl(eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcStringImpl) AbstractArcTest(eu.esdihumboldt.util.geometry.interpolation.AbstractArcTest) Test(org.junit.Test)

Example 59 with Coordinate

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

the class CurveHelper method combineCurve.

/**
 * Combine the given {@link LineString}s to a single {@link LineString} if
 * possible.
 *
 * @param lineStrings the line strings
 * @param fact a geometry factory
 * @return the combined {@link LineString} or <code>null</code> if the
 *         geometry did not meet the requirements of the strict mode
 */
@Nullable
public static LineString combineCurve(List<? extends LineString> lineStrings, GeometryFactory fact) {
    return combineCurve(lineStrings, true, geoms -> {
        List<Coordinate> coordinates = new ArrayList<>();
        boolean skipFirst = false;
        for (LineString geom : geoms) {
            int index = 0;
            if (!skipFirst) {
                skipFirst = true;
            } else {
                index = 1;
            }
            for (int i = index; i < geom.getNumPoints(); i++) {
                coordinates.add(geom.getCoordinateN(i));
            }
        }
        return fact.createLineString(coordinates.toArray(new Coordinate[coordinates.size()]));
    });
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) MultiLineString(org.locationtech.jts.geom.MultiLineString) LineString(org.locationtech.jts.geom.LineString) ArrayList(java.util.ArrayList) Nullable(javax.annotation.Nullable)

Example 60 with Coordinate

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

the class WindingOrderTest method setUp.

/**
 * Setup for different tests
 */
@BeforeClass
public static void setUp() {
    GeometryFactory factory = new GeometryFactory();
    r1 = factory.createLinearRing(new Coordinate[] { new Coordinate(10, 30), new Coordinate(20, 0), new Coordinate(0, 0), new Coordinate(10, 30) });
    r2 = factory.createLinearRing(new Coordinate[] { new Coordinate(49.87445, 8.64729), new Coordinate(49.87582, 8.65441), new Coordinate(49.87095, 8.65694), new Coordinate(49.86978, 8.65032), new Coordinate(49.87197, 8.64758), new Coordinate(49.87341, 8.64688), new Coordinate(49.87445, 8.64729) });
    h1 = factory.createLinearRing(new Coordinate[] { new Coordinate(49.87327, 8.64991), new Coordinate(49.8735, 8.6521), new Coordinate(49.87253, 8.65239), new Coordinate(49.8723, 8.65045), new Coordinate(49.87327, 8.64991) });
    h2 = factory.createLinearRing(new Coordinate[] { new Coordinate(49.87203, 8.65208), new Coordinate(49.87209, 8.6531), new Coordinate(49.87156, 8.65312), new Coordinate(49.87145, 8.65227), new Coordinate(49.87203, 8.65208) });
    clockWise1 = factory.createPolygon(r1);
    clockWise2 = factory.createPolygon(r2, new LinearRing[] { h1, h2 });
    clockWise2WOHoles = factory.createPolygon(r2);
    clockWise3 = factory.createMultiPolygon(new Polygon[] { clockWise1, clockWise2 });
    clockWise4 = factory.createGeometryCollection(new Geometry[] { clockWise2, clockWise2WOHoles, clockWise3, r2 });
    if (crs1 == null) {
        try {
            crs1 = CRS_CACHE.get(code1);
        } catch (Exception e) {
            throw new IllegalStateException("Invalid CRS code", e);
        }
    }
    if (crs2 == null) {
        try {
            crs2 = CRS_CACHE.get(code2);
        } catch (Exception e) {
            throw new IllegalStateException("Invalid CRS code", e);
        }
    }
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) GeometryFactory(org.locationtech.jts.geom.GeometryFactory) Coordinate(org.locationtech.jts.geom.Coordinate) LinearRing(org.locationtech.jts.geom.LinearRing) Polygon(org.locationtech.jts.geom.Polygon) MultiPolygon(org.locationtech.jts.geom.MultiPolygon) BeforeClass(org.junit.BeforeClass)

Aggregations

Coordinate (org.locationtech.jts.geom.Coordinate)348 Test (org.junit.Test)145 Geometry (org.locationtech.jts.geom.Geometry)69 GeometryFactory (org.locationtech.jts.geom.GeometryFactory)65 LineString (org.locationtech.jts.geom.LineString)57 Point (org.locationtech.jts.geom.Point)57 Polygon (org.locationtech.jts.geom.Polygon)47 LinearRing (org.locationtech.jts.geom.LinearRing)45 AbstractArcTest (eu.esdihumboldt.util.geometry.interpolation.AbstractArcTest)37 ArcByCenterPoint (eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint)32 ArrayList (java.util.ArrayList)32 MultiPolygon (org.locationtech.jts.geom.MultiPolygon)27 Test (org.junit.jupiter.api.Test)26 Arc (eu.esdihumboldt.util.geometry.interpolation.model.Arc)20 MultiPoint (org.locationtech.jts.geom.MultiPoint)20 ArcByPointsImpl (eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByPointsImpl)17 ArcByCenterPointImpl (eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByCenterPointImpl)16 GeometryWrapper (org.apache.jena.geosparql.implementation.GeometryWrapper)15 ArcByPoints (eu.esdihumboldt.util.geometry.interpolation.model.ArcByPoints)14 HashMap (java.util.HashMap)13