Search in sources :

Example 11 with LinearRingType

use of org.geosdi.geoplatform.xml.gml.v311.LinearRingType 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 12 with LinearRingType

use of org.geosdi.geoplatform.xml.gml.v311.LinearRingType in project ddf by codice.

the class WfsFilterDelegate method createPolygon.

private JAXBElement<PolygonType> createPolygon(Geometry geometry) {
    PolygonType polygonType = gml320ObjectFactory.createPolygonType();
    polygonType.setSrsName(GeospatialUtil.EPSG_4326_URN);
    LinearRingType ring = gml320ObjectFactory.createLinearRingType();
    ring.setCoordinates(createCoordinates(geometry));
    AbstractRingPropertyType abstractRing = gml320ObjectFactory.createAbstractRingPropertyType();
    abstractRing.setAbstractRing(gml320ObjectFactory.createLinearRing(ring));
    polygonType.setExterior(abstractRing);
    return gml320ObjectFactory.createPolygon(polygonType);
}
Also used : LinearRingType(net.opengis.gml.v_3_2_1.LinearRingType) AbstractRingPropertyType(net.opengis.gml.v_3_2_1.AbstractRingPropertyType) PolygonType(net.opengis.gml.v_3_2_1.PolygonType)

Example 13 with LinearRingType

use of org.geosdi.geoplatform.xml.gml.v311.LinearRingType in project ddf by codice.

the class CswJTSToGML311LinearRingConverter method doCreateGeometryType.

/**
 * @see {@code JTSToGML311LinearRingConverter#doCreateGeometryType}
 */
@Override
protected LinearRingType doCreateGeometryType(LinearRing linearRing) {
    final LinearRingType resultLinearRing;
    if (usePosList) {
        resultLinearRing = getObjectFactory().createLinearRingType();
        List<Double> posDoubleList = new ArrayList<Double>();
        for (Coordinate coordinate : linearRing.getCoordinates()) {
            posDoubleList.add(coordinate.x);
            posDoubleList.add(coordinate.y);
        }
        DirectPositionListType directPosListType = new DirectPositionListType();
        directPosListType.setValue(posDoubleList);
        resultLinearRing.setPosList(directPosListType);
    } else {
        resultLinearRing = super.doCreateGeometryType(linearRing);
    }
    return resultLinearRing;
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) LinearRingType(net.opengis.gml.v_3_1_1.LinearRingType) ArrayList(java.util.ArrayList) DirectPositionListType(net.opengis.gml.v_3_1_1.DirectPositionListType)

Example 14 with LinearRingType

use of org.geosdi.geoplatform.xml.gml.v311.LinearRingType in project ddf by codice.

the class WfsFilterDelegateTest method testMultiPolygonLonLatOrder.

@Test
public void testMultiPolygonLonLatOrder() {
    final WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.INTERSECTS.getValue(), new LonLatCoordinateStrategy());
    final FilterType filter = delegate.intersects(Metacard.ANY_GEO, MULTIPOLYGON);
    assertThat(filter.getSpatialOps().getValue(), is(instanceOf(BinarySpatialOpType.class)));
    final BinarySpatialOpType binarySpatialOpType = (BinarySpatialOpType) filter.getSpatialOps().getValue();
    assertThat(binarySpatialOpType.getGeometry().getValue(), is(instanceOf(MultiPolygonType.class)));
    final MultiPolygonType multiPolygonType = (MultiPolygonType) binarySpatialOpType.getGeometry().getValue();
    assertThat(multiPolygonType.getPolygonMember().size(), is(2));
    final LinearRingType firstLinearRing = (LinearRingType) multiPolygonType.getPolygonMember().get(0).getPolygon().getExterior().getValue().getRing().getValue();
    assertThat(firstLinearRing.getCoordinates().getValue(), is("30.0,20.0 10.0,40.0 45.0,40.0 30.0,20.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) MultiPolygonType(net.opengis.gml.v_3_1_1.MultiPolygonType) Test(org.junit.Test)

Example 15 with LinearRingType

use of org.geosdi.geoplatform.xml.gml.v311.LinearRingType 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)

Aggregations

Test (org.junit.Test)13 LinearRingType (net.opengis.gml.v_3_1_1.LinearRingType)9 ArrayList (java.util.ArrayList)7 MultiPolygonType (net.opengis.gml.v_3_1_1.MultiPolygonType)7 BinarySpatialOpType (net.opengis.filter.v_1_1_0.BinarySpatialOpType)6 FilterType (net.opengis.filter.v_1_1_0.FilterType)6 PolygonType (net.opengis.gml.v_3_1_1.PolygonType)6 Coordinate (org.locationtech.jts.geom.Coordinate)6 Polygon (org.locationtech.jts.geom.Polygon)5 AbstractRingPropertyType (net.opengis.gml._3.AbstractRingPropertyType)3 DirectPositionListType (net.opengis.gml._3.DirectPositionListType)3 LinearRingType (net.opengis.gml._3.LinearRingType)3 PolygonType (net.opengis.gml._3.PolygonType)3 LinearRingMemberType (ogc.schema.opengis.gml.v_2_1_2.LinearRingMemberType)3 LinearRingType (ogc.schema.opengis.gml.v_2_1_2.LinearRingType)3 MultiPolygonType (ogc.schema.opengis.gml.v_2_1_2.MultiPolygonType)3 PolygonType (ogc.schema.opengis.gml.v_2_1_2.PolygonType)3 Geometry (org.locationtech.jts.geom.Geometry)3 LinearRing (org.locationtech.jts.geom.LinearRing)3 HashMap (java.util.HashMap)2