* @param currentGeom
* @return Polygon
*/
public static Polygon createPolygon( EditGeom currentGeom ) {
Coordinate[] shellCoords = currentGeom.getShell().coordArray();
LinearRing shell = GeometryBuilder.create().safeCreateLinearRing(shellCoords);
try {
if (CGAlgorithms.isCCW(shellCoords)) {
shell = JTSUtilities.reverseRing(shell);
}
} catch (Exception e) {
EditPlugin.log("Not a critical problem, just an FYI", e); //$NON-NLS-1$
}
List<LinearRing> currentHoles = new ArrayList<LinearRing>();
for( PrimitiveShape shape : currentGeom.getHoles() ) {
Coordinate[] coordArray = shape.coordArray();
if (coordArray.length == 0) {
continue;
}
LinearRing hole = GeometryBuilder.create().safeCreateLinearRing(coordArray);
// FIXME test when the hole has only one coordinate.
if (!(coordArray.length <= 2) && !CGAlgorithms.isCCW(coordArray)) {
hole = JTSUtilities.reverseRing((LinearRing) hole);
}
currentHoles.add(hole);