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);
}
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;
}
Aggregations