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