Search in sources :

Example 6 with DistanceBufferType

use of net.opengis.filter.v_2_0_0.DistanceBufferType in project ddf by codice.

the class TestWfsFilterDelegate method testDWithinFilterPolygon.

@Test
public void testDWithinFilterPolygon() throws SAXException, IOException, JAXBException {
    WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.DWithin.toString());
    FilterType filter = delegate.dwithin(Metacard.ANY_GEO, POLYGON, DISTANCE);
    assertFalse(filter.isSetLogicOps());
    assertTrue(filter.isSetSpatialOps());
    assertTrue(filter.getSpatialOps().getValue() instanceof DistanceBufferType);
    assertXMLEqual(MockWfsServer.getDWithinXmlFilter(), getXmlFromMarshaller(filter));
}
Also used : FilterType(net.opengis.filter.v_2_0_0.FilterType) DistanceBufferType(net.opengis.filter.v_2_0_0.DistanceBufferType) Test(org.junit.Test)

Example 7 with DistanceBufferType

use of net.opengis.filter.v_2_0_0.DistanceBufferType in project ddf by codice.

the class CswFilterFactory method createDistanceBufferType.

@SuppressWarnings("unchecked")
private DistanceBufferType createDistanceBufferType(PropertyNameType propertyName, JAXBElement<? extends AbstractGeometryType> geometry, DistanceType distance) {
    DistanceBufferType distanceBuffer = new DistanceBufferType();
    distanceBuffer.setDistance(distance);
    distanceBuffer.setGeometry((JAXBElement<AbstractGeometryType>) geometry);
    distanceBuffer.setPropertyName(propertyName);
    return distanceBuffer;
}
Also used : AbstractGeometryType(net.opengis.gml.v_3_1_1.AbstractGeometryType) DistanceBufferType(net.opengis.filter.v_1_1_0.DistanceBufferType)

Example 8 with DistanceBufferType

use of net.opengis.filter.v_2_0_0.DistanceBufferType in project ddf by codice.

the class CswFilterFactory method createBeyondType.

private JAXBElement<DistanceBufferType> createBeyondType(String propertyName, String wkt, double distance) {
    wkt = convertWktToLatLonOrdering(wkt);
    Geometry geometry = getGeometryFromWkt(wkt);
    JAXBElement<? extends AbstractGeometryType> geometryJaxbElement = convertGeometry(geometry);
    PropertyNameType propertyNameType = createPropertyNameType(propertyName);
    DistanceType distanceType = createDistanceType(distance, CswConstants.METERS);
    DistanceBufferType distanceBufferType = createDistanceBufferType(propertyNameType, geometryJaxbElement, distanceType);
    return filterObjectFactory.createBeyond(distanceBufferType);
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) DistanceType(net.opengis.filter.v_1_1_0.DistanceType) DistanceBufferType(net.opengis.filter.v_1_1_0.DistanceBufferType) PropertyNameType(net.opengis.filter.v_1_1_0.PropertyNameType)

Example 9 with DistanceBufferType

use of net.opengis.filter.v_2_0_0.DistanceBufferType in project ddf by codice.

the class CswFilterFactory method createDWithinType.

private JAXBElement<DistanceBufferType> createDWithinType(String propertyName, String wkt, double distance) {
    wkt = convertWktToLatLonOrdering(wkt);
    Geometry geometry = getGeometryFromWkt(wkt);
    JAXBElement<? extends AbstractGeometryType> geometryJaxbElement = convertGeometry(geometry);
    PropertyNameType propertyNameType = createPropertyNameType(propertyName);
    DistanceType distanceType = createDistanceType(distance, CswConstants.METERS);
    DistanceBufferType distanceBufferType = createDistanceBufferType(propertyNameType, geometryJaxbElement, distanceType);
    return filterObjectFactory.createDWithin(distanceBufferType);
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) DistanceType(net.opengis.filter.v_1_1_0.DistanceType) DistanceBufferType(net.opengis.filter.v_1_1_0.DistanceBufferType) PropertyNameType(net.opengis.filter.v_1_1_0.PropertyNameType)

Example 10 with DistanceBufferType

use of net.opengis.filter.v_2_0_0.DistanceBufferType in project ddf by codice.

the class TestWfsFilterDelegate method testLogicalCombinationOfLogicals.

private void testLogicalCombinationOfLogicals(String methName, String compOpName) throws Exception {
    String mockProperty = "myPropertyName";
    String mockType = "myType";
    WfsFilterDelegate delegate = mockFeatureMetacardCreateDelegate(mockProperty, mockType);
    FilterType compFilter1 = delegate.propertyIsLike(Metacard.ANY_TEXT, LITERAL, true);
    FilterType compFilter2 = delegate.propertyIsLike(Metacard.ANY_TEXT, LITERAL, true);
    List<FilterType> subFiltersToBeOred = new ArrayList<>();
    subFiltersToBeOred.add(compFilter1);
    subFiltersToBeOred.add(compFilter2);
    FilterType spatialFilter1 = delegate.dwithin(Metacard.ANY_GEO, "POINT (30 10)", Double.valueOf(1000));
    FilterType spatialFilter2 = delegate.dwithin(Metacard.ANY_GEO, "POINT (50 10)", Double.valueOf(1500));
    List<FilterType> subFiltersToBeAnded = new ArrayList<>();
    subFiltersToBeAnded.add(spatialFilter1);
    subFiltersToBeAnded.add(spatialFilter2);
    List<FilterType> filtersToCombine = new ArrayList<>();
    filtersToCombine.add(delegate.or(subFiltersToBeOred));
    filtersToCombine.add(delegate.and(subFiltersToBeAnded));
    Method method = WfsFilterDelegate.class.getMethod(methName, List.class);
    FilterType filter = (FilterType) method.invoke(delegate, filtersToCombine);
    //Verify
    assertThat(filter.getLogicOps().getName().toString(), is(compOpName));
    BinaryLogicOpType logicOpType = (BinaryLogicOpType) filter.getLogicOps().getValue();
    BinaryLogicOpType logicOrType = (BinaryLogicOpType) logicOpType.getComparisonOpsOrSpatialOpsOrTemporalOps().get(0).getValue();
    assertThat(logicOpType.getComparisonOpsOrSpatialOpsOrTemporalOps().get(0).getName().toString(), is(LOGICAL_OR_NAME));
    assertThat(logicOrType.getComparisonOpsOrSpatialOpsOrTemporalOps().size(), is(2));
    for (JAXBElement<?> jaxbElement : logicOrType.getComparisonOpsOrSpatialOpsOrTemporalOps()) {
        PropertyIsLikeType compOpsType = (PropertyIsLikeType) jaxbElement.getValue();
        String valRef = fetchPropertyIsLikeExpression(compOpsType, VALUE_REFERENCE);
        assertThat(valRef, is(mockProperty));
        String literal = fetchPropertyIsLikeExpression(compOpsType, LITERAL);
        assertThat(literal, is(LITERAL));
    }
    BinaryLogicOpType logicAndType = (BinaryLogicOpType) logicOpType.getComparisonOpsOrSpatialOpsOrTemporalOps().get(1).getValue();
    assertThat(logicOpType.getComparisonOpsOrSpatialOpsOrTemporalOps().get(1).getName().toString(), is(LOGICAL_AND_NAME));
    DistanceBufferType spatialOpsType1 = (DistanceBufferType) logicAndType.getComparisonOpsOrSpatialOpsOrTemporalOps().get(0).getValue();
    assertThat(Double.toString(spatialOpsType1.getDistance().getValue()), is(Double.valueOf(1000).toString()));
    DistanceBufferType spatialOpsType2 = (DistanceBufferType) logicAndType.getComparisonOpsOrSpatialOpsOrTemporalOps().get(1).getValue();
    assertThat(Double.toString(spatialOpsType2.getDistance().getValue()), is(Double.valueOf(1500).toString()));
}
Also used : FilterType(net.opengis.filter.v_2_0_0.FilterType) BinaryLogicOpType(net.opengis.filter.v_2_0_0.BinaryLogicOpType) ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method) DistanceBufferType(net.opengis.filter.v_2_0_0.DistanceBufferType) PropertyIsLikeType(net.opengis.filter.v_2_0_0.PropertyIsLikeType)

Aggregations

DistanceBufferType (net.opengis.filter.v_2_0_0.DistanceBufferType)9 FilterType (net.opengis.filter.v_2_0_0.FilterType)9 Test (org.junit.Test)9 DistanceBufferType (net.opengis.filter.v_1_1_0.DistanceBufferType)6 ArrayList (java.util.ArrayList)3 DistanceType (net.opengis.filter.v_1_1_0.DistanceType)3 PropertyNameType (net.opengis.filter.v_1_1_0.PropertyNameType)3 BinaryLogicOpType (net.opengis.filter.v_2_0_0.BinaryLogicOpType)3 UnaryLogicOpType (net.opengis.filter.v_2_0_0.UnaryLogicOpType)3 Geometry (com.vividsolutions.jts.geom.Geometry)2 Method (java.lang.reflect.Method)2 BinaryTemporalOpType (net.opengis.filter.v_2_0_0.BinaryTemporalOpType)1 MeasureType (net.opengis.filter.v_2_0_0.MeasureType)1 PropertyIsLikeType (net.opengis.filter.v_2_0_0.PropertyIsLikeType)1 AbstractGeometryType (net.opengis.gml.v_3_1_1.AbstractGeometryType)1 DateTime (org.joda.time.DateTime)1