Search in sources :

Example 6 with FilterType

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

the class TestWfsFilterDelegate method testAbsoluteTemporalOnlyQueryDuringSupported.

/**
     * If the WFS server does not support an 'After' and 'Before' temporal query,
     * and supports a 'During' temporal query, the query should be translated
     * into 'During <after> to <before>'
     */
@Test
public void testAbsoluteTemporalOnlyQueryDuringSupported() {
    setupMockMetacardType();
    FilterType afterFilter = setupAfterFilterType();
    FilterType beforeFilter = setupBeforeFilterType();
    FilterCapabilities duringFilterCapabilities = setupFilterCapabilities();
    WfsFilterDelegate duringDelegate = new WfsFilterDelegate(mockFeatureMetacardType, duringFilterCapabilities, GeospatialUtil.EPSG_4326_URN, mockMapper, GeospatialUtil.LAT_LON_ORDER);
    // Get After Filter Date
    BinaryTemporalOpType binaryTemporalOpType = (BinaryTemporalOpType) afterFilter.getTemporalOps().getValue();
    assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
    assertThat(binaryTemporalOpType.isSetExpression(), is(true));
    TimeInstantType timePeriod = (TimeInstantType) binaryTemporalOpType.getExpression().getValue();
    TimePositionType beginPositionType = timePeriod.getTimePosition();
    Date afterDate = timePositionTypeToDate(beginPositionType);
    // Get Before Filter Date
    binaryTemporalOpType = (BinaryTemporalOpType) beforeFilter.getTemporalOps().getValue();
    assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
    assertThat(binaryTemporalOpType.isSetExpression(), is(true));
    timePeriod = (TimeInstantType) binaryTemporalOpType.getExpression().getValue();
    TimePositionType endPositionType = timePeriod.getTimePosition();
    Date beforeDate = timePositionTypeToDate(endPositionType);
    List<FilterType> testFilters = new ArrayList<>();
    testFilters.add(afterFilter);
    testFilters.add(beforeFilter);
    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) duringFilter.getTemporalOps().getValue();
    assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
    assertThat(binaryTemporalOpType.isSetExpression(), is(true));
    TimePeriodType timePeriodType = (TimePeriodType) binaryTemporalOpType.getExpression().getValue();
    beginPositionType = timePeriodType.getBeginPosition();
    Date beginDate = timePositionTypeToDate(beginPositionType);
    endPositionType = timePeriodType.getEndPosition();
    Date endDate = timePositionTypeToDate(endPositionType);
    // Verify Date range is created correctly
    assertThat(endDate.after(beginDate), is(true));
    assertThat(endDate.equals(beforeDate), is(true));
    assertThat(beginDate.equals(afterDate), is(true));
}
Also used : TimeInstantType(net.opengis.gml.v_3_2_1.TimeInstantType) 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 7 with FilterType

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

the class TestWfsFilterDelegate 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.getAttributeDescriptor(MOCK_GEOM)).thenReturn(new FeatureAttributeDescriptor(MOCK_GEOM, MOCK_GEOM, true, false, false, false, BasicTypes.STRING_TYPE));
    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, null, 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) FeatureAttributeDescriptor(org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor) 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 8 with FilterType

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

the class TestWfsFilterDelegate method testUnsupportedFilterType.

private void testUnsupportedFilterType(Method spatialOpMeth, SPATIAL_OPERATORS failType) throws InvocationTargetException, IllegalAccessException {
    WfsFilterDelegate delegate = setupFilterDelegate(failType.toString());
    FilterType filter = (FilterType) spatialOpMeth.invoke(delegate, Metacard.ANY_GEO, POLYGON);
    assertNull(filter);
}
Also used : FilterType(net.opengis.filter.v_2_0_0.FilterType)

Example 9 with FilterType

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

the class TestWfsFilterDelegate method testRelativeTemporalOnlyQueryAfterSupported.

/**
     * If the WFS server does support an 'After' temporal query and supports a
     * 'During' temporal query, the query should remain an 'After' query
     */
@Test
public void testRelativeTemporalOnlyQueryAfterSupported() {
    setupMockMetacardType();
    FilterType afterFilter = setupAfterFilterType();
    assertThat(afterFilter.getTemporalOps().getName().toString(), is("{http://www.opengis.net/fes/2.0}After"));
    BinaryTemporalOpType binaryTemporalOpType = (BinaryTemporalOpType) afterFilter.getTemporalOps().getValue();
    assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
    assertThat(binaryTemporalOpType.isSetExpression(), is(true));
    TimeInstantType timePeriod = (TimeInstantType) binaryTemporalOpType.getExpression().getValue();
    TimePositionType beginPositionType = timePeriod.getTimePosition();
    Date beginDate = timePositionTypeToDate(beginPositionType);
    Date endDate = new Date();
    // Verify Date range is created correctly
    assertThat(endDate.after(beginDate), is(true));
}
Also used : TimeInstantType(net.opengis.gml.v_3_2_1.TimeInstantType) FilterType(net.opengis.filter.v_2_0_0.FilterType) 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 10 with FilterType

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

the class TestWfsFilterDelegate method testSequentialPropertyIsOfTemporalType.

private void testSequentialPropertyIsOfTemporalType(String methName, String temporalOpName) throws Exception {
    SequentialTestMockHolder sequentialTestMockHolder = new SequentialTestMockHolder().invoke();
    WfsFilterDelegate delegate = sequentialTestMockHolder.getDelegate();
    String mockMetacardAttribute = sequentialTestMockHolder.getMockMetacardAttribute();
    String mockFeatureProperty = sequentialTestMockHolder.getMockFeatureProperty();
    String mockFeatureType = sequentialTestMockHolder.getMockFeatureType();
    DateTime date = new DateTime().minusDays(365);
    // Perform Test
    Method method = WfsFilterDelegate.class.getMethod(methName, String.class, Date.class);
    FilterType filter = (FilterType) method.invoke(delegate, mockMetacardAttribute, date.toDate());
    //Verify
    assertThat(filter.getTemporalOps().getName().toString(), is(temporalOpName));
    BinaryTemporalOpType binaryTemporalOpType = (BinaryTemporalOpType) filter.getTemporalOps().getValue();
    assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
    assertThat(binaryTemporalOpType.getValueReference(), is(mockFeatureProperty));
    assertThat(binaryTemporalOpType.isSetExpression(), is(true));
    TimeInstantType timeInstant = (TimeInstantType) binaryTemporalOpType.getExpression().getValue();
    assertThat(timeInstant.getTimePosition().getValue().get(0), is(ISODateTimeFormat.dateTimeNoMillis().withZone(DateTimeZone.UTC).print(date)));
    assertThat("Strings matches expected pattern", timeInstant.getId().matches(getRegEx(mockFeatureType)), equalTo(true));
}
Also used : TimeInstantType(net.opengis.gml.v_3_2_1.TimeInstantType) FilterType(net.opengis.filter.v_2_0_0.FilterType) Method(java.lang.reflect.Method) DateTime(org.joda.time.DateTime) BinaryTemporalOpType(net.opengis.filter.v_2_0_0.BinaryTemporalOpType)

Aggregations

Test (org.junit.Test)212 FilterType (net.opengis.filter.v_1_1_0.FilterType)209 FilterType (net.opengis.filter.v_2_0_0.FilterType)58 ArrayList (java.util.ArrayList)50 JAXBElement (javax.xml.bind.JAXBElement)12 CswSourceConfiguration (org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration)12 BinaryTemporalOpType (net.opengis.filter.v_2_0_0.BinaryTemporalOpType)11 FeatureAttributeDescriptor (org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor)11 QName (javax.xml.namespace.QName)10 BinarySpatialOpType (net.opengis.filter.v_2_0_0.BinarySpatialOpType)10 LineString (com.vividsolutions.jts.geom.LineString)9 Date (java.util.Date)9 DistanceBufferType (net.opengis.filter.v_2_0_0.DistanceBufferType)9 UnaryLogicOpType (net.opengis.filter.v_2_0_0.UnaryLogicOpType)9 DateTime (org.joda.time.DateTime)8 Method (java.lang.reflect.Method)7 QueryConstraintType (net.opengis.cat.csw.v_2_0_2.QueryConstraintType)7 FilterCapabilities (net.opengis.filter.v_2_0_0.FilterCapabilities)7 TimePeriodType (net.opengis.gml.v_3_2_1.TimePeriodType)7 TimePositionType (net.opengis.gml.v_3_2_1.TimePositionType)7