Search in sources :

Example 6 with JTSPrimitiveFactory

use of org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSPrimitiveFactory in project geotoolkit by Geomatys.

the class GeometryUtils method createCurve.

public static Curve createCurve(final DirectPosition[] points) {
    final CoordinateReferenceSystem crs = points[0].getCoordinateReferenceSystem();
    final PrimitiveFactory primitiveFactory = new JTSPrimitiveFactory(crs);
    return createCurve(primitiveFactory, points);
}
Also used : CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) JTSPrimitiveFactory(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSPrimitiveFactory) JTSPrimitiveFactory(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSPrimitiveFactory) PrimitiveFactory(org.opengis.geometry.primitive.PrimitiveFactory)

Example 7 with JTSPrimitiveFactory

use of org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSPrimitiveFactory in project geotoolkit by Geomatys.

the class JTSUtils method linearRingToRing.

public static Ring linearRingToRing(final org.locationtech.jts.geom.LineString jtsLinearRing, final CoordinateReferenceSystem crs) {
    int numPoints = jtsLinearRing.getNumPoints();
    if (numPoints != 0 && !jtsLinearRing.getCoordinateN(0).equals(jtsLinearRing.getCoordinateN(numPoints - 1))) {
        throw new IllegalArgumentException("LineString must be a ring");
    }
    // FactoryFinder.getPrimitiveFactory(hints);
    PrimitiveFactory pf = new JTSPrimitiveFactory(crs);
    // FactoryFinder.getGeometryFactory(hints);
    GeometryFactory gf = new JTSGeometryFactory(crs);
    LineString ls = gf.createLineString(new ArrayList());
    List pointList = ls.getControlPoints();
    for (int i = 0; i < numPoints; i++) {
        pointList.add(coordinateToDirectPosition(jtsLinearRing.getCoordinateN(i), crs));
    }
    Curve curve = pf.createCurve(new ArrayList());
    // Cast below can be removed when Types will be allowed to abandon Java 1.4 support.
    ((List) curve.getSegments()).add(ls);
    Ring result = pf.createRing(new ArrayList());
    // Cast below can be removed when Types will be allowed to abandon Java 1.4 support.
    ((List) result.getGenerators()).add(curve);
    return result;
}
Also used : JTSGeometryFactory(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSGeometryFactory) GeometryFactory(org.opengis.geometry.coordinate.GeometryFactory) JTSGeometryFactory(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSGeometryFactory) JTSLineString(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSLineString) LineString(org.opengis.geometry.coordinate.LineString) MultiLineString(org.locationtech.jts.geom.MultiLineString) Ring(org.opengis.geometry.primitive.Ring) ArrayList(java.util.ArrayList) JTSCurve(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSCurve) Curve(org.opengis.geometry.primitive.Curve) JTSMultiCurve(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.aggregate.JTSMultiCurve) ArrayList(java.util.ArrayList) List(java.util.List) JTSPrimitiveFactory(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSPrimitiveFactory) JTSPrimitiveFactory(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSPrimitiveFactory) PrimitiveFactory(org.opengis.geometry.primitive.PrimitiveFactory) MultiPoint(org.locationtech.jts.geom.MultiPoint) JTSMultiPoint(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.aggregate.JTSMultiPoint)

Aggregations

JTSPrimitiveFactory (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSPrimitiveFactory)7 PrimitiveFactory (org.opengis.geometry.primitive.PrimitiveFactory)7 ArrayList (java.util.ArrayList)4 JTSGeometryFactory (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSGeometryFactory)4 GeometryFactory (org.opengis.geometry.coordinate.GeometryFactory)4 Ring (org.opengis.geometry.primitive.Ring)4 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)4 SurfaceBoundary (org.opengis.geometry.primitive.SurfaceBoundary)3 List (java.util.List)2 JTSMultiCurve (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.aggregate.JTSMultiCurve)2 JTSMultiPoint (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.aggregate.JTSMultiPoint)2 JTSLineString (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSLineString)2 JTSCurve (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSCurve)2 MultiLineString (org.locationtech.jts.geom.MultiLineString)2 MultiPoint (org.locationtech.jts.geom.MultiPoint)2 DirectPosition (org.opengis.geometry.DirectPosition)2 LineString (org.opengis.geometry.coordinate.LineString)2 Set (java.util.Set)1 DirectPosition2D (org.apache.sis.geometry.DirectPosition2D)1 GeneralDirectPosition (org.apache.sis.geometry.GeneralDirectPosition)1