Search in sources :

Example 16 with PolygonType

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

the class WfsFilterDelegate method createPolygon.

private PolygonType createPolygon(Coordinate[] coordinates) {
    if (coordinates != null && coordinates.length > 0) {
        PolygonType polygon = new PolygonType();
        LinearRingType linearRing = new LinearRingType();
        String coordinateString = coordinateStrategy.toString(coordinates);
        CoordinatesType coordinatesType = new CoordinatesType();
        coordinatesType.setValue(coordinateString);
        coordinatesType.setDecimal(".");
        coordinatesType.setCs(",");
        coordinatesType.setTs(" ");
        linearRing.setCoordinates(coordinatesType);
        AbstractRingPropertyType abstractRingPropertyType = gmlObjectFactory.createAbstractRingPropertyType();
        abstractRingPropertyType.setRing(gmlObjectFactory.createLinearRing(linearRing));
        polygon.setExterior(gmlObjectFactory.createExterior(abstractRingPropertyType));
        return polygon;
    } else {
        throw new IllegalArgumentException("Unable to parse Polygon coordinates from WKT String");
    }
}
Also used : LinearRingType(net.opengis.gml.v_3_1_1.LinearRingType) AbstractRingPropertyType(net.opengis.gml.v_3_1_1.AbstractRingPropertyType) PolygonType(net.opengis.gml.v_3_1_1.PolygonType) MultiPolygonType(net.opengis.gml.v_3_1_1.MultiPolygonType) LineString(org.locationtech.jts.geom.LineString) CoordinatesType(net.opengis.gml.v_3_1_1.CoordinatesType)

Example 17 with PolygonType

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

PolygonType (net.opengis.gml.v_3_1_1.PolygonType)7 LinearRingType (net.opengis.gml.v_3_1_1.LinearRingType)6 MultiPolygonType (net.opengis.gml.v_3_1_1.MultiPolygonType)6 Test (org.junit.Test)6 Point (org.locationtech.jts.geom.Point)5 BinarySpatialOpType (net.opengis.filter.v_1_1_0.BinarySpatialOpType)4 FilterType (net.opengis.filter.v_1_1_0.FilterType)4 PolygonType (net.opengis.gml.v_3_2_1.PolygonType)4 MultiPolygonType (ogc.schema.opengis.gml.v_2_1_2.MultiPolygonType)4 PolygonType (ogc.schema.opengis.gml.v_2_1_2.PolygonType)4 LineString (org.locationtech.jts.geom.LineString)4 MultiPoint (org.locationtech.jts.geom.MultiPoint)4 Polygon (org.locationtech.jts.geom.Polygon)4 LinearRingMemberType (ogc.schema.opengis.gml.v_2_1_2.LinearRingMemberType)3 LinearRingType (ogc.schema.opengis.gml.v_2_1_2.LinearRingType)3 Geometry (org.locationtech.jts.geom.Geometry)3 MultiLineString (org.locationtech.jts.geom.MultiLineString)3 LineString (com.vividsolutions.jts.geom.LineString)2 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)2 MultiPolygon (com.vividsolutions.jts.geom.MultiPolygon)2