use of org.opengis.geometry.primitive.Ring in project geotoolkit by Geomatys.
the class JTSMultiPolygon method applyCRSOnchild.
public void applyCRSOnchild() {
for (JTSPolygon polygon : elements) {
JTSRing exterior = (JTSRing) polygon.getBoundary().getExterior();
exterior.setCoordinateReferenceSystem(getCoordinateReferenceSystem());
for (Primitive p : (Collection<Primitive>) exterior.getElements()) {
if (p instanceof JTSCurve) {
JTSCurve curve = (JTSCurve) p;
curve.setCoordinateReferenceSystem(getCoordinateReferenceSystem());
for (CurveSegment cv : curve.getSegments()) {
if (cv instanceof JTSLineString) {
JTSLineString line = (JTSLineString) cv;
line.setCoordinateReferenceSystem(getCoordinateReferenceSystem());
PointArray pa = line.getControlPoints();
List<Position> newPositions = new ArrayList<Position>();
for (Position pos : pa) {
if (pos instanceof GeneralDirectPosition) {
((GeneralDirectPosition) pos).setCoordinateReferenceSystem(getCoordinateReferenceSystem());
newPositions.add(pos);
}
}
line.getControlPoints().clear();
line.getControlPoints().addAll(newPositions);
}
}
}
}
if (polygon.getBoundary().getInteriors() != null) {
for (Ring ring : polygon.getBoundary().getInteriors()) {
((JTSRing) ring).setCoordinateReferenceSystem(getCoordinateReferenceSystem());
for (Primitive p : ring.getElements()) {
if (p instanceof JTSCurve) {
JTSCurve curve = (JTSCurve) p;
curve.setCoordinateReferenceSystem(getCoordinateReferenceSystem());
for (CurveSegment cv : curve.getSegments()) {
if (cv instanceof JTSLineString) {
JTSLineString line = (JTSLineString) cv;
line.setCoordinateReferenceSystem(getCoordinateReferenceSystem());
PointArray pa = line.getControlPoints();
List<Position> newPositions = new ArrayList<Position>();
for (Position pos : pa) {
if (pos instanceof GeneralDirectPosition) {
((GeneralDirectPosition) pos).setCoordinateReferenceSystem(getCoordinateReferenceSystem());
newPositions.add(pos);
}
}
line.getControlPoints().clear();
line.getControlPoints().addAll(newPositions);
}
}
}
}
}
}
polygon.setCoordinateReferenceSystem(getCoordinateReferenceSystem());
}
}
use of org.opengis.geometry.primitive.Ring 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;
}
use of org.opengis.geometry.primitive.Ring in project geotoolkit by Geomatys.
the class AbstractGeometryTest method createRing.
/**
* A helper method for creating a Ring from an array of DirectPositions
*
* @param curve
* @return a <tt>Ring</tt>
*/
protected Ring createRing(final Curve curve) {
final List curveList = Collections.singletonList(curve);
final Ring ring = PRIMITIVE_FACTORY.createRing(curveList);
return ring;
}
Aggregations