Search in sources :

Example 21 with TimeInstant

use of org.n52.shetland.ogc.gml.time.TimeInstant 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 22 with TimeInstant

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

the class TextObservationDecodingTest method testObservation.

@Test
public void testObservation() {
    assertThat(observation, is(notNullValue()));
    final String type = observation.getObservationConstellation().getObservationType();
    assertThat(type, is(equalTo(OmConstants.OBS_TYPE_TEXT_OBSERVATION)));
    final ObservationValue<?> value = observation.getValue();
    assertThat(value, is(instanceOf(SingleObservationValue.class)));
    assertThat(value.getPhenomenonTime(), is(instanceOf(TimeInstant.class)));
    TimeInstant pt = (TimeInstant) value.getPhenomenonTime();
    assertThat(pt.getValue(), is(equalTo(phenomenonTime)));
    assertThat(value.getValue(), is(instanceOf(TextValue.class)));
    TextValue v = (TextValue) value.getValue();
    assertThat(v.getValue(), is(equalTo("Some Value")));
    assertThat(v.getUnit(), is(nullValue()));
}
Also used : TextValue(org.n52.shetland.ogc.om.values.TextValue) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) Test(org.junit.Test)

Example 23 with TimeInstant

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

the class CategoryObservationDecodingTest method testObservation.

@Test
public void testObservation() {
    assertThat(observation, is(notNullValue()));
    final String type = observation.getObservationConstellation().getObservationType();
    assertThat(type, is(equalTo(OmConstants.OBS_TYPE_CATEGORY_OBSERVATION)));
    final ObservationValue<?> value = observation.getValue();
    assertThat(value, is(instanceOf(SingleObservationValue.class)));
    assertThat(value.getPhenomenonTime(), is(instanceOf(TimeInstant.class)));
    TimeInstant pt = (TimeInstant) value.getPhenomenonTime();
    assertThat(pt.getValue(), is(equalTo(phenomenonTime)));
    assertThat(value.getValue(), is(instanceOf(CategoryValue.class)));
    CategoryValue v = (CategoryValue) value.getValue();
    assertThat(v.getValue(), is(equalTo("Some Value")));
    assertThat(v.getUnit(), is(equalTo("http://52north.org/")));
}
Also used : CategoryValue(org.n52.shetland.ogc.om.values.CategoryValue) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) Test(org.junit.Test)

Example 24 with TimeInstant

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

the class GeometryObservationDecodingTest method testObservation.

@Test
public void testObservation() {
    assertThat(observation, is(notNullValue()));
    final String type = observation.getObservationConstellation().getObservationType();
    assertThat(type, is(equalTo(OmConstants.OBS_TYPE_GEOMETRY_OBSERVATION)));
    final ObservationValue<?> value = observation.getValue();
    assertThat(value, is(instanceOf(SingleObservationValue.class)));
    assertThat(value.getPhenomenonTime(), is(instanceOf(TimeInstant.class)));
    TimeInstant pt = (TimeInstant) value.getPhenomenonTime();
    assertThat(pt.getValue(), is(equalTo(phenomenonTime)));
    assertThat(value.getValue(), is(instanceOf(GeometryValue.class)));
    GeometryValue v = (GeometryValue) value.getValue();
    assertThat(v.getUnit(), is(nullValue()));
    Geometry g = v.getValue();
    assertThat(g, is(instanceOf(LineString.class)));
    assertThat(g.getSRID(), is(2000));
    assertThat(g.getNumPoints(), is(2));
    assertThat(g.getCoordinates()[0], is(equalTo(new Coordinate(52, 7))));
    assertThat(g.getCoordinates()[1], is(equalTo(new Coordinate(51, 7))));
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) GeometryValue(org.n52.shetland.ogc.om.values.GeometryValue) Coordinate(org.locationtech.jts.geom.Coordinate) LineString(org.locationtech.jts.geom.LineString) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) Test(org.junit.Test)

Example 25 with TimeInstant

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

the class OmDecoderv20 method getResultTime.

private TimeInstant getResultTime(OMObservationType omObservation) throws DecodingException {
    if (omObservation.getResultTime().isSetHref()) {
        TimeInstant timeInstant = new TimeInstant();
        timeInstant.setGmlId(omObservation.getResultTime().getHref());
        if (omObservation.getResultTime().getHref().charAt(0) == '#') {
            // document internal link
            // TODO parse linked element
            timeInstant.setReference(Sos2Constants.EN_PHENOMENON_TIME);
        } else {
            timeInstant.setReference(omObservation.getResultTime().getHref());
        }
        return timeInstant;
    } else if (omObservation.getResultTime().isSetNilReason() && omObservation.getResultTime().getNilReason() instanceof String && NilReason.template.equals(NilReason.getEnumForString((String) omObservation.getResultTime().getNilReason()))) {
        TimeInstant timeInstant = new TimeInstant();
        timeInstant.setNilReason(NilReason.getEnumForString((String) omObservation.getResultTime().getNilReason()));
        return timeInstant;
    } else if (omObservation.getResultTime().isSetTimeInstant()) {
        Object decodedObject = decodeXmlObject(omObservation.getResultTime().getTimeInstant());
        if (decodedObject instanceof TimeInstant) {
            return (TimeInstant) decodedObject;
        }
        throw unsupportedResultTimeType();
    } else {
        throw unsupportedResultTimeType();
    }
}
Also used : XmlObject(org.apache.xmlbeans.XmlObject) XmlString(org.apache.xmlbeans.XmlString) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant)

Aggregations

TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)38 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)16 Time (org.n52.shetland.ogc.gml.time.Time)13 DateTime (org.joda.time.DateTime)12 OmObservation (org.n52.shetland.ogc.om.OmObservation)12 Test (org.junit.Test)9 XmlObject (org.apache.xmlbeans.XmlObject)7 DecodingException (org.n52.svalbard.decode.exception.DecodingException)5 EncodingException (org.n52.svalbard.encode.exception.EncodingException)5 EReportingHeader (org.n52.shetland.aqd.EReportingHeader)4 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)4 XmlString (org.apache.xmlbeans.XmlString)3 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)3 FeatureCollection (org.n52.shetland.ogc.om.features.FeatureCollection)3 OwsExceptionReport (org.n52.shetland.ogc.ows.exception.OwsExceptionReport)3 URI (java.net.URI)2 Date (java.util.Date)2 XmlCursor (org.apache.xmlbeans.XmlCursor)2 EReportingChange (org.n52.shetland.aqd.EReportingChange)2 GeographicalName (org.n52.shetland.inspire.GeographicalName)2