Search in sources :

Example 1 with LineStringType

use of org.geotoolkit.gml.xml.v311.LineStringType in project ddf by codice.

the class TestWfs10JTStoGML200Converter method testGMLToLineStringType.

@Test
public void testGMLToLineStringType() throws JAXBException, SAXException, IOException, ParseException, NullPointerException {
    LineString lineString = (LineString) getGeometryFromWkt(LINESTRING);
    assertThat(lineString == null, is(Boolean.FALSE));
    String lineStringGML = Wfs10JTStoGML200Converter.convertGeometryToGML(lineString);
    LineStringType lineStringType = (LineStringType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(lineStringGML, Wfs10Constants.LINESTRING);
    assertThat(Wfs10Constants.LINESTRING.getLocalPart().equals(lineStringType.getJAXBElementName().getLocalPart()), is(Boolean.TRUE));
    String coords = lineStringType.getCoordinates().getValue().replaceAll("\n", "").trim();
    assertThat(coords.isEmpty(), is(Boolean.FALSE));
    assertThat(LINESTRING_COORDS.equals(coords), is(Boolean.TRUE));
}
Also used : LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) MultiLineStringType(ogc.schema.opengis.gml.v_2_1_2.MultiLineStringType) LineStringType(ogc.schema.opengis.gml.v_2_1_2.LineStringType) Test(org.junit.Test)

Example 2 with LineStringType

use of org.geotoolkit.gml.xml.v311.LineStringType in project ddf by codice.

the class TestWfs10JTStoGML200Converter method extractLineStringMemberCoordinates.

private String extractLineStringMemberCoordinates(JAXBElement element1) throws JAXBException, SAXException, IOException, ParseException, NullPointerException {
    assertThat(Wfs10Constants.LINESTRING_MEMBER.getLocalPart().equals(element1.getName().getLocalPart()), is(Boolean.TRUE));
    LineStringMemberType lsMemberType1 = (LineStringMemberType) element1.getValue();
    JAXBElement geometry1 = lsMemberType1.getGeometry();
    LineStringType lineStringType = (LineStringType) geometry1.getValue();
    return lineStringType.getCoordinates().getValue().replaceAll("\n", "").trim();
}
Also used : JAXBElement(javax.xml.bind.JAXBElement) MultiLineStringType(ogc.schema.opengis.gml.v_2_1_2.MultiLineStringType) LineStringType(ogc.schema.opengis.gml.v_2_1_2.LineStringType) LineStringMemberType(ogc.schema.opengis.gml.v_2_1_2.LineStringMemberType)

Example 3 with LineStringType

use of org.geotoolkit.gml.xml.v311.LineStringType in project ddf by codice.

the class WfsFilterDelegate method createLineString.

private JAXBElement<LineStringType> createLineString(Geometry geometry) {
    JAXBElement<LineStringType> jaxbElement = null;
    try {
        String gml = Wfs10JTStoGML200Converter.convertGeometryToGML(geometry);
        LineStringType lineStringType = (LineStringType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(gml, Wfs10Constants.LINESTRING);
        jaxbElement = (JAXBElement<LineStringType>) Wfs10JTStoGML200Converter.convertGeometryTypeToJAXB(lineStringType);
    } catch (JAXBException jbe) {
        LOGGER.debug("Unable to create LineString with geometry: [{}]", geometry);
    }
    return jaxbElement;
}
Also used : JAXBException(javax.xml.bind.JAXBException) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) MultiLineStringType(ogc.schema.opengis.gml.v_2_1_2.MultiLineStringType) LineStringType(ogc.schema.opengis.gml.v_2_1_2.LineStringType)

Example 4 with LineStringType

use of org.geotoolkit.gml.xml.v311.LineStringType in project ddf by codice.

the class Wfs20JTStoGML321Converter method convertToLineStringType.

public static LineStringType convertToLineStringType(LineString line, String srsName) {
    LineStringType lineStringType = GML320_OBJECT_FACTORY.createLineStringType();
    CoordinatesType coordinatesType = GML320_OBJECT_FACTORY.createCoordinatesType();
    StringBuilder stringBuffer = new StringBuilder();
    for (int i = 0; i < line.getCoordinateSequence().size(); i++) {
        Coordinate coordinate = line.getCoordinateSequence().getCoordinate(i);
        if (i != 0) {
            stringBuffer.append(" ");
        }
        stringBuffer.append(coordinate.x).append(",").append(coordinate.y);
        if (!Double.isNaN(coordinate.z)) {
            stringBuffer.append(",").append(coordinate.z);
        }
    }
    coordinatesType.setValue(stringBuffer.toString());
    lineStringType.setCoordinates(coordinatesType);
    lineStringType.setSrsName(srsName);
    return lineStringType;
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) LineStringType(net.opengis.gml.v_3_2_1.LineStringType) Point(org.locationtech.jts.geom.Point) MultiPoint(org.locationtech.jts.geom.MultiPoint) CoordinatesType(net.opengis.gml.v_3_2_1.CoordinatesType)

Example 5 with LineStringType

use of org.geotoolkit.gml.xml.v311.LineStringType in project ddf by codice.

the class Wfs20JTStoGML321Converter method convertToRingType.

public static RingType convertToRingType(LinearRing line, String srsName) {
    RingType ringType = GML320_OBJECT_FACTORY.createRingType();
    CurvePropertyType curvePropertyType = GML320_OBJECT_FACTORY.createCurvePropertyType();
    LineStringType curve = convertToLineStringType(line, srsName);
    JAXBElement<LineStringType> lineStringTypeJAXBElement = GML320_OBJECT_FACTORY.createLineString(curve);
    curvePropertyType.setAbstractCurve(lineStringTypeJAXBElement);
    ringType.getCurveMember().add(curvePropertyType);
    return ringType;
}
Also used : CurvePropertyType(net.opengis.gml.v_3_2_1.CurvePropertyType) LineStringType(net.opengis.gml.v_3_2_1.LineStringType) RingType(net.opengis.gml.v_3_2_1.RingType)

Aggregations

Test (org.junit.Test)11 LineString (org.locationtech.jts.geom.LineString)9 Coordinate (org.locationtech.jts.geom.Coordinate)7 ArrayList (java.util.ArrayList)6 JAXBElement (javax.xml.bind.JAXBElement)6 Geometry (org.locationtech.jts.geom.Geometry)6 LineStringType (net.opengis.gml._3.LineStringType)5 LineStringType (net.opengis.gml.v_3_2_1.LineStringType)5 LineStringType (ogc.schema.opengis.gml.v_2_1_2.LineStringType)5 MultiLineStringType (ogc.schema.opengis.gml.v_2_1_2.MultiLineStringType)5 LineString (com.vividsolutions.jts.geom.LineString)4 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)4 List (java.util.List)4 DirectPositionListType (net.opengis.gml._3.DirectPositionListType)4 LineStringType (net.opengis.gml.v_3_1_1.LineStringType)3 LineStringType (org.geotoolkit.gml.xml.v311.LineStringType)3 MultiPoint (org.locationtech.jts.geom.MultiPoint)3 Point (org.locationtech.jts.geom.Point)3 BigDecimal (java.math.BigDecimal)2 TypeBuilder (ma.glasnost.orika.metadata.TypeBuilder)2