Search in sources :

Example 1 with IndeterminateValue

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

the class GmlDecoderv311 method parseTimePosition.

private TimeInstant parseTimePosition(TimePositionType xbTimePosition) throws DecodingException {
    TimeInstant ti = new TimeInstant();
    String timeString = xbTimePosition.getStringValue();
    if (timeString != null && !timeString.isEmpty()) {
        try {
            // TODO better differnetiate between ISO8601 and an
            // indeterminate value
            DateTime dateTime = DateTimeHelper.parseIsoString2DateTime(timeString);
            ti.setValue(dateTime);
            ti.setRequestedTimeLength(DateTimeHelper.getTimeLengthBeforeTimeZone(timeString));
        } catch (DateTimeParseException ex) {
            ti.setIndeterminateValue(new IndeterminateValue(timeString));
        }
    }
    if (xbTimePosition.getIndeterminatePosition() != null) {
        ti.setIndeterminateValue(new IndeterminateValue(xbTimePosition.getIndeterminatePosition().toString()));
    }
    return ti;
}
Also used : DateTimeParseException(org.n52.shetland.util.DateTimeParseException) IndeterminateValue(org.n52.shetland.ogc.gml.time.IndeterminateValue) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) DateTime(org.joda.time.DateTime)

Example 2 with IndeterminateValue

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

the class GmlDecoderv321 method parseTimePosition.

private TimeInstant parseTimePosition(TimePositionType xbTimePosition) throws DecodingException {
    TimeInstant ti = new TimeInstant();
    String timeString = xbTimePosition.getStringValue();
    if (timeString != null && !timeString.isEmpty()) {
        try {
            // TODO better differentiate between ISO8601 and indeterminate
            // value
            ti.setValue(DateTimeHelper.parseIsoString2DateTime(timeString));
            ti.setRequestedTimeLength(DateTimeHelper.getTimeLengthBeforeTimeZone(timeString));
        } catch (DateTimeParseException ex) {
            ti.setIndeterminateValue(new IndeterminateValue(timeString));
        }
    }
    if (xbTimePosition.isSetIndeterminatePosition()) {
        ti.setIndeterminateValue(new IndeterminateValue(xbTimePosition.getIndeterminatePosition().toString()));
    }
    return ti;
}
Also used : DateTimeParseException(org.n52.shetland.util.DateTimeParseException) IndeterminateValue(org.n52.shetland.ogc.gml.time.IndeterminateValue) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant)

Aggregations

IndeterminateValue (org.n52.shetland.ogc.gml.time.IndeterminateValue)2 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)2 DateTimeParseException (org.n52.shetland.util.DateTimeParseException)2 DateTime (org.joda.time.DateTime)1