Search in sources :

Example 6 with Time

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

the class TimeTest method inteterminate.

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

Example 7 with Time

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

the class TimeTest method nullFormat.

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

Example 8 with Time

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

the class SweHelper method getPhenomenonTimeField.

private SweField getPhenomenonTimeField(Time sosTime) {
    SweAbstractUomType<?> time;
    if (sosTime instanceof TimePeriod) {
        time = new SweTimeRange();
    } else {
        time = new SweTime();
    }
    time.setDefinition(OmConstants.PHENOMENON_TIME);
    time.setUom(OmConstants.PHEN_UOM_ISO8601);
    return new SweField(OmConstants.PHENOMENON_TIME_NAME, time);
}
Also used : SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) SweField(org.n52.shetland.ogc.swe.SweField) TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange)

Example 9 with Time

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

the class TimeJSONEncoder method encodeJSON.

@Override
public JsonNode encodeJSON(Time time) {
    if (time instanceof TimeInstant) {
        TimeInstant ti = (TimeInstant) time;
        return nodeFactory().textNode(encodeTimePosition(ti.getTimePosition()));
    }
    if (time instanceof TimePeriod) {
        TimePeriod tp = (TimePeriod) time;
        ArrayNode a = nodeFactory().arrayNode();
        a.add(encodeTimePosition(tp.getStartTimePosition()));
        a.add(encodeTimePosition(tp.getEndTimePosition()));
        return a;
    } else {
        return null;
    }
}
Also used : TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant)

Example 10 with Time

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

the class FieldDecoderTest method time.

@Test
public void time() throws DecodingException {
    ObjectNode json = createField().put(JSONConstants.TYPE, JSONConstants.TIME_TYPE).put(JSONConstants.UOM, UOM);
    SweField field = checkCommon(json, false);
    assertThat(field.getElement(), is(instanceOf(SweTime.class)));
    SweTime swe = (SweTime) field.getElement();
    errors.checkThat(swe.getValue(), is(nullValue()));
    errors.checkThat(swe.getUom(), is(UOM));
}
Also used : SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SweField(org.n52.shetland.ogc.swe.SweField) Test(org.junit.Test)

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