Search in sources :

Example 1 with GeometryCollectionType

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

the class TestWfs10JTStoGML200Converter method testGeometryCollectionTypeToJAXB.

@Test
public void testGeometryCollectionTypeToJAXB() throws JAXBException, SAXException, IOException, ParseException, NullPointerException {
    String geometryCollectionGML = Wfs10JTStoGML200Converter.convertGeometryToGML(getGeometryFromWkt(GEOMETRYCOLLECTION)).replaceAll("\n", "");
    GeometryCollectionType geometryCollectionType = (GeometryCollectionType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(geometryCollectionGML, Wfs10Constants.GEOMETRY_COLLECTION);
    JAXBElement<GeometryCollectionType> geometryCollectionTypeJAXBElement = (JAXBElement<GeometryCollectionType>) Wfs10JTStoGML200Converter.convertGeometryTypeToJAXB(geometryCollectionType);
    JAXB.marshal(geometryCollectionTypeJAXBElement, writer);
    String xml = writer.toString().replaceAll("\n", "");
    Diff diff = XMLUnit.compareXML(xml, GEOMETRYCOLLECTION_NS1);
    assertTrue(XMLUNIT_SIMILAR, diff.similar());
    assertThat(diff.similar(), is(Boolean.TRUE));
    assertThat(diff.identical(), is(Boolean.TRUE));
}
Also used : GeometryCollectionType(ogc.schema.opengis.gml.v_2_1_2.GeometryCollectionType) Diff(org.custommonkey.xmlunit.Diff) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) JAXBElement(javax.xml.bind.JAXBElement) Test(org.junit.Test)

Example 2 with GeometryCollectionType

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

the class TestWfs10JTStoGML200Converter method testTwo.

@Test
public void testTwo() throws Exception {
    Geometry geometryFromWkt = getGeometryFromWkt(GEOMETRYCOLLECTION);
    String gml = Wfs10JTStoGML200Converter.convertGeometryCollectionToGML(geometryFromWkt);
    GeometryCollectionType geometryCollectionType = (GeometryCollectionType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(gml, Wfs10Constants.GEOMETRY_COLLECTION);
    JAXBElement<GeometryCollectionType> jaxbElement = (JAXBElement<GeometryCollectionType>) Wfs10JTStoGML200Converter.convertGeometryTypeToJAXB(geometryCollectionType);
    assertFalse(jaxbElement == null);
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) GeometryCollectionType(ogc.schema.opengis.gml.v_2_1_2.GeometryCollectionType) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) JAXBElement(javax.xml.bind.JAXBElement) Test(org.junit.Test)

Example 3 with GeometryCollectionType

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

Example 4 with GeometryCollectionType

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

the class WfsFilterDelegate method createGeometryCollection.

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

Aggregations

LineString (com.vividsolutions.jts.geom.LineString)4 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)4 GeometryCollectionType (ogc.schema.opengis.gml.v_2_1_2.GeometryCollectionType)4 JAXBElement (javax.xml.bind.JAXBElement)3 Test (org.junit.Test)3 Geometry (com.vividsolutions.jts.geom.Geometry)1 JAXBException (javax.xml.bind.JAXBException)1 GeometryAssociationType (ogc.schema.opengis.gml.v_2_1_2.GeometryAssociationType)1 LineStringType (ogc.schema.opengis.gml.v_2_1_2.LineStringType)1 MultiLineStringType (ogc.schema.opengis.gml.v_2_1_2.MultiLineStringType)1 MultiPointType (ogc.schema.opengis.gml.v_2_1_2.MultiPointType)1 PointType (ogc.schema.opengis.gml.v_2_1_2.PointType)1 Diff (org.custommonkey.xmlunit.Diff)1