use of org.opengis.geometry.primitive.Primitive in project geotoolkit by Geomatys.
the class PolygonType method getJTSPolygon.
public JTSPolygon getJTSPolygon() {
final Ring out;
if (exterior != null) {
out = exterior;
} else {
out = outerBoundaryIs;
}
if (out != null) {
((JTSRing) out).setCoordinateReferenceSystem(coordinateReferenceSystem);
for (Primitive p : out.getElements()) {
if (p instanceof JTSCurve) {
JTSCurve curve = (JTSCurve) p;
curve.setCoordinateReferenceSystem(coordinateReferenceSystem);
for (CurveSegment cv : curve.getSegments()) {
if (cv instanceof JTSLineString) {
JTSLineString line = (JTSLineString) cv;
line.setCoordinateReferenceSystem(coordinateReferenceSystem);
PointArray pa = line.getControlPoints();
List<Position> newPositions = new ArrayList<Position>();
for (Position pos : pa) {
if (pos instanceof GeneralDirectPosition) {
((GeneralDirectPosition) pos).setCoordinateReferenceSystem(coordinateReferenceSystem);
newPositions.add(pos);
}
}
line.getControlPoints().clear();
line.getControlPoints().addAll(newPositions);
}
}
}
}
}
List<Ring> inte;
if (interior != null) {
inte = interior;
} else {
inte = innerBoundaryIs;
}
if (inte != null) {
for (Ring ring : inte) {
((JTSRing) ring).setCoordinateReferenceSystem(coordinateReferenceSystem);
for (Primitive p : ring.getElements()) {
if (p instanceof JTSCurve) {
JTSCurve curve = (JTSCurve) p;
curve.setCoordinateReferenceSystem(coordinateReferenceSystem);
for (CurveSegment cv : curve.getSegments()) {
if (cv instanceof JTSLineString) {
JTSLineString line = (JTSLineString) cv;
line.setCoordinateReferenceSystem(coordinateReferenceSystem);
PointArray pa = line.getControlPoints();
List<Position> newPositions = new ArrayList<Position>();
for (Position pos : pa) {
if (pos instanceof GeneralDirectPosition) {
((GeneralDirectPosition) pos).setCoordinateReferenceSystem(coordinateReferenceSystem);
newPositions.add(pos);
}
}
line.getControlPoints().clear();
line.getControlPoints().addAll(newPositions);
}
}
}
}
}
} else {
inte = new ArrayList<Ring>();
}
final JTSPolygon result = new JTSPolygon(new JTSSurfaceBoundary(coordinateReferenceSystem, out, inte));
result.setCoordinateReferenceSystem(coordinateReferenceSystem);
return result;
}
Aggregations