use of net.opengis.gml.x32.TimePositionType in project arctic-sea by 52North.
the class GmlDecoderv321 method parseTimePeriod.
/**
* creates SOS representation of time period from XMLBeans representation of time period
*
* @param xbTimePeriod XMLBeans representation of time period
*
* @return Returns SOS representation of time period
*
* @throws DecodingException if the time string is invalid
*/
private Object parseTimePeriod(TimePeriodType xbTimePeriod) throws DecodingException {
// begin position
TimePositionType xbBeginTPT = xbTimePeriod.getBeginPosition();
TimeInstant begin = null;
if (xbBeginTPT != null) {
begin = parseTimePosition(xbBeginTPT);
} else {
throw new DecodingException("gml:TimePeriod must contain gml:beginPosition Element with valid ISO:8601 String!");
}
// end position
TimePositionType xbEndTPT = xbTimePeriod.getEndPosition();
TimeInstant end = null;
if (xbEndTPT != null) {
end = parseTimePosition(xbEndTPT);
} else {
throw new DecodingException("gml:TimePeriod must contain gml:endPosition Element with valid ISO:8601 String!");
}
TimePeriod timePeriod = new TimePeriod(begin, end);
timePeriod.setGmlId(xbTimePeriod.getId());
return timePeriod;
}
use of net.opengis.gml.x32.TimePositionType in project ddf by codice.
the class TestWfsFilterDelegate method testDuringFilterTypeDates.
@Test
public void testDuringFilterTypeDates() throws Exception {
setupMockMetacardType();
FilterType duringFilter = setupDuringFilterType();
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);
assertThat(endDate.after(beginDate), is(true));
}
use of net.opengis.gml.x32.TimePositionType in project ddf by codice.
the class TestWfsFilterDelegate method testDuringTemporalFallback.
@Test
public void testDuringTemporalFallback() throws Exception {
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);
WfsFilterDelegate spatialDelegate = mockFeatureMetacardCreateDelegate(mockFeatureProperty, mockFeatureType);
FilterType spatialFilter = spatialDelegate.dwithin(Metacard.ANY_GEO, "POINT (30 10)", Double.valueOf(1000));
List<List<FilterType>> testFilters = new ArrayList<>();
testFilters.add(Arrays.asList(afterFilter, beforeFilter));
testFilters.add(Arrays.asList(afterFilter, beforeFilter, spatialFilter));
for (List<FilterType> filtersToBeConverted : testFilters) {
List<FilterType> convertedFilters = duringDelegate.applyTemporalFallbacks(filtersToBeConverted);
FilterType duringFilter = convertedFilters.get(0);
if (filtersToBeConverted.contains(spatialFilter)) {
// verify that results contains the spatial filter type
assertThat(convertedFilters.contains(spatialFilter), is(true));
assertThat(convertedFilters.size(), is(2));
if (duringFilter.isSetSpatialOps()) {
duringFilter = convertedFilters.get(1);
}
//Verify during Filter is correct
assertThat(duringFilter.isSetTemporalOps(), is(true));
}
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 net.opengis.gml.x32.TimePositionType 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));
}
use of net.opengis.gml.x32.TimePositionType in project arctic-sea by 52North.
the class GmlEncoderv321 method createTimePositionType.
private TimePositionType createTimePositionType(TimePosition timePosition) throws DateTimeFormatException {
TimePositionType xbTimePosition = TimePositionType.Factory.newInstance();
if (!timePosition.isSetTime()) {
String indeterminateValue = Optional.ofNullable(timePosition.getIndeterminateValue()).orElse(IndeterminateValue.UNKNOWN).getValue();
if (TimeIndeterminateValueType.Enum.forString(indeterminateValue) != null) {
xbTimePosition.setIndeterminatePosition(TimeIndeterminateValueType.Enum.forString(indeterminateValue));
} else {
xbTimePosition.setStringValue(indeterminateValue);
}
} else {
String endString = DateTimeHelper.formatDateTime2String(timePosition);
// concat minutes for timeZone offset, because gml requires
// xs:dateTime, which needs minutes in
// timezone offset
// TODO enable really
xbTimePosition.setStringValue(endString);
}
return xbTimePosition;
}
Aggregations