use of net.opengis.swe.x101.TimeRangeDocument.TimeRange in project arctic-sea by 52North.
the class SweCommonDecoderV101Test method should_decode_TimeRange.
@Test
public void should_decode_TimeRange() throws DecodingException {
final TimeRangeDocument xbTimeRangeDoc = TimeRangeDocument.Factory.newInstance();
TimeRange xbTimeRange = xbTimeRangeDoc.addNewTimeRange();
final DateTime startDate = new DateTime(1970, 1, 1, 0, 0, DateTimeZone.UTC);
final DateTime endDate = new DateTime(2013, 12, 31, 23, 59, DateTimeZone.UTC);
final List<String> values = Lists.newArrayList(startDate.toString(), endDate.toString());
xbTimeRange.setValue(values);
final String iso8601Uom = "urn:ogc:def:unit:ISO:8601";
xbTimeRange.addNewUom().setHref(iso8601Uom);
final Object decodedObject = new SweCommonDecoderV101().decode(xbTimeRange);
assertThat(decodedObject, is(instanceOf(SweTimeRange.class)));
final SweTimeRange sweTimeRange = (SweTimeRange) decodedObject;
assertThat(sweTimeRange.isSetUom(), is(true));
assertThat(sweTimeRange.getUom(), is(iso8601Uom));
assertThat(sweTimeRange.isSetValue(), is(true));
assertThat(sweTimeRange.getValue().getRangeStart(), is(startDate));
assertThat(sweTimeRange.getValue().getRangeEnd(), is(endDate));
}
use of net.opengis.swe.x101.TimeRangeDocument.TimeRange in project arctic-sea by 52North.
the class SweCommonEncoderv101 method createTimeRange.
private TimeRange createTimeRange(SweTimeRange timeRange) throws EncodingException {
TimeRange xbTimeRange = TimeRange.Factory.newInstance(getXmlOptions());
addAbstractDataComponentValues(xbTimeRange, timeRange);
if (timeRange.isSetValue()) {
xbTimeRange.setValue(timeRange.getValue().getRangeAsStringList());
}
if (timeRange.isSetUom()) {
xbTimeRange.addNewUom().setCode(timeRange.getUom());
}
if (timeRange.isSetQuality()) {
xbTimeRange.setQuality(createQuality(timeRange.getQuality())[0]);
}
return xbTimeRange;
}
Aggregations