Search in sources :

Example 1 with MultiPointType

use of net.opengis.gml.v_3_2_1.MultiPointType in project ddf by codice.

the class Wfs20JTStoGML321Converter method createGeometryPropertyType.

private static GeometryPropertyType createGeometryPropertyType(Geometry geometry, String srsName) {
    final GeometryPropertyType geometryPropertyType = GML320_OBJECT_FACTORY.createGeometryPropertyType();
    if (geometry instanceof Point) {
        PointType pointType = convertToPointType((Point) geometry, srsName);
        geometryPropertyType.setAbstractGeometry(convertPointTypeToJAXB(pointType));
    } else if (geometry instanceof LineString) {
        LineStringType lineStringType = convertToLineStringType((LineString) geometry, srsName);
        geometryPropertyType.setAbstractGeometry(convertLineStringTypeToJAXB(lineStringType));
    } else if (geometry instanceof Polygon) {
        PolygonType polygonType = convertToPolygonType((Polygon) geometry, srsName);
        geometryPropertyType.setAbstractGeometry(convertPolygonTypeToJAXB(polygonType));
    } else if (geometry instanceof MultiPoint) {
        MultiPointType multiPointType = convertToMultiPointType((MultiPoint) geometry, srsName);
        geometryPropertyType.setAbstractGeometry(convertMultiPointTypeToJAXB(multiPointType));
    } else if (geometry instanceof MultiLineString) {
        MultiCurveType multiCurveType = convertToMultiLineStringType((MultiLineString) geometry, srsName);
        geometryPropertyType.setAbstractGeometry(convertMultiCurveTypeToJAXB(multiCurveType));
    } else if (geometry instanceof MultiPolygon) {
        MultiSurfaceType multiSurfaceType = convertToMultiSurfaceType((MultiPolygon) geometry, srsName);
        geometryPropertyType.setAbstractGeometry(convertMultiSurfaceTypeToJAXB(multiSurfaceType));
    } else if (geometry instanceof GeometryCollection) {
        MultiGeometryType multiGeometryType = convertToMultiGeometryType((GeometryCollection) geometry, srsName);
        geometryPropertyType.setAbstractGeometry(convertMultiGeometryTypeToJAXB(multiGeometryType));
    } else {
        throw new IllegalArgumentException();
    }
    return geometryPropertyType;
}
Also used : MultiPoint(com.vividsolutions.jts.geom.MultiPoint) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) MultiCurveType(net.opengis.gml.v_3_2_1.MultiCurveType) MultiGeometryType(net.opengis.gml.v_3_2_1.MultiGeometryType) PolygonType(net.opengis.gml.v_3_2_1.PolygonType) Point(com.vividsolutions.jts.geom.Point) MultiPoint(com.vividsolutions.jts.geom.MultiPoint) LineStringType(net.opengis.gml.v_3_2_1.LineStringType) MultiPointType(net.opengis.gml.v_3_2_1.MultiPointType) GeometryCollection(com.vividsolutions.jts.geom.GeometryCollection) MultiSurfaceType(net.opengis.gml.v_3_2_1.MultiSurfaceType) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) MultiPolygon(com.vividsolutions.jts.geom.MultiPolygon) PointType(net.opengis.gml.v_3_2_1.PointType) MultiPointType(net.opengis.gml.v_3_2_1.MultiPointType) MultiPolygon(com.vividsolutions.jts.geom.MultiPolygon) Polygon(com.vividsolutions.jts.geom.Polygon) GeometryPropertyType(net.opengis.gml.v_3_2_1.GeometryPropertyType)

Example 2 with MultiPointType

use of net.opengis.gml.v_3_2_1.MultiPointType in project ddf by codice.

the class WfsFilterDelegate method createMultiPoint.

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

Example 3 with MultiPointType

use of net.opengis.gml.v_3_2_1.MultiPointType in project ddf by codice.

the class Wfs20JTStoGML321Converter method convertToMultiPointType.

public static MultiPointType convertToMultiPointType(MultiPoint multiPoint, String srsName) {
    MultiPointType multiPointType = GML320_OBJECT_FACTORY.createMultiPointType();
    for (int i = 0; i < multiPoint.getNumGeometries(); i++) {
        Point point = (Point) multiPoint.getGeometryN(i);
        PointPropertyType pointPropertyType = GML320_OBJECT_FACTORY.createPointPropertyType();
        pointPropertyType.setPoint(convertToPointType(point, srsName));
        multiPointType.getPointMember().add(pointPropertyType);
    }
    multiPointType.setSrsName(srsName);
    return multiPointType;
}
Also used : Point(com.vividsolutions.jts.geom.Point) MultiPoint(com.vividsolutions.jts.geom.MultiPoint) PointPropertyType(net.opengis.gml.v_3_2_1.PointPropertyType) MultiPointType(net.opengis.gml.v_3_2_1.MultiPointType) Point(com.vividsolutions.jts.geom.Point) MultiPoint(com.vividsolutions.jts.geom.MultiPoint)

Example 4 with MultiPointType

use of net.opengis.gml.v_3_2_1.MultiPointType in project ddf by codice.

the class TestWfs10JTStoGML200Converter method testGMLToMultiPointType.

@Test
public void testGMLToMultiPointType() throws JAXBException, SAXException, IOException, ParseException, NullPointerException {
    String multiPointGML = Wfs10JTStoGML200Converter.convertGeometryToGML(getGeometryFromWkt(MULTIPOINT));
    MultiPointType multiPointType = (MultiPointType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(multiPointGML, Wfs10Constants.MULTI_POINT);
    List<JAXBElement<? extends GeometryAssociationType>> geoMembers = multiPointType.getGeometryMember();
    assertThat(geoMembers.isEmpty(), is(Boolean.FALSE));
    assertThat(Wfs10Constants.MULTI_POINT.getLocalPart().equals(multiPointType.getJAXBElementName().getLocalPart()), is(Boolean.TRUE));
    assertThat(geoMembers.size() == 4, is(Boolean.TRUE));
    String coords1 = extractPointMemberTypeCoordinates(geoMembers.get(0));
    assertThat(MULTIPOINT_COORDS1.equals(coords1), is(Boolean.TRUE));
    String coords2 = extractPointMemberTypeCoordinates(geoMembers.get(1));
    assertThat(MULTIPOINT_COORDS2.equals(coords2), is(Boolean.TRUE));
    String coords3 = extractPointMemberTypeCoordinates(geoMembers.get(2));
    assertThat(MULTIPOINT_COORDS3.equals(coords3), is(Boolean.TRUE));
    String coords4 = extractPointMemberTypeCoordinates(geoMembers.get(3));
    assertThat(MULTIPOINT_COORDS4.equals(coords4), is(Boolean.TRUE));
}
Also used : GeometryAssociationType(ogc.schema.opengis.gml.v_2_1_2.GeometryAssociationType) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) JAXBElement(javax.xml.bind.JAXBElement) MultiPointType(ogc.schema.opengis.gml.v_2_1_2.MultiPointType) Test(org.junit.Test)

Example 5 with MultiPointType

use of net.opengis.gml.v_3_2_1.MultiPointType in project ddf by codice.

the class TestWfs10JTStoGML200Converter method testMultiPointTypeToJAXB.

@Test
public void testMultiPointTypeToJAXB() throws JAXBException, SAXException, IOException, ParseException, NullPointerException {
    String multiPointGML = Wfs10JTStoGML200Converter.convertGeometryToGML(getGeometryFromWkt(MULTIPOINT));
    MultiPointType multiPointType = (MultiPointType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(multiPointGML, Wfs10Constants.MULTI_POINT);
    JAXBElement<MultiPointType> multiPointTypeJAXBElement = (JAXBElement<MultiPointType>) Wfs10JTStoGML200Converter.convertGeometryTypeToJAXB(multiPointType);
    JAXB.marshal(multiPointTypeJAXBElement, writer);
    String xml = writer.toString();
    Diff diff = XMLUnit.compareXML(xml, MULTIPOINT_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) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) JAXBElement(javax.xml.bind.JAXBElement) MultiPointType(ogc.schema.opengis.gml.v_2_1_2.MultiPointType) Test(org.junit.Test)

Aggregations

LineString (com.vividsolutions.jts.geom.LineString)4 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)4 MultiPointType (ogc.schema.opengis.gml.v_2_1_2.MultiPointType)3 MultiPoint (com.vividsolutions.jts.geom.MultiPoint)2 Point (com.vividsolutions.jts.geom.Point)2 JAXBElement (javax.xml.bind.JAXBElement)2 MultiPointType (net.opengis.gml.v_3_2_1.MultiPointType)2 Test (org.junit.Test)2 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 GeometryPropertyType (net.opengis.gml.v_3_2_1.GeometryPropertyType)1 LineStringType (net.opengis.gml.v_3_2_1.LineStringType)1 MultiCurveType (net.opengis.gml.v_3_2_1.MultiCurveType)1 MultiGeometryType (net.opengis.gml.v_3_2_1.MultiGeometryType)1 MultiSurfaceType (net.opengis.gml.v_3_2_1.MultiSurfaceType)1 PointPropertyType (net.opengis.gml.v_3_2_1.PointPropertyType)1 PointType (net.opengis.gml.v_3_2_1.PointType)1 PolygonType (net.opengis.gml.v_3_2_1.PolygonType)1