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);
}
}
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());
}
}
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());
}
}
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;
}
Aggregations