Search in sources :

Example 11 with BinaryTemporalOpType

use of net.opengis.filter.v_2_0_0.BinaryTemporalOpType in project ddf by codice.

the class TestWfsFilterDelegate 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 12 with BinaryTemporalOpType

use of net.opengis.filter.v_2_0_0.BinaryTemporalOpType 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);
}
Also used : FilterType(net.opengis.filter.v_2_0_0.FilterType) BinaryLogicOpType(net.opengis.filter.v_2_0_0.BinaryLogicOpType) ArrayList(java.util.ArrayList) DistanceBufferType(net.opengis.filter.v_2_0_0.DistanceBufferType) DateTime(org.joda.time.DateTime) BinaryTemporalOpType(net.opengis.filter.v_2_0_0.BinaryTemporalOpType) Test(org.junit.Test)

Aggregations

BinaryTemporalOpType (net.opengis.filter.v_2_0_0.BinaryTemporalOpType)12 FilterType (net.opengis.filter.v_2_0_0.FilterType)11 Test (org.junit.Test)9 Date (java.util.Date)7 TimePeriodType (net.opengis.gml.v_3_2_1.TimePeriodType)7 TimePositionType (net.opengis.gml.v_3_2_1.TimePositionType)7 ArrayList (java.util.ArrayList)6 TimeInstantType (net.opengis.gml.v_3_2_1.TimeInstantType)5 DateTime (org.joda.time.DateTime)4 FilterCapabilities (net.opengis.filter.v_2_0_0.FilterCapabilities)3 List (java.util.List)2 BinaryLogicOpType (net.opengis.filter.v_2_0_0.BinaryLogicOpType)2 LineString (com.vividsolutions.jts.geom.LineString)1 Method (java.lang.reflect.Method)1 JAXBElement (javax.xml.bind.JAXBElement)1 DistanceBufferType (net.opengis.filter.v_2_0_0.DistanceBufferType)1