Search in sources :

Example 6 with DistanceBufferType

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

the class TestWfsFilterDelegate method testLogicalNotOfSpatial.

@Test
public void testLogicalNotOfSpatial() throws Exception {
    String mockProperty = "myPropertyName";
    String mockType = "myType";
    WfsFilterDelegate delegate = mockFeatureMetacardCreateDelegate(mockProperty, mockType);
    FilterType spatialFilter1 = delegate.dwithin(Metacard.ANY_GEO, "POINT (30 10)", Double.valueOf(1000));
    //Perform Test
    FilterType filter = delegate.not(spatialFilter1);
    //Verify
    assertThat(filter.getLogicOps().getName().toString(), is(LOGICAL_NOT_NAME));
    UnaryLogicOpType logicOpType = (UnaryLogicOpType) filter.getLogicOps().getValue();
    DistanceBufferType spatialOpsType1 = (DistanceBufferType) logicOpType.getSpatialOps().getValue();
    assertThat(Double.toString(spatialOpsType1.getDistance().getValue()), is(Double.valueOf(1000).toString()));
}
Also used : UnaryLogicOpType(net.opengis.filter.v_2_0_0.UnaryLogicOpType) 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_1_1_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 8 with DistanceBufferType

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

the class TestWfsFilterDelegate method testLogicalAndOrSpatial.

private void testLogicalAndOrSpatial(String methName, String compOpName) throws Exception {
    String mockProperty = "myPropertyName";
    String mockType = "myType";
    WfsFilterDelegate delegate = mockFeatureMetacardCreateDelegate(mockProperty, mockType);
    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> filtersToCombine = new ArrayList<>();
    filtersToCombine.add(spatialFilter1);
    filtersToCombine.add(spatialFilter2);
    //Perform Test
    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();
    DistanceBufferType spatialOpsType1 = (DistanceBufferType) logicOpType.getComparisonOpsOrSpatialOpsOrTemporalOps().get(0).getValue();
    assertThat(Double.toString(spatialOpsType1.getDistance().getValue()), is(Double.valueOf(1000).toString()));
    DistanceBufferType spatialOpsType2 = (DistanceBufferType) logicOpType.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)

Example 9 with DistanceBufferType

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

the class TestWfsFilterDelegate method testBeyondAsNotDwithin.

@Test
public void testBeyondAsNotDwithin() {
    WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.DWithin.toString());
    FilterType filter = delegate.beyond(Metacard.ANY_GEO, POLYGON, DISTANCE);
    assertTrue(filter.getLogicOps().getValue() instanceof UnaryLogicOpType);
    UnaryLogicOpType type = (UnaryLogicOpType) filter.getLogicOps().getValue();
    assertTrue(type.getSpatialOps().getValue() instanceof DistanceBufferType);
}
Also used : UnaryLogicOpType(net.opengis.filter.v_2_0_0.UnaryLogicOpType) FilterType(net.opengis.filter.v_2_0_0.FilterType) DistanceBufferType(net.opengis.filter.v_2_0_0.DistanceBufferType) Test(org.junit.Test)

Example 10 with DistanceBufferType

use of net.opengis.filter.v_1_1_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)

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)4 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 QueryImpl (ddf.catalog.operation.impl.QueryImpl)1 JAXBElement (javax.xml.bind.JAXBElement)1 QName (javax.xml.namespace.QName)1 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)1 QueryConstraintType (net.opengis.cat.csw.v_2_0_2.QueryConstraintType)1 QueryType (net.opengis.cat.csw.v_2_0_2.QueryType)1 FilterType (net.opengis.filter.v_1_1_0.FilterType)1 BinaryTemporalOpType (net.opengis.filter.v_2_0_0.BinaryTemporalOpType)1 PropertyIsLikeType (net.opengis.filter.v_2_0_0.PropertyIsLikeType)1