Search in sources :

Example 11 with JTSSurfaceBoundary

use of org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSSurfaceBoundary 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)

Aggregations

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