Search in sources :

Example 1 with SurfacePropertyType

use of net.opengis.gml.x32.SurfacePropertyType in project ddf by codice.

the class Wfs20JTStoGML321Converter method convertToMultiSurfaceType.

/**
     * Converts a @link com.vividsolutions.jts.geom.MultiPolygon to a @link net.opengis.gml.v_3_2_1.MultiSurfaceType
     * Note:  MultiPolygon maps to gml MultiSurfaceType
     *
     * @param multiPolygon
     * @return MultiSurfaceType
     */
public static MultiSurfaceType convertToMultiSurfaceType(MultiPolygon multiPolygon, String srsName) {
    MultiSurfaceType multiSurfaceType = GML320_OBJECT_FACTORY.createMultiSurfaceType();
    for (int i = 0; i < multiPolygon.getNumGeometries(); i++) {
        Polygon poly = (Polygon) multiPolygon.getGeometryN(i);
        PolygonType polygonType = convertToPolygonType(poly, srsName);
        JAXBElement<PolygonType> polygonTypeJAXBElement = GML320_OBJECT_FACTORY.createPolygon(polygonType);
        SurfacePropertyType surfacePropertyType = GML320_OBJECT_FACTORY.createSurfacePropertyType();
        surfacePropertyType.setAbstractSurface(polygonTypeJAXBElement);
        multiSurfaceType.getSurfaceMember().add(surfacePropertyType);
    }
    multiSurfaceType.setSrsName(srsName);
    return multiSurfaceType;
}
Also used : MultiSurfaceType(net.opengis.gml.v_3_2_1.MultiSurfaceType) SurfacePropertyType(net.opengis.gml.v_3_2_1.SurfacePropertyType) PolygonType(net.opengis.gml.v_3_2_1.PolygonType) MultiPolygon(com.vividsolutions.jts.geom.MultiPolygon) Polygon(com.vividsolutions.jts.geom.Polygon) Point(com.vividsolutions.jts.geom.Point) MultiPoint(com.vividsolutions.jts.geom.MultiPoint)

Example 2 with SurfacePropertyType

use of net.opengis.gml.x32.SurfacePropertyType in project arctic-sea by 52North.

the class GmlDecoderv321 method parseCompositeSurfaceType.

private Geometry parseCompositeSurfaceType(CompositeSurfaceType xbCompositeSurface) throws DecodingException {
    SurfacePropertyType[] xbCurfaceProperties = xbCompositeSurface.getSurfaceMemberArray();
    int srid = -1;
    ArrayList<Polygon> polygons = new ArrayList<>(xbCurfaceProperties.length);
    if (xbCompositeSurface.getSrsName() != null) {
        srid = CRSHelper.parseSrsName(xbCompositeSurface.getSrsName());
    }
    for (SurfacePropertyType xbSurfaceProperty : xbCurfaceProperties) {
        AbstractSurfaceType xbAbstractSurface = xbSurfaceProperty.getAbstractSurface();
        if (srid == -1 && xbAbstractSurface.getSrsName() != null) {
            srid = CRSHelper.parseSrsName(xbAbstractSurface.getSrsName());
        }
        if (xbAbstractSurface instanceof PolygonType) {
            polygons.add((Polygon) parsePolygonType((PolygonType) xbAbstractSurface));
        } else {
            throw new DecodingException("The FeatureType %s is not supportted! Only PolygonType", xbAbstractSurface);
        }
    }
    if (polygons.isEmpty()) {
        throw new DecodingException("The FeatureType: %s does not contain any member!", xbCompositeSurface);
    }
    srid = setDefaultForUnsetSrid(srid);
    GeometryFactory factory = new GeometryFactory();
    Geometry geom = factory.createMultiPolygon(polygons.toArray(new Polygon[polygons.size()]));
    geom.setSRID(srid);
    return geom;
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) AbstractGeometry(org.n52.shetland.ogc.gml.AbstractGeometry) AbstractSurfaceType(net.opengis.gml.x32.AbstractSurfaceType) GeometryFactory(org.locationtech.jts.geom.GeometryFactory) SurfacePropertyType(net.opengis.gml.x32.SurfacePropertyType) ArrayList(java.util.ArrayList) PolygonType(net.opengis.gml.x32.PolygonType) DecodingException(org.n52.svalbard.decode.exception.DecodingException) Polygon(org.locationtech.jts.geom.Polygon)

Aggregations

MultiPoint (com.vividsolutions.jts.geom.MultiPoint)1 MultiPolygon (com.vividsolutions.jts.geom.MultiPolygon)1 Point (com.vividsolutions.jts.geom.Point)1 Polygon (com.vividsolutions.jts.geom.Polygon)1 ArrayList (java.util.ArrayList)1 MultiSurfaceType (net.opengis.gml.v_3_2_1.MultiSurfaceType)1 PolygonType (net.opengis.gml.v_3_2_1.PolygonType)1 SurfacePropertyType (net.opengis.gml.v_3_2_1.SurfacePropertyType)1 AbstractSurfaceType (net.opengis.gml.x32.AbstractSurfaceType)1 PolygonType (net.opengis.gml.x32.PolygonType)1 SurfacePropertyType (net.opengis.gml.x32.SurfacePropertyType)1 Geometry (org.locationtech.jts.geom.Geometry)1 GeometryFactory (org.locationtech.jts.geom.GeometryFactory)1 Polygon (org.locationtech.jts.geom.Polygon)1 AbstractGeometry (org.n52.shetland.ogc.gml.AbstractGeometry)1 DecodingException (org.n52.svalbard.decode.exception.DecodingException)1