Search in sources :

Example 31 with FilterCapabilities

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));
}
Also used : GeometryOperand(net.opengis.filter.v_2_0_0.GeometryOperandsType.GeometryOperand) FilterCapabilities(net.opengis.filter.v_2_0_0.FilterCapabilities) FilterType(net.opengis.filter.v_2_0_0.FilterType) SpatialOperatorType(net.opengis.filter.v_2_0_0.SpatialOperatorType) ArrayList(java.util.ArrayList) BinarySpatialOpType(net.opengis.filter.v_2_0_0.BinarySpatialOpType) Test(org.junit.Test)

Example 32 with FilterCapabilities

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));
}
Also used : FilterCapabilities(net.opengis.filter.v_2_0_0.FilterCapabilities) DomainType(net.opengis.ows.v_1_1_0.DomainType) AllowedValues(net.opengis.ows.v_1_1_0.AllowedValues) ValueType(net.opengis.ows.v_1_1_0.ValueType) ArrayList(java.util.ArrayList) ConformanceType(net.opengis.filter.v_2_0_0.ConformanceType) Test(org.junit.Test)

Example 33 with FilterCapabilities

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);
}
Also used : FilterCapabilities(net.opengis.filter.v_2_0_0.FilterCapabilities) SpatialOperatorType(net.opengis.filter.v_2_0_0.SpatialOperatorType) ArrayList(java.util.ArrayList)

Example 34 with FilterCapabilities

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));
}
Also used : FilterCapabilities(net.opengis.filter.v_2_0_0.FilterCapabilities) FilterType(net.opengis.filter.v_2_0_0.FilterType) TimePeriodType(net.opengis.gml.v_3_2_1.TimePeriodType) ArrayList(java.util.ArrayList) BinaryTemporalOpType(net.opengis.filter.v_2_0_0.BinaryTemporalOpType) TimePositionType(net.opengis.gml.v_3_2_1.TimePositionType) Date(java.util.Date) Test(org.junit.Test)

Example 35 with FilterCapabilities

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));
}
Also used : GeometryOperand(net.opengis.filter.v_2_0_0.GeometryOperandsType.GeometryOperand) FilterCapabilities(net.opengis.filter.v_2_0_0.FilterCapabilities) FilterType(net.opengis.filter.v_2_0_0.FilterType) SpatialOperatorType(net.opengis.filter.v_2_0_0.SpatialOperatorType) ArrayList(java.util.ArrayList) BinarySpatialOpType(net.opengis.filter.v_2_0_0.BinarySpatialOpType) Test(org.junit.Test)

Aggregations

FilterCapabilities (net.opengis.filter.v_2_0_0.FilterCapabilities)33 ArrayList (java.util.ArrayList)28 Test (org.junit.Test)24 FilterType (net.opengis.filter.v_2_0_0.FilterType)14 FilterCapabilities (net.opengis.filter.v_1_1_0.FilterCapabilities)11 SpatialOperatorType (net.opengis.filter.v_2_0_0.SpatialOperatorType)11 ComparisonOperatorsType (net.opengis.filter.v_1_1_0.ComparisonOperatorsType)8 LogicalOperators (net.opengis.filter.v_1_1_0.LogicalOperators)8 ScalarCapabilitiesType (net.opengis.filter.v_1_1_0.ScalarCapabilitiesType)8 SpatialCapabilitiesType (net.opengis.filter.v_1_1_0.SpatialCapabilitiesType)8 SpatialOperatorsType (net.opengis.filter.v_1_1_0.SpatialOperatorsType)8 Date (java.util.Date)6 QName (javax.xml.namespace.QName)6 SpatialOperatorType (net.opengis.filter.v_1_1_0.SpatialOperatorType)6 BinarySpatialOpType (net.opengis.filter.v_2_0_0.BinarySpatialOpType)6 BinaryTemporalOpType (net.opengis.filter.v_2_0_0.BinaryTemporalOpType)6 TimePeriodType (net.opengis.gml.v_3_2_1.TimePeriodType)6 TimePositionType (net.opengis.gml.v_3_2_1.TimePositionType)6 ConformanceType (net.opengis.filter.v_2_0_0.ConformanceType)5 GeometryOperand (net.opengis.filter.v_2_0_0.GeometryOperandsType.GeometryOperand)5