use of org.geotoolkit.gml.xml.v321.CurveSegmentArrayPropertyType in project geotoolkit by Geomatys.
the class GeometrytoJTSTest method gmlGeodesicStringToJTSTest2D.
@Test
public void gmlGeodesicStringToJTSTest2D() throws Exception {
final DirectPositionListType posLst = new DirectPositionListType(Arrays.asList(10.0, 20.0, 30.0, 40.0, 50.0, 60.0));
final GeodesicStringType s = new GeodesicStringType();
s.setPosList(posLst);
final CurveSegmentArrayPropertyType segments = new CurveSegmentArrayPropertyType();
segments.setAbstractCurveSegment(s);
final CurveType curve = new CurveType();
curve.setSegments(segments);
final LineString expected = GF.createLineString(new Coordinate[] { new Coordinate(10, 20), new Coordinate(30, 40), new Coordinate(50, 60) });
final Geometry result = GeometrytoJTS.toJTS(curve);
Assert.assertEquals(expected, result);
}
use of org.geotoolkit.gml.xml.v321.CurveSegmentArrayPropertyType in project geotoolkit by Geomatys.
the class GeometrytoJTSTest method gmlArcToJTSTest.
@Test
public void gmlArcToJTSTest() throws Exception {
final LengthType radius = new LengthType();
radius.setValue(2.0);
radius.setUom("m");
final AngleType startAngle = new AngleType();
startAngle.setValue(0);
startAngle.setUom("rad");
final AngleType endAngle = new AngleType();
endAngle.setValue(270);
endAngle.setUom("°");
final ArcByCenterPointType arc = new ArcByCenterPointType();
arc.setStartAngle(startAngle);
arc.setEndAngle(endAngle);
arc.setRadius(radius);
arc.setPointProperty(new PointPropertyType(new PointType(new DirectPosition2D(0, 0))));
final CurveType gmlCurve = new CurveType();
gmlCurve.setSrsName("EPSG:3857");
gmlCurve.setSegments(new CurveSegmentArrayPropertyType(Collections.singletonList(arc)));
Geometry geom = GeometrytoJTS.toJTS(gmlCurve);
// For geometric comparison, we oppose pure jts solution to the SIS geodetic calculator.
final GeometricShapeFactory f = new GeometricShapeFactory(GF);
f.setCentre(new Coordinate(0, 0));
f.setSize(radius.getValue() * 2);
// with this value, we should get points on trigonometric circle cardinalities (0, PI/2, PI, etc.), which eases comparison in debug.
f.setNumPoints(17);
// JTS angles are not azimuth, but pure trigonometric
Geometry expectedArc = f.createArc(Math.PI, 3 / 2.0 * Math.PI);
Assert.assertTrue(expectedArc.buffer(0.2).contains(geom));
// Now, test in reverse (counter-clockwise) order
endAngle.setValue(-90);
geom = GeometrytoJTS.toJTS(gmlCurve);
expectedArc = f.createArc(0, Math.PI);
Assert.assertTrue(expectedArc.buffer(0.2).contains(geom));
}
Aggregations