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)));
}
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()));
}
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/")));
}
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))));
}
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();
}
}
Aggregations