Search in sources :

Example 6 with Primitive

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;
}
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

Primitive (org.opengis.geometry.primitive.Primitive)6 Ring (org.opengis.geometry.primitive.Ring)6 PointArray (org.opengis.geometry.coordinate.PointArray)4 CurveSegment (org.opengis.geometry.primitive.CurveSegment)4 ArrayList (java.util.ArrayList)3 GeneralDirectPosition (org.apache.sis.geometry.GeneralDirectPosition)3 JTSLineString (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSLineString)3 JTSPolygon (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSPolygon)3 JTSCurve (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSCurve)3 JTSRing (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSRing)3 JTSSurfaceBoundary (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSSurfaceBoundary)2 CurveImpl (org.geotools.geometry.iso.primitive.CurveImpl)2 SurfaceImpl (org.geotools.geometry.iso.primitive.SurfaceImpl)2 Position (org.opengis.geometry.coordinate.Position)2 List (java.util.List)1 JTSPolyhedralSurface (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSPolyhedralSurface)1 AbstractCurveType (org.geotoolkit.gml.xml.v311.AbstractCurveType)1 AbstractGMLType (org.geotoolkit.gml.xml.v311.AbstractGMLType)1 AbstractGeometryType (org.geotoolkit.gml.xml.v311.AbstractGeometryType)1 CurveInterpolationType (org.geotoolkit.gml.xml.v311.CurveInterpolationType)1