Search in sources :

Example 6 with TimePeriod

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)))));
}
Also used : GetObservationRequest(org.n52.shetland.ogc.sos.request.GetObservationRequest) TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 7 with TimePeriod

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)));
}
Also used : TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) Test(org.junit.Test)

Example 8 with TimePeriod

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;
}
Also used : TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod)

Example 9 with TimePeriod

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;
}
Also used : TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) DecodingException(org.n52.svalbard.decode.exception.DecodingException) TimePositionType(net.opengis.gml.TimePositionType) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant)

Example 10 with 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;
}
Also used : TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) DecodingException(org.n52.svalbard.decode.exception.DecodingException) TimePositionType(net.opengis.gml.x32.TimePositionType) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant)

Aggregations

TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)33 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)16 DateTime (org.joda.time.DateTime)13 Time (org.n52.shetland.ogc.gml.time.Time)12 OmObservation (org.n52.shetland.ogc.om.OmObservation)10 EncodingException (org.n52.svalbard.encode.exception.EncodingException)8 XmlObject (org.apache.xmlbeans.XmlObject)7 Test (org.junit.Test)4 EReportingHeader (org.n52.shetland.aqd.EReportingHeader)3 ReferenceType (org.n52.shetland.ogc.gml.ReferenceType)3 FeatureCollection (org.n52.shetland.ogc.om.features.FeatureCollection)3 OwsExceptionReport (org.n52.shetland.ogc.ows.exception.OwsExceptionReport)3 DataAvailability (org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.DataAvailability)3 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)3 SweField (org.n52.shetland.ogc.swe.SweField)3 SweTime (org.n52.shetland.ogc.swe.simpleType.SweTime)3 DecodingException (org.n52.svalbard.decode.exception.DecodingException)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)2 GetObservationRequest (org.n52.shetland.ogc.sos.request.GetObservationRequest)2