use of ogc.schema.opengis.filter_capabilities.v_1_0_0.FilterCapabilities in project ddf by codice.
the class WfsFilterDelegateTest method testIntersectsWithEnvelopeLonLat.
@Test
public void testIntersectsWithEnvelopeLonLat() throws SAXException, IOException, JAXBException {
List<String> gmlProps = new ArrayList<>();
gmlProps.add(MOCK_GEOM);
when(mockFeatureMetacardType.getGmlProperties()).thenReturn(gmlProps);
when(mockFeatureMetacardType.isQueryable(MOCK_GEOM)).thenReturn(true);
SpatialOperatorType operator = new SpatialOperatorType();
operator.setName(SPATIAL_OPERATORS.INTERSECTS.toString());
FilterCapabilities capabilities = MockWfsServer.getFilterCapabilities();
capabilities.getSpatialCapabilities().getSpatialOperators().getSpatialOperator().clear();
capabilities.getSpatialCapabilities().getSpatialOperators().getSpatialOperator().add(operator);
capabilities.getSpatialCapabilities().getGeometryOperands().getGeometryOperand().clear();
GeometryOperand geoOperand = new GeometryOperand();
geoOperand.setName(Wfs20Constants.ENVELOPE);
capabilities.getSpatialCapabilities().getGeometryOperands().getGeometryOperand().add(geoOperand);
WfsFilterDelegate delegate = new WfsFilterDelegate(mockFeatureMetacardType, capabilities, GeospatialUtil.EPSG_4326_URN, mockMapper, GeospatialUtil.LON_LAT_ORDER);
FilterType filter = delegate.intersects(Metacard.ANY_GEO, POLYGON);
assertTrue(filter.getSpatialOps().getValue() instanceof BinarySpatialOpType);
assertFalse(filter.isSetLogicOps());
assertXMLEqual(MockWfsServer.getIntersectsWithEnvelopeLonLatXmlFilter(), getXmlFromMarshaller(filter));
}
use of ogc.schema.opengis.filter_capabilities.v_1_0_0.FilterCapabilities in project ddf by codice.
the class WfsFilterDelegateTest method testConformanceAllowedValues.
@Test
public void testConformanceAllowedValues() {
// Setup
FilterCapabilities capabilities = MockWfsServer.getFilterCapabilities();
ConformanceType conformance = capabilities.getConformance();
List<DomainType> domainTypes = conformance.getConstraint();
for (DomainType domainType : domainTypes) {
if (StringUtils.equals(domainType.getName(), "ImplementsSorting")) {
domainType.setNoValues(null);
ValueType asc = new ValueType();
asc.setValue("ASC");
ValueType desc = new ValueType();
desc.setValue("DESC");
AllowedValues allowedValues = new AllowedValues();
List<Object> values = new ArrayList<>();
values.add(asc);
values.add(desc);
allowedValues.setValueOrRange(values);
domainType.setAllowedValues(allowedValues);
ValueType defaultValue = new ValueType();
defaultValue.setValue("ASC");
domainType.setDefaultValue(defaultValue);
break;
}
}
// Perform Test
WfsFilterDelegate delegate = new WfsFilterDelegate(mockFeatureMetacardType, capabilities, GeospatialUtil.EPSG_4326_URN, mockMapper, GeospatialUtil.LAT_LON_ORDER);
// Verify
assertThat(delegate.isSortingSupported(), is(true));
assertThat(delegate.getAllowedSortOrders().size(), is(2));
assertThat(delegate.getAllowedSortOrders().contains(SortOrder.ASCENDING), is(true));
assertThat(delegate.getAllowedSortOrders().contains(SortOrder.DESCENDING), is(true));
}
use of ogc.schema.opengis.filter_capabilities.v_1_0_0.FilterCapabilities in project ddf by codice.
the class WfsFilterDelegateTest method setupFilterDelegate.
private WfsFilterDelegate setupFilterDelegate(String spatialOpType) {
List<String> gmlProps = new ArrayList<>();
gmlProps.add(MOCK_GEOM);
when(mockFeatureMetacardType.getGmlProperties()).thenReturn(gmlProps);
when(mockFeatureMetacardType.isQueryable(MOCK_GEOM)).thenReturn(true);
SpatialOperatorType operator = new SpatialOperatorType();
operator.setName(spatialOpType);
FilterCapabilities capabilities = MockWfsServer.getFilterCapabilities();
capabilities.getSpatialCapabilities().getSpatialOperators().getSpatialOperator().clear();
capabilities.getSpatialCapabilities().getSpatialOperators().getSpatialOperator().add(operator);
return new WfsFilterDelegate(mockFeatureMetacardType, capabilities, GeospatialUtil.EPSG_4326_URN, mockMapper, GeospatialUtil.LAT_LON_ORDER);
}
use of ogc.schema.opengis.filter_capabilities.v_1_0_0.FilterCapabilities in project ddf by codice.
the class WfsFilterDelegateTest method testRelativeTemporalOnlyQueryAfterUnsupported.
/**
* If the WFS server does not support an 'After' temporal query and supports a 'During' temporal
* query, the query should be translated into a 'During <date> to <now>'
*/
@Test
public void testRelativeTemporalOnlyQueryAfterUnsupported() {
setupMockMetacardType();
FilterType afterFilter = setupAfterFilterType();
FilterCapabilities duringFilterCapabilities = setupFilterCapabilities();
WfsFilterDelegate duringDelegate = new WfsFilterDelegate(mockFeatureMetacardType, duringFilterCapabilities, GeospatialUtil.EPSG_4326_URN, mockMapper, GeospatialUtil.LAT_LON_ORDER);
List<FilterType> testFilters = new ArrayList<>();
testFilters.add(afterFilter);
List<FilterType> convertedFilters = duringDelegate.applyTemporalFallbacks(testFilters);
FilterType duringFilter = convertedFilters.get(0);
assertThat(duringFilter.getTemporalOps().getName().toString(), is("{http://www.opengis.net/fes/2.0}During"));
BinaryTemporalOpType binaryTemporalOpType = (BinaryTemporalOpType) duringFilter.getTemporalOps().getValue();
assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
assertThat(binaryTemporalOpType.isSetExpression(), is(true));
TimePeriodType timePeriod = (TimePeriodType) binaryTemporalOpType.getExpression().getValue();
TimePositionType beginPositionType = timePeriod.getBeginPosition();
Date beginDate = timePositionTypeToDate(beginPositionType);
TimePositionType endPositionType = timePeriod.getEndPosition();
Date endDate = timePositionTypeToDate(endPositionType);
// Verify Date range is created correctly
assertThat(endDate.after(beginDate), is(true));
}
use of ogc.schema.opengis.filter_capabilities.v_1_0_0.FilterCapabilities in project ddf by codice.
the class WfsFilterDelegateTest method testIntersectsWithEnvelope.
@Test
public void testIntersectsWithEnvelope() throws SAXException, IOException, JAXBException {
List<String> gmlProps = new ArrayList<>();
gmlProps.add(MOCK_GEOM);
when(mockFeatureMetacardType.getGmlProperties()).thenReturn(gmlProps);
when(mockFeatureMetacardType.isQueryable(MOCK_GEOM)).thenReturn(true);
SpatialOperatorType operator = new SpatialOperatorType();
operator.setName(SPATIAL_OPERATORS.INTERSECTS.toString());
FilterCapabilities capabilities = MockWfsServer.getFilterCapabilities();
capabilities.getSpatialCapabilities().getSpatialOperators().getSpatialOperator().clear();
capabilities.getSpatialCapabilities().getSpatialOperators().getSpatialOperator().add(operator);
capabilities.getSpatialCapabilities().getGeometryOperands().getGeometryOperand().clear();
GeometryOperand geoOperand = new GeometryOperand();
geoOperand.setName(Wfs20Constants.ENVELOPE);
capabilities.getSpatialCapabilities().getGeometryOperands().getGeometryOperand().add(geoOperand);
WfsFilterDelegate delegate = new WfsFilterDelegate(mockFeatureMetacardType, capabilities, GeospatialUtil.EPSG_4326_URN, mockMapper, GeospatialUtil.LAT_LON_ORDER);
FilterType filter = delegate.intersects(Metacard.ANY_GEO, POLYGON);
assertTrue(filter.getSpatialOps().getValue() instanceof BinarySpatialOpType);
assertFalse(filter.isSetLogicOps());
assertXMLEqual(MockWfsServer.getIntersectsWithEnvelopeXmlFilter(), getXmlFromMarshaller(filter));
}
Aggregations