Search in sources :

Example 21 with JTSCurve

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());
    }
}
Also used : GeneralDirectPosition(org.apache.sis.geometry.GeneralDirectPosition) JTSRing(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSRing) Position(org.opengis.geometry.coordinate.Position) GeneralDirectPosition(org.apache.sis.geometry.GeneralDirectPosition) JTSPolygon(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSPolygon) JTSCurve(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSCurve) PointArray(org.opengis.geometry.coordinate.PointArray) JTSLineString(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSLineString) Primitive(org.opengis.geometry.primitive.Primitive) CurveSegment(org.opengis.geometry.primitive.CurveSegment) JTSRing(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSRing) Ring(org.opengis.geometry.primitive.Ring)

Example 22 with JTSCurve

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;
}
Also used : GeneralDirectPosition(org.apache.sis.geometry.GeneralDirectPosition) JTSRing(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSRing) Position(org.opengis.geometry.coordinate.Position) GeneralDirectPosition(org.apache.sis.geometry.GeneralDirectPosition) JTSPolygon(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSPolygon) JTSSurfaceBoundary(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSSurfaceBoundary) ArrayList(java.util.ArrayList) JTSCurve(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSCurve) PointArray(org.opengis.geometry.coordinate.PointArray) JTSLineString(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSLineString) Primitive(org.opengis.geometry.primitive.Primitive) CurveSegment(org.opengis.geometry.primitive.CurveSegment) JTSRing(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSRing) Ring(org.opengis.geometry.primitive.Ring)

Example 23 with JTSCurve

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;
}
Also used : JTSCurve(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSCurve) JTSLineString(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSLineString)

Aggregations

JTSLineString (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSLineString)23 JTSCurve (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSCurve)23 GeneralDirectPosition (org.apache.sis.geometry.GeneralDirectPosition)21 DirectPosition (org.opengis.geometry.DirectPosition)18 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)16 JTSRing (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSRing)14 JTSPolygon (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSPolygon)12 Ring (org.opengis.geometry.primitive.Ring)12 JTSSurfaceBoundary (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSSurfaceBoundary)10 StringReader (java.io.StringReader)8 StringWriter (java.io.StringWriter)8 JTSPolyhedralSurface (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSPolyhedralSurface)5 ArrayList (java.util.ArrayList)4 PointArray (org.opengis.geometry.coordinate.PointArray)4 CurveSegment (org.opengis.geometry.primitive.CurveSegment)4 JTSMultiCurve (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.aggregate.JTSMultiCurve)3 JTSMultiPrimitive (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.aggregate.JTSMultiPrimitive)3 Position (org.opengis.geometry.coordinate.Position)3 Primitive (org.opengis.geometry.primitive.Primitive)3 JAXBElement (javax.xml.bind.JAXBElement)2