int numPoints = jtsLinearRing.getNumPoints();
if (! jtsLinearRing.getCoordinateN(0).equals(jtsLinearRing.getCoordinateN(numPoints-1))) {
throw new IllegalArgumentException("LineString must be a ring");
}
Hints hints = new Hints( Hints.CRS, crs );
PrimitiveFactory pf = GeometryFactoryFinder.getPrimitiveFactory(hints);
GeometryFactory gf = GeometryFactoryFinder.getGeometryFactory(hints);
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 GeoAPI 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 GeoAPI will be allowed to abandon Java 1.4 support.
((List) result.getGenerators()).add(curve);
return result;
}