use of org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSCurve 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.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSCurve 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.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSCurve in project geotoolkit by Geomatys.
the class CurveLineAdapter method unmarshal.
@Override
public OrientableCurve unmarshal(final CurveLineAdapter v) throws Exception {
if (v != null && v.lineString != null && v.lineString.getValue() != null) {
LineStringPosListType posList = (LineStringPosListType) v.lineString.getValue();
JTSLineString line = posList.getJTSLineString();
JTSCurve curve = new JTSCurve(null);
curve.getSegments().add(line);
return curve;
}
return null;
}
Aggregations