* @return new instance of polygon adapted polygon
*/
public Polygon asPolygon() {
// makes the exterior ring using the modified segments
LinearRing originalExteriorRing = (LinearRing) this.originalPolygon.getExteriorRing();
LinearRing exteriorRing = buildAdaptedRing(originalExteriorRing);
// makes the interior rings using the modified hole segments
final Set<Entry<LinearRing, Map<String,LineString>>> entrySet = this.ringSegmentAdaptedAssociation.entrySet();
LinearRing[] holes = new LinearRing[entrySet.size()-1];
int i = 0;
for( Entry<LinearRing, Map<String, LineString>> entry : entrySet ) {
LinearRing currentRing = entry.getKey();
if( ! currentRing.equals(originalExteriorRing) ){
// it is an interior ring (hole)
LinearRing holeRing = buildAdaptedRing(currentRing);
holes[i++] = holeRing;
}
}
Polygon polygon = this.geomFactory.createPolygon(exteriorRing, holes);