Search in sources :

Example 31 with Time

use of org.n52.shetland.ogc.gml.time.Time in project arctic-sea by 52North.

the class UVFEncoder method getTemporalBBoxFromObservations.

private TimePeriod getTemporalBBoxFromObservations(List<OmObservation> observationCollection) throws EncodingException {
    DateTime start = null;
    DateTime end = null;
    for (OmObservation observation : observationCollection) {
        Time phenomenonTime = observation.getPhenomenonTime();
        if (phenomenonTime instanceof TimeInstant) {
            final DateTime time = ((TimeInstant) phenomenonTime).getTimePosition().getTime();
            if (start == null || time.isBefore(start)) {
                start = time;
            }
            if (end == null || time.isAfter(end)) {
                end = time;
            }
        } else {
            final DateTime periodStart = ((TimePeriod) phenomenonTime).getStart();
            if (start == null || periodStart.isBefore(start)) {
                start = periodStart;
            }
            final DateTime periodEnd = ((TimePeriod) phenomenonTime).getEnd();
            if (end == null || periodEnd.isAfter(end)) {
                end = periodEnd;
            }
        }
    }
    if (start != null && end != null) {
        return new TimePeriod(start, end);
    } else {
        final String message = "Could not extract centuries from observation collection";
        LOGGER.error(message);
        throw new EncodingException(message);
    }
}
Also used : EncodingException(org.n52.svalbard.encode.exception.EncodingException) TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) OmObservation(org.n52.shetland.ogc.om.OmObservation) Time(org.n52.shetland.ogc.gml.time.Time) DateTime(org.joda.time.DateTime) DateTime(org.joda.time.DateTime) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant)

Example 32 with Time

use of org.n52.shetland.ogc.gml.time.Time in project arctic-sea by 52North.

the class TimeTest method datetime.

@Test
public void datetime() {
    TimePosition timePosition = new TimePosition(DateTime.now());
    assertThat("time position is set", timePosition.isSetTime(), is(true));
    assertThat("indeterminate value is not", timePosition.isSetIndeterminateValue(), is(false));
    assertThat("time format is set", timePosition.isSetTimeFormat(), is(true));
}
Also used : TimePosition(org.n52.shetland.ogc.gml.time.TimePosition) Test(org.junit.Test)

Example 33 with Time

use of org.n52.shetland.ogc.gml.time.Time in project arctic-sea by 52North.

the class TimeTest method format.

@Test
public void format() {
    TimePosition timePosition = new TimePosition(DateTime.now(), Time.TimeFormat.ISO8601);
    assertThat("time position is set", timePosition.isSetTime(), is(true));
    assertThat("indeterminate value is not set", timePosition.isSetIndeterminateValue(), is(false));
    assertThat("format is set", timePosition.isSetTimeFormat(), is(true));
    assertThat("format is correct", timePosition.getTimeFormat().toString(), is(Time.TimeFormat.ISO8601.toString()));
}
Also used : TimePosition(org.n52.shetland.ogc.gml.time.TimePosition) Test(org.junit.Test)

Example 34 with Time

use of org.n52.shetland.ogc.gml.time.Time in project arctic-sea by 52North.

the class MeasurementDecodingTest method testPhenomenonTime.

@Test
public void testPhenomenonTime() {
    assertThat(observation, is(notNullValue()));
    final ObservationValue<?> ov = observation.getValue();
    assertThat(ov, is(notNullValue()));
    final Time pt = ov.getPhenomenonTime();
    assertThat(pt, is(notNullValue()));
    assertThat(pt, is(instanceOf(TimeInstant.class)));
    TimeInstant ti = (TimeInstant) pt;
    assertThat(ti.getValue(), is(equalTo(phenomenonTime)));
}
Also used : Time(org.n52.shetland.ogc.gml.time.Time) DateTime(org.joda.time.DateTime) DateTimeHelper.parseIsoString2DateTime(org.n52.shetland.util.DateTimeHelper.parseIsoString2DateTime) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) Test(org.junit.Test)

Example 35 with Time

use of org.n52.shetland.ogc.gml.time.Time in project arctic-sea by 52North.

the class SweCommonDecoderV101 method parseEnvelope.

private SweAbstractDataComponent parseEnvelope(EnvelopeType envelopeType) throws DecodingException {
    String referenceFrame = null;
    SweVector lowerCorner = null;
    SweVector upperCorner = null;
    SweTimeRange time = null;
    if (envelopeType.isSetReferenceFrame()) {
        referenceFrame = envelopeType.getReferenceFrame();
    }
    if (envelopeType.getLowerCorner() != null) {
        lowerCorner = parseVectorProperty(envelopeType.getLowerCorner());
    }
    if (envelopeType.getUpperCorner() != null) {
        upperCorner = parseVectorProperty(envelopeType.getUpperCorner());
    }
    if (envelopeType.isSetTime()) {
        time = parseTimeRange(envelopeType.getTime().getTimeRange());
    }
    // FIXME get the northing first value for the reference frame
    boolean northingFirst = false;
    return new SweEnvelope(referenceFrame, upperCorner, lowerCorner, time, northingFirst);
}
Also used : SweVector(org.n52.shetland.ogc.swe.SweVector) SweEnvelope(org.n52.shetland.ogc.swe.SweEnvelope) SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange)

Aggregations

Time (org.n52.shetland.ogc.gml.time.Time)24 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)18 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)17 DateTime (org.joda.time.DateTime)12 Test (org.junit.Test)11 XmlObject (org.apache.xmlbeans.XmlObject)9 OmObservation (org.n52.shetland.ogc.om.OmObservation)8 DecodingException (org.n52.svalbard.decode.exception.DecodingException)7 EncodingException (org.n52.svalbard.encode.exception.EncodingException)7 SweTime (org.n52.shetland.ogc.swe.simpleType.SweTime)6 TimePosition (org.n52.shetland.ogc.gml.time.TimePosition)5 SweTimeRange (org.n52.shetland.ogc.swe.simpleType.SweTimeRange)4 XmlException (org.apache.xmlbeans.XmlException)3 XmlString (org.apache.xmlbeans.XmlString)3 EReportingHeader (org.n52.shetland.aqd.EReportingHeader)3 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)3 MultiObservationValues (org.n52.shetland.ogc.om.MultiObservationValues)3 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)3 SingleObservationValue (org.n52.shetland.ogc.om.SingleObservationValue)3 TimeValuePair (org.n52.shetland.ogc.om.TimeValuePair)3