Search in sources :

Example 16 with TimePositionType

use of org.geotoolkit.gml.xml.v321.TimePositionType in project geotoolkit by Geomatys.

the class TimePositionTypeTest method setValueTest.

@Test
public void setValueTest() throws Exception {
    String s = null;
    TimePositionType tp = new TimePositionType(s);
    final Date d = f3.parse("2010-01-01");
    tp.setValue(d);
    assertEquals(tp.getValues(), Arrays.asList("2010-01-01"));
    final Date d2 = f2.parse("2010-01-01 01:01:02");
    tp.setValue(d2);
    assertEquals(tp.getValues(), Arrays.asList("2010-01-01T01:01:02.000"));
}
Also used : TimePositionType(org.geotoolkit.gml.xml.v321.TimePositionType) Date(java.util.Date)

Example 17 with TimePositionType

use of org.geotoolkit.gml.xml.v321.TimePositionType in project geotoolkit by Geomatys.

the class TimePositionTypeTest method dateParsingTest.

@Test
public void dateParsingTest() throws Exception {
    final String s1 = f1.format(date);
    TimePositionType tp = new TimePositionType(s1);
    assertEquals(date, tp.getDate());
    final String s2 = f2.format(date);
    tp = new TimePositionType(s2);
    assertEquals(date, tp.getDate());
    final String s3 = f3.format(date);
    tp = new TimePositionType(s3);
    final Calendar cal = Calendar.getInstance();
    cal.setTime(date);
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    final Date dateNoTime = cal.getTime();
    assertEquals(dateNoTime, tp.getDate());
}
Also used : Calendar(java.util.Calendar) TimePositionType(org.geotoolkit.gml.xml.v321.TimePositionType) Date(java.util.Date)

Example 18 with TimePositionType

use of org.geotoolkit.gml.xml.v321.TimePositionType 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 19 with TimePositionType

use of org.geotoolkit.gml.xml.v321.TimePositionType in project ddf by codice.

the class WfsFilterDelegateTest 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 20 with TimePositionType

use of org.geotoolkit.gml.xml.v321.TimePositionType in project ddf by codice.

the class WfsFilterDelegateTest method testAbsoluteTemporalOnlyQueryDuringUnSupported.

/**
 * 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 testAbsoluteTemporalOnlyQueryDuringUnSupported() {
    setupMockMetacardType();
    FilterType afterFilter = setupAfterFilterType();
    FilterType beforeFilter = setupBeforeFilterType();
    WfsFilterDelegate delegate = setupTemporalFilterDelegate();
    // 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 = delegate.applyTemporalFallbacks(testFilters);
    FilterType resultAfterFilter = convertedFilters.get(0);
    FilterType resultBeforeFilter = convertedFilters.get(1);
    assertThat(resultAfterFilter.getTemporalOps().getName().toString(), is("{http://www.opengis.net/fes/2.0}After"));
    assertThat(resultBeforeFilter.getTemporalOps().getName().toString(), is("{http://www.opengis.net/fes/2.0}Before"));
    // Get Resulting After Filter Date
    binaryTemporalOpType = (BinaryTemporalOpType) resultAfterFilter.getTemporalOps().getValue();
    assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
    assertThat(binaryTemporalOpType.isSetExpression(), is(true));
    TimeInstantType timePeriodType = (TimeInstantType) binaryTemporalOpType.getExpression().getValue();
    beginPositionType = timePeriodType.getTimePosition();
    Date beginDate = timePositionTypeToDate(beginPositionType);
    // Get Resulting Before Filter Date
    binaryTemporalOpType = (BinaryTemporalOpType) resultBeforeFilter.getTemporalOps().getValue();
    assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
    assertThat(binaryTemporalOpType.isSetExpression(), is(true));
    timePeriodType = (TimeInstantType) binaryTemporalOpType.getExpression().getValue();
    endPositionType = timePeriodType.getTimePosition();
    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) FilterType(net.opengis.filter.v_2_0_0.FilterType) 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)

Aggregations

Date (java.util.Date)17 TimePositionType (net.opengis.gml.v_3_2_1.TimePositionType)14 BinaryTemporalOpType (net.opengis.filter.v_2_0_0.BinaryTemporalOpType)13 FilterType (net.opengis.filter.v_2_0_0.FilterType)13 Test (org.junit.Test)12 TimePositionType (org.geotoolkit.gml.xml.v311.TimePositionType)11 ArrayList (java.util.ArrayList)10 TimePeriodType (net.opengis.gml.v_3_2_1.TimePeriodType)9 TimeInstantType (net.opengis.gml.v_3_2_1.TimeInstantType)7 TimePeriodType (org.geotoolkit.gml.xml.v311.TimePeriodType)7 FilterCapabilities (net.opengis.filter.v_2_0_0.FilterCapabilities)6 TimePositionType (org.geotoolkit.gml.xml.v321.TimePositionType)6 JAXBElement (javax.xml.bind.JAXBElement)4 TimePeriodType (org.geotoolkit.gml.xml.v321.TimePeriodType)4 StringWriter (java.io.StringWriter)3 List (java.util.List)3 TimeInstantType (org.geotoolkit.gml.xml.v311.TimeInstantType)3 StringReader (java.io.StringReader)2 Calendar (java.util.Calendar)2 Duration (javax.xml.datatype.Duration)2