use of org.n52.shetland.ogc.gml.time.TimePeriod in project arctic-sea by 52North.
the class GetObservationRequestDecoderTest method hasMultipleTemporalFilters.
@Test
public void hasMultipleTemporalFilters() throws IOException, DecodingException {
final GetObservationRequest req = loadMultiple();
assertThat(req.getTemporalFilters(), is(notNullValue()));
assertThat(req.getTemporalFilters(), hasSize(2));
assertThat(req.getTemporalFilters().get(0), is(notNullValue()));
assertThat(req.getTemporalFilters().get(0).getOperator(), is(TimeOperator.TM_Equals));
assertThat(req.getTemporalFilters().get(0).getValueReference(), is("om:phenomenonTime"));
assertThat(req.getTemporalFilters().get(0).getTime(), is(instanceOf(TimePeriod.class)));
final TimePeriod time1 = (TimePeriod) req.getTemporalFilters().get(0).getTime();
assertThat(time1.getStart(), is(equalTo(new DateTime(2013, 01, 01, 00, 00, 00, 00, DateTimeZone.forOffsetHours(2)))));
assertThat(time1.getEnd(), is(equalTo(new DateTime(2013, 01, 01, 01, 00, 00, 00, DateTimeZone.forOffsetHours(2)))));
assertThat(req.getTemporalFilters().get(1), is(notNullValue()));
assertThat(req.getTemporalFilters().get(1).getOperator(), is(TimeOperator.TM_Equals));
assertThat(req.getTemporalFilters().get(1).getValueReference(), is("om:phenomenonTime"));
assertThat(req.getTemporalFilters().get(1).getTime(), is(instanceOf(TimePeriod.class)));
final TimePeriod time2 = (TimePeriod) req.getTemporalFilters().get(1).getTime();
assertThat(time2.getStart(), is(equalTo(new DateTime(2013, 01, 01, 20, 00, 00, 00, DateTimeZone.forOffsetHours(2)))));
assertThat(time2.getEnd(), is(equalTo(new DateTime(2013, 01, 01, 22, 00, 00, 00, DateTimeZone.forOffsetHours(2)))));
}
use of org.n52.shetland.ogc.gml.time.TimePeriod in project arctic-sea by 52North.
the class MeasurementDecodingTest method testValidTime.
@Test
public void testValidTime() {
assertThat(observation, is(notNullValue()));
final TimePeriod vt = observation.getValidTime();
assertThat(vt, is(notNullValue()));
assertThat(vt.getStart(), is(equalTo(validTimeStart)));
assertThat(vt.getEnd(), is(equalTo(validTimeEnd)));
}
use of org.n52.shetland.ogc.gml.time.TimePeriod in project arctic-sea by 52North.
the class GetDataAvailabilityResponseDecoder method getPhenomenonTime.
private TimePeriod getPhenomenonTime(AbstractTimeObjectType atot, String href, Map<String, TimePeriod> periods) throws DecodingException {
TimePeriod phenomenonTime;
if (atot != null) {
phenomenonTime = decodeXmlElement(atot);
periods.put(phenomenonTime.getGmlId(), phenomenonTime);
} else {
String id = href.startsWith("#") ? href.substring(1) : href;
phenomenonTime = periods.get(id);
}
return phenomenonTime;
}
use of org.n52.shetland.ogc.gml.time.TimePeriod in project arctic-sea by 52North.
the class GmlDecoderv311 method parseTimePeriod.
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 org.n52.shetland.ogc.gml.time.TimePeriod 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;
}
Aggregations