use of org.geotoolkit.gml.xml.v321.DirectPositionListType in project OpenTripPlanner by opentripplanner.
the class ServiceLinkMapperTest method createServiceLink.
private ServiceLink createServiceLink(String id, double distance, Double[] coordinates) {
DirectPositionListType directPositionListType = new DirectPositionListType().withValue(coordinates);
LinkSequenceProjection linkSequenceProjection = new LinkSequenceProjection().withLineString(new LineStringType().withPosList(directPositionListType));
JAXBElement<LinkSequenceProjection_VersionStructure> linkSequenceProjection_versionStructure = MappingSupport.createJaxbElement(linkSequenceProjection);
Projections_RelStructure projections_relStructure = new Projections_RelStructure().withProjectionRefOrProjection(linkSequenceProjection_versionStructure);
return new ServiceLink().withId(id).withDistance(new BigDecimal(distance)).withProjections(projections_relStructure);
}
use of org.geotoolkit.gml.xml.v321.DirectPositionListType in project arctic-sea by 52North.
the class GmlEncoderv321 method createLineStringFromJtsGeometry.
/**
* Creates a XML LineString from a SOS LineString.
*
* @param jtsLineString
* SOS LineString
* @param xbLst
* XML LinetSring
*/
private void createLineStringFromJtsGeometry(LineString jtsLineString, LineStringType xbLst) {
String srsName = getSrsName(jtsLineString);
xbLst.setSrsName(srsName);
DirectPositionListType xbPosList = xbLst.addNewPosList();
xbPosList.setSrsName(srsName);
xbPosList.setStringValue(JTSHelper.getCoordinatesString(jtsLineString));
}
use of org.geotoolkit.gml.xml.v321.DirectPositionListType in project arctic-sea by 52North.
the class GmlEncoderv321 method createPolygonFromJtsGeometry.
/**
* Creates a XML Polygon from a SOS Polygon.
*
* @param jtsPolygon
* SOS Polygon
* @param xbPolType
* XML Polygon
*/
private void createPolygonFromJtsGeometry(Polygon jtsPolygon, PolygonType xbPolType) {
List<?> jtsPolygons = PolygonExtracter.getPolygons(jtsPolygon);
String srsName = getSrsName(jtsPolygon);
for (int i = 0; i < jtsPolygons.size(); i++) {
Polygon pol = (Polygon) jtsPolygons.get(i);
AbstractRingPropertyType xbArpt = xbPolType.addNewExterior();
AbstractRingType xbArt = xbArpt.addNewAbstractRing();
LinearRingType xbLrt = LinearRingType.Factory.newInstance();
// Exterior ring
// LineString ring = pol.getExteriorRing();
Coordinate[] ring = JTSHelper.getExteriorRingCoordinatesFromPolygon(pol);
DirectPositionListType xbPosList = xbLrt.addNewPosList();
xbPosList.setSrsName(srsName);
xbPosList.setStringValue(JTSHelper.getCoordinatesString(ring));
xbArt.set(xbLrt);
// Rename element name for output
XmlCursor cursor = xbArpt.newCursor();
if (cursor.toChild(GmlConstants.QN_ABSTRACT_RING_32)) {
cursor.setName(GmlConstants.QN_LINEAR_RING_32);
}
cursor.dispose();
// Interior ring
int numberOfInteriorRings = pol.getNumInteriorRing();
for (int ringNumber = 0; ringNumber < numberOfInteriorRings; ringNumber++) {
xbArpt = xbPolType.addNewInterior();
xbArt = xbArpt.addNewAbstractRing();
xbLrt = LinearRingType.Factory.newInstance();
xbPosList = xbLrt.addNewPosList();
xbPosList.setSrsName(srsName);
xbPosList.setStringValue(JTSHelper.getCoordinatesString(pol.getInteriorRingN(ringNumber)));
xbArt.set(xbLrt);
// Rename element name for output
cursor = xbArpt.newCursor();
if (cursor.toChild(GmlConstants.QN_ABSTRACT_RING_32)) {
cursor.setName(GmlConstants.QN_LINEAR_RING_32);
}
cursor.dispose();
}
}
}
use of org.geotoolkit.gml.xml.v321.DirectPositionListType in project geotoolkit by Geomatys.
the class GeometrytoJTSTest method gmlPolygonToJTSTest3D.
@Test
public void gmlPolygonToJTSTest3D() throws Exception {
GeometryFactory fact = GF;
final Coordinate[] coordinates = new Coordinate[5];
coordinates[0] = new Coordinate(0, 0, 1);
coordinates[1] = new Coordinate(0, 1, 1);
coordinates[2] = new Coordinate(1, 1, 1);
coordinates[3] = new Coordinate(1, 0, 1);
coordinates[4] = new Coordinate(0, 0, 1);
LinearRing linear = GF.createLinearRing(coordinates);
Polygon expected = new Polygon(linear, null, fact);
expected.setSRID(2154);
LinearRingType exterior = new LinearRingType();
List<Double> coords = new ArrayList<>();
coords.add(0.0);
coords.add(0.0);
coords.add(1.0);
coords.add(0.0);
coords.add(1.0);
coords.add(1.0);
coords.add(1.0);
coords.add(1.0);
coords.add(1.0);
coords.add(1.0);
coords.add(0.0);
coords.add(1.0);
coords.add(0.0);
coords.add(0.0);
coords.add(1.0);
exterior.setPosList(new DirectPositionListType(coords));
exterior.setSrsDimension(3);
PolygonType gml = new PolygonType(exterior, null);
final Geometry result = GeometrytoJTS.toJTS((org.geotoolkit.gml.xml.Polygon) gml);
Assert.assertEquals(expected, result);
}
use of org.geotoolkit.gml.xml.v321.DirectPositionListType 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);
}
Aggregations