Search in sources :

Example 1 with TimePositionType

use of net.opengis.gml.TimePositionType in project arctic-sea by 52North.

the class GmlDecoderv311 method parseTimePeriod.

private Object parseTimePeriod(TimePeriodType xbTimePeriod) throws DecodingException {
    // begin position
    TimePositionType xbBeginTPT = xbTimePeriod.getBeginPosition();
    TimeInstant begin = null;
    if (xbBeginTPT != null) {
        begin = parseTimePosition(xbBeginTPT);
    } else {
        throw new DecodingException("gml:TimePeriod must contain gml:beginPosition Element with valid ISO:8601 String!");
    }
    // end position
    TimePositionType xbEndTPT = xbTimePeriod.getEndPosition();
    TimeInstant end = null;
    if (xbEndTPT != null) {
        end = parseTimePosition(xbEndTPT);
    } else {
        throw new DecodingException("gml:TimePeriod must contain gml:endPosition Element with valid ISO:8601 String!");
    }
    TimePeriod timePeriod = new TimePeriod(begin, end);
    timePeriod.setGmlId(xbTimePeriod.getId());
    return timePeriod;
}
Also used : TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) DecodingException(org.n52.svalbard.decode.exception.DecodingException) TimePositionType(net.opengis.gml.TimePositionType) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant)

Example 2 with TimePositionType

use of net.opengis.gml.TimePositionType in project arctic-sea by 52North.

the class GmlEncoderv311 method createTimePositionType.

private TimePositionType createTimePositionType(final TimePosition timePosition) throws DateTimeFormatException {
    final TimePositionType xbTimePosition = TimePositionType.Factory.newInstance();
    if (!timePosition.isSetTime()) {
        if (timePosition.isSetIndeterminateValue()) {
            xbTimePosition.setIndeterminatePosition(TimeIndeterminateValueType.Enum.forString(timePosition.getIndeterminateValue().getValue()));
        } else {
            xbTimePosition.setIndeterminatePosition(TimeIndeterminateValueType.Enum.forString(IndeterminateValue.UNKNOWN.getValue()));
        }
    } else {
        final String endString = DateTimeHelper.formatDateTime2String(timePosition.getTime(), timePosition.getTimeFormat());
        // concat minutes for timeZone offset, because gml requires
        // xs:dateTime, which needs minutes in
        // timezone offset
        // TODO enable really
        xbTimePosition.setStringValue(endString);
    }
    return xbTimePosition;
}
Also used : LineString(org.locationtech.jts.geom.LineString) TimePositionType(net.opengis.gml.TimePositionType)

Aggregations

TimePositionType (net.opengis.gml.TimePositionType)2 LineString (org.locationtech.jts.geom.LineString)1 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)1 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)1 DecodingException (org.n52.svalbard.decode.exception.DecodingException)1