use of net.opengis.filter.v_2_0_0.DistanceBufferType in project ddf by codice.
the class TestWfsFilterDelegate method testLogicalAndOfSpatialTemporal.
/**
* Verifies that a temporal criteria can be AND'ed to other criteria.
*
* @throws Exception
*/
@Test
public void testLogicalAndOfSpatialTemporal() throws Exception {
String mockProperty = "myPropertyName";
String mockType = "myType";
WfsFilterDelegate delegate = mockFeatureMetacardCreateDelegate(mockProperty, mockType);
FilterType spatialFilter = delegate.dwithin(Metacard.ANY_GEO, "POINT (30 10)", Double.valueOf(1000));
FilterType temporalFilter = delegate.during(mockProperty, new DateTime().minusDays(365).toDate(), new DateTime().minusDays(10).toDate());
List<FilterType> filtersToBeAnded = new ArrayList<>(Arrays.asList(spatialFilter, temporalFilter));
//Perform Test
FilterType filter = delegate.and(filtersToBeAnded);
//Verify AND op used
if (filter.getLogicOps() == null) {
fail("No AND/OR element found in the generated FilterType.");
}
assertEquals(LOGICAL_AND_NAME, filter.getLogicOps().getName().toString());
BinaryLogicOpType logicOpType = (BinaryLogicOpType) filter.getLogicOps().getValue();
//Verify two items were AND'ed
assertEquals(2, logicOpType.getComparisonOpsOrSpatialOpsOrTemporalOps().size());
//Verify first is spatial, second is temporal
assertTrue(logicOpType.getComparisonOpsOrSpatialOpsOrTemporalOps().get(0).getValue() instanceof DistanceBufferType);
assertTrue(logicOpType.getComparisonOpsOrSpatialOpsOrTemporalOps().get(1).getValue() instanceof BinaryTemporalOpType);
}
use of net.opengis.filter.v_2_0_0.DistanceBufferType in project ddf by codice.
the class TestWfsFilterDelegate method testDwithinAsNotBeyond.
@Test
public void testDwithinAsNotBeyond() {
WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.Beyond.toString());
FilterType filter = delegate.dwithin(Metacard.ANY_GEO, POLYGON, DISTANCE);
assertTrue(filter.getLogicOps().getValue() instanceof UnaryLogicOpType);
UnaryLogicOpType type = (UnaryLogicOpType) filter.getLogicOps().getValue();
assertTrue(type.getSpatialOps().getValue() instanceof DistanceBufferType);
}
use of net.opengis.filter.v_2_0_0.DistanceBufferType in project ddf by codice.
the class TestWfsFilterDelegate method testDWithinFilterPoint.
@Test
public void testDWithinFilterPoint() throws SAXException, IOException, JAXBException {
WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.DWithin.toString());
FilterType filter = delegate.dwithin(Metacard.ANY_GEO, POINT, DISTANCE);
assertFalse(filter.isSetLogicOps());
assertTrue(filter.isSetSpatialOps());
assertTrue(filter.getSpatialOps().getValue() instanceof DistanceBufferType);
assertXMLEqual(MockWfsServer.getDWithinPointXmlFilter(), getXmlFromMarshaller(filter));
}
use of net.opengis.filter.v_2_0_0.DistanceBufferType in project ddf by codice.
the class WfsFilterDelegate method buildDistanceBufferType.
private JAXBElement<DistanceBufferType> buildDistanceBufferType(JAXBElement<DistanceBufferType> dbt, String propertyName, String wkt, double distance) {
MeasureType measureType = new MeasureType();
measureType.setValue(distance);
// the filter adapter normalizes all distances to meters
measureType.setUom(Wfs20Constants.METERS);
dbt.getValue().setDistance(measureType);
dbt.getValue().setExpression(filterObjectFactory.createValueReference(propertyName));
dbt.getValue().setAny(createGeometryOperand(wkt));
return dbt;
}
use of net.opengis.filter.v_2_0_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()));
}
Aggregations