Search in sources :

Example 21 with PolygonType

use of org.geotoolkit.gml.xml.v321.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)

Example 22 with PolygonType

use of org.geotoolkit.gml.xml.v321.PolygonType in project geo-platform by geosdi.

the class GMLPolygonParserTest method c_polygonJTSParserTest.

@Test
public void c_polygonJTSParserTest() throws Exception {
    PolygonType polygonType = GPJAXBContextBuilder.newInstance().unmarshal(new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<gml:Polygon xmlns:gml=\"http://www.opengis.net/gml\" srsName=\"SDO:\">\n" + "   <gml:exterior>\n" + "      <gml:LinearRing>\n" + "         <gml:posList srsDimension=\"2\">5.0 1.0 8.0 1.0 8.0 6.0 5.0 7.0 5.0 1.0</gml:posList>\n" + "      </gml:LinearRing>\n" + "   </gml:exterior>\n" + "</gml:Polygon>"), PolygonType.class);
    logger.info("##########################POLYGON_STRING_JTS : {}\n", polygonParser.parseGeometry(polygonType));
}
Also used : StringReader(java.io.StringReader) PolygonType(org.geosdi.geoplatform.xml.gml.v311.PolygonType) Test(org.junit.Test)

Example 23 with PolygonType

use of org.geotoolkit.gml.xml.v321.PolygonType in project ddf by codice.

the class WfsFilterDelegateTest method testMultiPolygonWithSinglePolygonSupportsOnlyPolygon.

@Test
public void testMultiPolygonWithSinglePolygonSupportsOnlyPolygon() {
    final String MULTIPOLYGON_SINGLE_POLYGON = "MULTIPOLYGON (((30 20, 10 40, 45 40, 30 20)))";
    final WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.INTERSECTS.getValue(), new LatLonCoordinateStrategy());
    delegate.setSupportedGeometryOperands(singletonList(Wfs11Constants.POLYGON));
    final FilterType filter = delegate.intersects(Metacard.ANY_GEO, MULTIPOLYGON_SINGLE_POLYGON);
    assertThat(filter.getSpatialOps().getValue(), is(instanceOf(BinarySpatialOpType.class)));
    final BinarySpatialOpType binarySpatialOpType = (BinarySpatialOpType) filter.getSpatialOps().getValue();
    assertThat(binarySpatialOpType.getGeometry().getValue(), is(instanceOf(PolygonType.class)));
    final PolygonType polygonType = (PolygonType) binarySpatialOpType.getGeometry().getValue();
    assertThat(polygonType.getExterior().getValue().getRing().getValue(), is(instanceOf(LinearRingType.class)));
    final LinearRingType linearRingType = (LinearRingType) polygonType.getExterior().getValue().getRing().getValue();
    assertThat(linearRingType.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) PolygonType(net.opengis.gml.v_3_1_1.PolygonType) MultiPolygonType(net.opengis.gml.v_3_1_1.MultiPolygonType) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) Test(org.junit.Test)

Example 24 with PolygonType

use of org.geotoolkit.gml.xml.v321.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 25 with PolygonType

use of org.geotoolkit.gml.xml.v321.PolygonType in project ddf by codice.

the class Wfs20JTStoGML321Converter method convertToMultiSurfaceType.

/**
 * Converts a @link org.locationtech.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) Polygon(org.locationtech.jts.geom.Polygon) MultiPolygon(org.locationtech.jts.geom.MultiPolygon) Point(org.locationtech.jts.geom.Point) MultiPoint(org.locationtech.jts.geom.MultiPoint)

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