Search in sources :

Example 21 with PolygonType

use of org.geotoolkit.kml.xml.v220.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 22 with PolygonType

use of org.geotoolkit.kml.xml.v220.PolygonType in project ddf by codice.

the class TestWfs10JTStoGML200Converter method testGMLToPolygonType.

@Test
public void testGMLToPolygonType() throws JAXBException, SAXException, IOException, ParseException, NullPointerException {
    Polygon polygon = (Polygon) getGeometryFromWkt(POLYGON);
    assertThat(polygon == null, is(Boolean.FALSE));
    String polygonGML = Wfs10JTStoGML200Converter.convertGeometryToGML(polygon);
    PolygonType polygonType = (PolygonType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(polygonGML, Wfs10Constants.POLYGON);
    assertThat(null != polygonType, is(Boolean.TRUE));
    assertThat(polygonType.isSetInnerBoundaryIs(), is(Boolean.FALSE));
    assertThat(polygonType.isSetOuterBoundaryIs(), is(Boolean.TRUE));
    LinearRingMemberType linearRingMemberType = polygonType.getOuterBoundaryIs();
    JAXBElement<? extends AbstractGeometryType> geometry = linearRingMemberType.getGeometry();
    LinearRingType linearRingType = (LinearRingType) geometry.getValue();
    String coordinates = linearRingType.getCoordinates().getValue().replaceAll("\n", "").trim();
    assertThat(POLYGON_COORDS.equals(coordinates), is(Boolean.TRUE));
}
Also used : LinearRingType(ogc.schema.opengis.gml.v_2_1_2.LinearRingType) LinearRingMemberType(ogc.schema.opengis.gml.v_2_1_2.LinearRingMemberType) PolygonType(ogc.schema.opengis.gml.v_2_1_2.PolygonType) MultiPolygonType(ogc.schema.opengis.gml.v_2_1_2.MultiPolygonType) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) MultiPolygon(com.vividsolutions.jts.geom.MultiPolygon) Polygon(com.vividsolutions.jts.geom.Polygon) Test(org.junit.Test)

Example 23 with PolygonType

use of org.geotoolkit.kml.xml.v220.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)

Example 24 with PolygonType

use of org.geotoolkit.kml.xml.v220.PolygonType in project geo-platform by geosdi.

the class GMLPolygonParserTest method a_polygonJTSParserTest.

@Test
public void a_polygonJTSParserTest() throws Exception {
    PolygonType polygonType = GPJAXBContextBuilder.newInstance().unmarshal(new File(of(new File(".").getCanonicalPath(), "src", "test", "resources", "Polygon_2.xml").collect(joining(File.separator))), PolygonType.class);
    logger.info("##########################POLYGON_STRING_JTS : {}\n", polygonParser.parseGeometry(polygonType));
}
Also used : PolygonType(org.geosdi.geoplatform.xml.gml.v311.PolygonType) File(java.io.File) Test(org.junit.Test)

Example 25 with PolygonType

use of org.geotoolkit.kml.xml.v220.PolygonType in project geo-platform by geosdi.

the class GMLPolygonParserTest method b_polygonJTSParserTest.

@Test
public void b_polygonJTSParserTest() throws Exception {
    PolygonType polygonType = GPJAXBContextBuilder.newInstance().unmarshal(new File(of(new File(".").getCanonicalPath(), "src", "test", "resources", "Polygon_3.xml").collect(joining(File.separator))), PolygonType.class);
    logger.info("##########################POLYGON_STRING_JTS : {}\n", polygonParser.parseGeometry(polygonType));
}
Also used : PolygonType(org.geosdi.geoplatform.xml.gml.v311.PolygonType) File(java.io.File) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)18 ArrayList (java.util.ArrayList)11 Polygon (org.locationtech.jts.geom.Polygon)11 Geometry (org.locationtech.jts.geom.Geometry)8 PolygonType (net.opengis.gml.v_3_1_1.PolygonType)7 Coordinate (org.locationtech.jts.geom.Coordinate)7 LinearRing (org.locationtech.jts.geom.LinearRing)7 List (java.util.List)6 JAXBElement (javax.xml.bind.JAXBElement)6 LinearRingType (net.opengis.gml.v_3_1_1.LinearRingType)6 MultiPolygonType (net.opengis.gml.v_3_1_1.MultiPolygonType)6 PolygonType (net.opengis.gml._3.PolygonType)5 PolygonType (org.geosdi.geoplatform.xml.gml.v311.PolygonType)5 LineString (org.locationtech.jts.geom.LineString)5 File (java.io.File)4 MappingContext (ma.glasnost.orika.MappingContext)4 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 Point (org.locationtech.jts.geom.Point)4