Search in sources :

Example 1 with MultiPolygonType

use of net.opengis.gml.v_3_1_1.MultiPolygonType in project ddf by codice.

the class TestWfs10JTStoGML200Converter method testMultiPolygonTypeToJAXB.

@Test
public void testMultiPolygonTypeToJAXB() throws JAXBException, SAXException, IOException, ParseException, NullPointerException {
    String multiPolygonGML = Wfs10JTStoGML200Converter.convertGeometryToGML(getGeometryFromWkt(MULTIPOLYGON));
    MultiPolygonType multiPolygonType = (MultiPolygonType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(multiPolygonGML, Wfs10Constants.MULTI_POLYGON);
    JAXBElement<MultiPolygonType> multiPolygonTypeJAXBElement = (JAXBElement<MultiPolygonType>) Wfs10JTStoGML200Converter.convertGeometryTypeToJAXB(multiPolygonType);
    JAXB.marshal(multiPolygonTypeJAXBElement, writer);
    String xml = writer.toString();
    Diff diff = XMLUnit.compareXML(xml, MULTIPOLYGON_GML);
    assertTrue(XMLUNIT_SIMILAR, diff.similar());
    assertThat(diff.similar(), is(Boolean.TRUE));
    assertThat(diff.identical(), is(Boolean.FALSE));
}
Also used : Diff(org.custommonkey.xmlunit.Diff) MultiPolygonType(ogc.schema.opengis.gml.v_2_1_2.MultiPolygonType) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) JAXBElement(javax.xml.bind.JAXBElement) Test(org.junit.Test)

Example 2 with MultiPolygonType

use of net.opengis.gml.v_3_1_1.MultiPolygonType in project ddf by codice.

the class TestWfs10JTStoGML200Converter method testGMLToMultiPolygonType.

@Test
public void testGMLToMultiPolygonType() throws JAXBException, SAXException, IOException, ParseException, NullPointerException {
    String multiPolygonGML = Wfs10JTStoGML200Converter.convertGeometryToGML(getGeometryFromWkt(MULTIPOLYGON));
    MultiPolygonType multiPolygonType = (MultiPolygonType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(multiPolygonGML, Wfs10Constants.MULTI_POLYGON);
    multiPolygonType.getJAXBElementName();
    List<JAXBElement<? extends GeometryAssociationType>> geometryMembers = multiPolygonType.getGeometryMember();
    assertThat(geometryMembers.size() == 2, is(Boolean.TRUE));
    PolygonMemberType polygonMemberType1 = (PolygonMemberType) geometryMembers.get(0).getValue();
    String coords1 = extractPolygonMemberCoordinates(polygonMemberType1);
    assertThat(MULTIPOLYGON_COORDS1.equals(coords1), is(Boolean.TRUE));
    PolygonMemberType polygonMemberType2 = (PolygonMemberType) geometryMembers.get(0).getValue();
    String coords2 = extractPolygonMemberCoordinates(polygonMemberType2);
    assertThat(MULTIPOLYGON_COORDS2.equals(coords2), is(Boolean.TRUE));
}
Also used : PolygonMemberType(ogc.schema.opengis.gml.v_2_1_2.PolygonMemberType) GeometryAssociationType(ogc.schema.opengis.gml.v_2_1_2.GeometryAssociationType) MultiPolygonType(ogc.schema.opengis.gml.v_2_1_2.MultiPolygonType) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) JAXBElement(javax.xml.bind.JAXBElement) Test(org.junit.Test)

Example 3 with MultiPolygonType

use of net.opengis.gml.v_3_1_1.MultiPolygonType in project ddf by codice.

the class WfsFilterDelegateTest method testMultiPolygonLatLonOrder.

@Test
public void testMultiPolygonLatLonOrder() {
    final WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.INTERSECTS.getValue(), new LatLonCoordinateStrategy());
    final FilterType filter = delegate.intersects(Metacard.ANY_GEO, MULTIPOLYGON);
    assertThat(filter.getSpatialOps().getValue(), is(instanceOf(BinarySpatialOpType.class)));
    final BinarySpatialOpType binarySpatialOpType = (BinarySpatialOpType) filter.getSpatialOps().getValue();
    assertThat(binarySpatialOpType.getGeometry().getValue(), is(instanceOf(MultiPolygonType.class)));
    final MultiPolygonType multiPolygonType = (MultiPolygonType) binarySpatialOpType.getGeometry().getValue();
    assertThat(multiPolygonType.getPolygonMember().size(), is(2));
    final LinearRingType firstLinearRing = (LinearRingType) multiPolygonType.getPolygonMember().get(0).getPolygon().getExterior().getValue().getRing().getValue();
    assertThat(firstLinearRing.getCoordinates().getValue(), is("20.0,30.0 40.0,10.0 40.0,45.0 20.0,30.0"));
}
Also used : FilterType(net.opengis.filter.v_1_1_0.FilterType) LinearRingType(net.opengis.gml.v_3_1_1.LinearRingType) BinarySpatialOpType(net.opengis.filter.v_1_1_0.BinarySpatialOpType) MultiPolygonType(net.opengis.gml.v_3_1_1.MultiPolygonType) Test(org.junit.Test)

Example 4 with MultiPolygonType

use of net.opengis.gml.v_3_1_1.MultiPolygonType in project ddf by codice.

the class WfsFilterDelegate method createMultiPolygon.

private JAXBElement<MultiPolygonType> createMultiPolygon(Geometry geometry) {
    MultiPolygonType multiPolygon = new MultiPolygonType();
    if (geometry.getNumGeometries() > 0) {
        List<PolygonPropertyType> geometryMembers = multiPolygon.getPolygonMember();
        for (int i = 0; i < geometry.getNumGeometries(); i++) {
            Geometry currentGeo = geometry.getGeometryN(i);
            PolygonType currentPolygon = createPolygon(currentGeo.getCoordinates());
            PolygonPropertyType member = new PolygonPropertyType();
            member.setPolygon(currentPolygon);
            geometryMembers.add(member);
        }
        return gmlObjectFactory.createMultiPolygon(multiPolygon);
    } else {
        throw new IllegalArgumentException("Unable to parse Polygon coordinates from WKT String");
    }
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) PolygonPropertyType(net.opengis.gml.v_3_1_1.PolygonPropertyType) MultiPolygonType(net.opengis.gml.v_3_1_1.MultiPolygonType) PolygonType(net.opengis.gml.v_3_1_1.PolygonType) MultiPolygonType(net.opengis.gml.v_3_1_1.MultiPolygonType) Point(org.locationtech.jts.geom.Point)

Example 5 with MultiPolygonType

use of net.opengis.gml.v_3_1_1.MultiPolygonType in project ddf by codice.

the class WfsFilterDelegate method createMultiPolygon.

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

Aggregations

Test (org.junit.Test)4 LineString (com.vividsolutions.jts.geom.LineString)3 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)3 MultiPolygonType (net.opengis.gml.v_3_1_1.MultiPolygonType)3 MultiPolygonType (ogc.schema.opengis.gml.v_2_1_2.MultiPolygonType)3 JAXBElement (javax.xml.bind.JAXBElement)2 BinarySpatialOpType (net.opengis.filter.v_1_1_0.BinarySpatialOpType)2 FilterType (net.opengis.filter.v_1_1_0.FilterType)2 LinearRingType (net.opengis.gml.v_3_1_1.LinearRingType)2 JAXBException (javax.xml.bind.JAXBException)1 PolygonPropertyType (net.opengis.gml.v_3_1_1.PolygonPropertyType)1 PolygonType (net.opengis.gml.v_3_1_1.PolygonType)1 GeometryAssociationType (ogc.schema.opengis.gml.v_2_1_2.GeometryAssociationType)1 MultiLineStringType (ogc.schema.opengis.gml.v_2_1_2.MultiLineStringType)1 PolygonMemberType (ogc.schema.opengis.gml.v_2_1_2.PolygonMemberType)1 Diff (org.custommonkey.xmlunit.Diff)1 Geometry (org.locationtech.jts.geom.Geometry)1 Point (org.locationtech.jts.geom.Point)1