Search in sources :

Example 6 with LineStringType

use of ogc.schema.opengis.gml.v_2_1_2.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 7 with LineStringType

use of ogc.schema.opengis.gml.v_2_1_2.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 8 with LineStringType

use of ogc.schema.opengis.gml.v_2_1_2.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 9 with LineStringType

use of ogc.schema.opengis.gml.v_2_1_2.LineStringType in project ddf by codice.

the class TestWfs10JTStoGML200Converter method testLineStringTypeToJAXB.

@Test
public void testLineStringTypeToJAXB() 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);
    JAXBElement<LineStringType> lineStringTypeJAXBElement = (JAXBElement<LineStringType>) Wfs10JTStoGML200Converter.convertGeometryTypeToJAXB(lineStringType);
    XMLUnit.setNormalizeWhitespace(Boolean.TRUE);
    JAXB.marshal(lineStringTypeJAXBElement, writer);
    String xml = writer.toString();
    Diff diff = XMLUnit.compareXML(xml, LINESTRING_GML);
    assertTrue(XMLUNIT_SIMILAR, diff.similar());
    assertThat(diff.similar(), is(Boolean.TRUE));
    assertThat(diff.identical(), is(Boolean.FALSE));
}
Also used : LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) Diff(org.custommonkey.xmlunit.Diff) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) 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) Test(org.junit.Test)

Example 10 with LineStringType

use of ogc.schema.opengis.gml.v_2_1_2.LineStringType in project ddf by codice.

the class TestWfs10JTStoGML200Converter method testGMLToGeometryCollectionType.

@Test
public void testGMLToGeometryCollectionType() throws JAXBException, SAXException, IOException, ParseException, NullPointerException {
    String geometryCollectionGML = Wfs10JTStoGML200Converter.convertGeometryToGML(getGeometryFromWkt(GEOMETRYCOLLECTION));
    GeometryCollectionType geometryCollectionType = (GeometryCollectionType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(geometryCollectionGML, Wfs10Constants.GEOMETRY_COLLECTION);
    assertFalse(geometryCollectionType == null);
    List<JAXBElement<? extends GeometryAssociationType>> geometryMembers = geometryCollectionType.getGeometryMember();
    assertThat(CollectionUtils.isEmpty(geometryMembers), is(Boolean.FALSE));
    assertThat(geometryMembers.size() == 2, is(Boolean.TRUE));
    GeometryAssociationType geometryAssociationType = geometryMembers.get(0).getValue();
    JAXBElement<? extends AbstractGeometryType> jaxbElement = geometryAssociationType.getGeometry();
    assertThat(Wfs10Constants.POINT.getLocalPart().equals(jaxbElement.getName().getLocalPart()), is(Boolean.TRUE));
    PointType pointType = (PointType) jaxbElement.getValue();
    assertThat(pointType == null, is(Boolean.FALSE));
    assertThat(GEOMETRYCOLLECTION_POINT_COORD.equals(pointType.getCoordinates().getValue().trim()), is(Boolean.TRUE));
    GeometryAssociationType geometryAssociationType2 = geometryMembers.get(1).getValue();
    JAXBElement<? extends AbstractGeometryType> jaxbElement2 = geometryAssociationType2.getGeometry();
    assertThat(Wfs10Constants.LINESTRING.getLocalPart().equals(jaxbElement2.getName().getLocalPart()), is(Boolean.TRUE));
    LineStringType lineStringType = (LineStringType) jaxbElement2.getValue();
    assertThat(lineStringType == null, is(Boolean.FALSE));
    assertThat(GEOMETRYCOLLECTION_LINESTRING_COORD.equals(lineStringType.getCoordinates().getValue().trim()), is(Boolean.TRUE));
}
Also used : GeometryAssociationType(ogc.schema.opengis.gml.v_2_1_2.GeometryAssociationType) GeometryCollectionType(ogc.schema.opengis.gml.v_2_1_2.GeometryCollectionType) PointType(ogc.schema.opengis.gml.v_2_1_2.PointType) MultiPointType(ogc.schema.opengis.gml.v_2_1_2.MultiPointType) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) 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) Test(org.junit.Test)

Aggregations

LineString (com.vividsolutions.jts.geom.LineString)5 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)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 JAXBElement (javax.xml.bind.JAXBElement)3 Test (org.junit.Test)3 MultiPoint (com.vividsolutions.jts.geom.MultiPoint)2 Point (com.vividsolutions.jts.geom.Point)2 Coordinate (com.vividsolutions.jts.geom.Coordinate)1 GeometryCollection (com.vividsolutions.jts.geom.GeometryCollection)1 MultiPolygon (com.vividsolutions.jts.geom.MultiPolygon)1 Polygon (com.vividsolutions.jts.geom.Polygon)1 JAXBException (javax.xml.bind.JAXBException)1 CoordinatesType (net.opengis.gml.v_3_2_1.CoordinatesType)1 CurvePropertyType (net.opengis.gml.v_3_2_1.CurvePropertyType)1 DirectPositionType (net.opengis.gml.v_3_2_1.DirectPositionType)1 GeometryPropertyType (net.opengis.gml.v_3_2_1.GeometryPropertyType)1 MultiCurveType (net.opengis.gml.v_3_2_1.MultiCurveType)1 MultiGeometryType (net.opengis.gml.v_3_2_1.MultiGeometryType)1