Search in sources :

Example 26 with TimePeriod

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

the class GetCapabilitiesResponseEncoder method encodeResultTime.

private void encodeResultTime(SosObservationOffering offering, int offeringCounter, ObservationOfferingType xbObsOff) throws EncodingException {
    // set resultTime [0..1]
    if (offering.getResultTime() instanceof TimePeriod) {
        TimePeriod tp = (TimePeriod) offering.getResultTime();
        tp.setGmlId(String.format(ID_FORMAT_STRING, Sos2Constants.EN_RESULT_TIME, offeringCounter));
        if (!tp.isEmpty()) {
            XmlObject xmlObject = encodeGml(tp);
            xbObsOff.addNewResultTime().addNewTimePeriod().set(xmlObject);
            xbObsOff.getResultTime().substitute(Sos2Constants.QN_SOS_RESULT_TIME, xbObsOff.getResultTime().schemaType());
        }
    }
}
Also used : TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) XmlObject(org.apache.xmlbeans.XmlObject)

Example 27 with TimePeriod

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

the class GetCapabilitiesResponseEncoder method encodePhenomenonTime.

private void encodePhenomenonTime(SosObservationOffering offering, int offeringCounter, ObservationOfferingType xbObsOff) throws EncodingException {
    // set up phenomenon time [0..1]
    if (offering.getPhenomenonTime() instanceof TimePeriod) {
        TimePeriod tp = (TimePeriod) offering.getPhenomenonTime();
        if (!tp.isEmpty()) {
            tp.setGmlId(String.format(ID_FORMAT_STRING, Sos2Constants.EN_PHENOMENON_TIME, offeringCounter));
            XmlObject xmlObject = encodeGml(tp);
            xbObsOff.addNewPhenomenonTime().addNewTimePeriod().set(xmlObject);
            xbObsOff.getPhenomenonTime().substitute(Sos2Constants.QN_SOS_PHENOMENON_TIME, xbObsOff.getPhenomenonTime().schemaType());
        }
    }
}
Also used : TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) XmlObject(org.apache.xmlbeans.XmlObject)

Example 28 with TimePeriod

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

the class FesEncoderv20 method encodeTemporalFilterDuring.

private XmlObject encodeTemporalFilterDuring(TemporalFilter temporalFilter) throws EncodingException {
    final DuringDocument duringDoc = DuringDocument.Factory.newInstance(getXmlOptions());
    final BinaryTemporalOpType during = duringDoc.addNewDuring();
    if (temporalFilter.getTime() instanceof TimePeriod) {
        during.set(encodeObjectToXml(GmlConstants.NS_GML_32, temporalFilter.getTime(), EncodingContext.of(XmlBeansEncodingFlags.DOCUMENT)));
    } else {
        throw new EncodingException("The temporal filter value is not a TimePeriod!");
    }
    checkAndAddValueReference(during, temporalFilter);
    return duringDoc;
}
Also used : EncodingException(org.n52.svalbard.encode.exception.EncodingException) TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) DuringDocument(net.opengis.fes.x20.DuringDocument) BinaryTemporalOpType(net.opengis.fes.x20.BinaryTemporalOpType)

Example 29 with TimePeriod

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

the class AbstractOmEncoderv20 method addResultTime.

/**
 * Method to add the result time to the XML observation object
 *
 * @param xbObs
 *            XML observation object
 * @param sosObservation
 *            SOS observation object
 * @throws EncodingException
 *             If an error occurs.
 */
private void addResultTime(OMObservationType xbObs, OmObservation sosObservation) throws EncodingException {
    TimeInstant resultTime = sosObservation.getResultTime();
    Time phenomenonTime = sosObservation.getPhenomenonTime();
    // get result time from SOS result time representation
    if (sosObservation.getResultTime() != null) {
        if (resultTime.equals(phenomenonTime)) {
            xbObs.addNewResultTime().setHref("#" + phenomenonTime.getGmlId());
        } else {
            addResultTime(xbObs, resultTime);
        }
    } else {
        // representation
        if (phenomenonTime instanceof TimeInstant) {
            xbObs.addNewResultTime().setHref("#" + phenomenonTime.getGmlId());
        } else if (phenomenonTime instanceof TimePeriod) {
            TimeInstant rsTime = new TimeInstant(((TimePeriod) sosObservation.getPhenomenonTime()).getEnd());
            addResultTime(xbObs, rsTime);
        }
    }
}
Also used : TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) Time(org.n52.shetland.ogc.gml.time.Time) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant)

Example 30 with TimePeriod

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

the class AbstractAqdResponseEncoder method processObservation.

protected void processObservation(OmObservation observation, TimePeriod timePeriod, TimeInstant resultTime, FeatureCollection featureCollection, AbstractEReportingHeader eReportingHeader, int counter) {
    if (observation.isSetPhenomenonTime()) {
        // generate gml:id
        observation.setGmlId(getObservationId(counter));
        // add xlink:href to eReportingHeader.content
        eReportingHeader.addContent((AbstractFeature) new OmObservation().setIdentifier(new CodeWithAuthority(getObservationXlink(observation.getGmlId()))));
        timePeriod.extendToContain(observation.getPhenomenonTime());
        observation.setResultTime(resultTime);
        featureCollection.addMember(observation);
    }
}
Also used : OmObservation(org.n52.shetland.ogc.om.OmObservation) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority)

Aggregations

TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)33 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)16 DateTime (org.joda.time.DateTime)13 Time (org.n52.shetland.ogc.gml.time.Time)12 OmObservation (org.n52.shetland.ogc.om.OmObservation)10 EncodingException (org.n52.svalbard.encode.exception.EncodingException)8 XmlObject (org.apache.xmlbeans.XmlObject)7 Test (org.junit.Test)4 EReportingHeader (org.n52.shetland.aqd.EReportingHeader)3 ReferenceType (org.n52.shetland.ogc.gml.ReferenceType)3 FeatureCollection (org.n52.shetland.ogc.om.features.FeatureCollection)3 OwsExceptionReport (org.n52.shetland.ogc.ows.exception.OwsExceptionReport)3 DataAvailability (org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.DataAvailability)3 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)3 SweField (org.n52.shetland.ogc.swe.SweField)3 SweTime (org.n52.shetland.ogc.swe.simpleType.SweTime)3 DecodingException (org.n52.svalbard.decode.exception.DecodingException)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)2 GetObservationRequest (org.n52.shetland.ogc.sos.request.GetObservationRequest)2