Search in sources :

Example 26 with Ring

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());
    }
}
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 27 with Ring

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;
}
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 28 with Ring

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;
}
Also used : Ring(org.opengis.geometry.primitive.Ring) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

Ring (org.opengis.geometry.primitive.Ring)28 ArrayList (java.util.ArrayList)14 JTSLineString (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSLineString)13 JTSCurve (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSCurve)13 DirectPosition (org.opengis.geometry.DirectPosition)13 GeneralDirectPosition (org.apache.sis.geometry.GeneralDirectPosition)12 JTSPolygon (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSPolygon)12 JTSRing (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSRing)11 JTSSurfaceBoundary (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSSurfaceBoundary)11 SurfaceBoundary (org.opengis.geometry.primitive.SurfaceBoundary)11 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)11 List (java.util.List)9 PointArray (org.opengis.geometry.coordinate.PointArray)6 CurveSegment (org.opengis.geometry.primitive.CurveSegment)6 Primitive (org.opengis.geometry.primitive.Primitive)6 JTSPolyhedralSurface (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSPolyhedralSurface)5 StringReader (java.io.StringReader)4 StringWriter (java.io.StringWriter)4 JTSGeometryFactory (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSGeometryFactory)4 JTSPrimitiveFactory (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSPrimitiveFactory)4