use of org.opengis.geometry.coordinate.LineSegment in project geotoolkit by Geomatys.
the class SurfaceImplTest method testLargeSurface.
/**
* We need to create a large surface with 7000 points
*/
@Test
public void testLargeSurface() {
int NUMBER = 100000;
double delta = 360.0 / (double) NUMBER;
PointArray points = postitionFactory.createPointArray();
for (double angle = 0.0; angle < 360.0; angle += delta) {
double[] coordinates = new double[] { Math.sin(Math.toRadians(angle)), Math.cos(Math.toRadians(angle)) };
DirectPosition point = postitionFactory.createDirectPosition(coordinates);
points.add(point);
}
List<OrientableCurve> curves = new ArrayList<OrientableCurve>();
// A curve will be created
// - The curve will be set as parent curves for the Curve segments
// - Start and end params for the CurveSegments will be set
List<CurveSegment> segmentList = new ArrayList<CurveSegment>();
for (int i = 0; i < points.size(); i++) {
int start = i;
int end = (i + 1) % points.size();
DirectPosition point1 = points.getDirectPosition(start, null);
DirectPosition point2 = points.getDirectPosition(end, null);
LineSegment segment = geometryFactory.createLineSegment(point1, point2);
segmentList.add(segment);
}
Curve curve = primitiveFactory.createCurve(segmentList);
curves.add(curve);
Ring ring = primitiveFactory.createRing(curves);
SurfaceBoundary boundary = primitiveFactory.createSurfaceBoundary(ring, new ArrayList());
JTSSurface surface = (JTSSurface) primitiveFactory.createSurface(boundary);
Geometry peer = surface.computeJTSPeer();
}
use of org.opengis.geometry.coordinate.LineSegment in project sldeditor by robward-scisys.
the class WKTConversion method extractLineSegments.
/**
* Extract line segments.
*
* @param curveImpl the curve impl
* @param ptList the pt list
*/
private static void extractLineSegments(CurveImpl curveImpl, WKTSegmentList ptList) {
for (LineSegment lineSegment : curveImpl.asLineSegments()) {
WKTPoint startPoint = new WKTPoint(lineSegment.getStartPoint());
WKTPoint endPoint = new WKTPoint(lineSegment.getEndPoint());
ptList.addPoint(startPoint);
ptList.addPoint(endPoint);
}
ptList.removeIfFirstLastSame();
}
Aggregations