Search in sources :

Example 11 with CurveSegment

use of org.opengis.geometry.primitive.CurveSegment in project geotoolkit by Geomatys.

the class JTSCurve method setCurveArray.

public void setCurveArray(final CurveArrayType array) {
    curveSegments = new NotifyingArrayList<CurveSegment>(this);
    for (CurveSegment c : array.getCurveSegments()) {
        JTSLineString line = (JTSLineString) c;
        JTSLineString newLine = new JTSLineString(getCoordinateReferenceSystem());
        for (Position p : line.getPositions()) {
            if (p instanceof GeneralDirectPosition) {
                ((GeneralDirectPosition) p).setCoordinateReferenceSystem(getCoordinateReferenceSystem());
                newLine.getPositions().add(p);
            }
        }
        curveSegments.add(newLine);
    }
}
Also used : GeneralDirectPosition(org.apache.sis.geometry.GeneralDirectPosition) CurveSegment(org.opengis.geometry.primitive.CurveSegment) Position(org.opengis.geometry.coordinate.Position) GeneralDirectPosition(org.apache.sis.geometry.GeneralDirectPosition) DirectPosition(org.opengis.geometry.DirectPosition) JTSLineString(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSLineString)

Example 12 with CurveSegment

use of org.opengis.geometry.primitive.CurveSegment in project geotoolkit by Geomatys.

the class JTSCurve method forConstructiveParam.

// We choose to parameterize the curve as a function from the interval
// [0, n] to R_n, where interval [i, i+1] corresponds to curve i, and
// the in between points are mapped linearly between the constructive params
// of curve i, i.e. C(i+d) = C_i((1-d)*scp + d*ecp), 0 <= d < 1, scp is the
// start constructive param of curve segment i, ecp is the end constructive
// param of curve segment i.
@Override
public final DirectPosition forConstructiveParam(final double cp) {
    int n = curveSegments.size();
    int i = (int) cp;
    if (i < 0) {
        i = 0;
    } else if (i > n) {
        i = n;
    }
    if (i == n) {
        return (curveSegments.get(n - 1)).getEndPoint();
    } else {
        CurveSegment cs = curveSegments.get(i);
        // 0 <= d < 1
        double d = cp - i;
        return cs.forConstructiveParam((1 - d) * cs.getStartConstructiveParam() + d * cs.getEndConstructiveParam());
    }
}
Also used : CurveSegment(org.opengis.geometry.primitive.CurveSegment) ParamForPoint(org.opengis.geometry.coordinate.ParamForPoint)

Example 13 with CurveSegment

use of org.opengis.geometry.primitive.CurveSegment 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 14 with CurveSegment

use of org.opengis.geometry.primitive.CurveSegment 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

CurveSegment (org.opengis.geometry.primitive.CurveSegment)14 DirectPosition (org.opengis.geometry.DirectPosition)7 Position (org.opengis.geometry.coordinate.Position)7 ArrayList (java.util.ArrayList)6 Ring (org.opengis.geometry.primitive.Ring)6 JTSLineString (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSLineString)5 PointArray (org.opengis.geometry.coordinate.PointArray)5 GeneralDirectPosition (org.apache.sis.geometry.GeneralDirectPosition)4 JTSCurve (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSCurve)4 LineString (org.opengis.geometry.coordinate.LineString)4 OrientableCurve (org.opengis.geometry.primitive.OrientableCurve)4 Primitive (org.opengis.geometry.primitive.Primitive)4 JTSPolygon (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSPolygon)3 JTSRing (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSRing)3 Curve (org.opengis.geometry.primitive.Curve)3 SurfaceBoundary (org.opengis.geometry.primitive.SurfaceBoundary)3 List (java.util.List)2 JTSSurfaceBoundary (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSSurfaceBoundary)2 Test (org.junit.Test)2 DirectPosition2D (org.apache.sis.geometry.DirectPosition2D)1