Search in sources :

Example 1 with OMObservationType

use of net.opengis.om.x20.OMObservationType in project arctic-sea by 52North.

the class OmDecoderv20 method getPhenomenonTime.

private Time getPhenomenonTime(OMObservationType omObservation) throws DecodingException {
    TimeObjectPropertyType phenomenonTime = omObservation.getPhenomenonTime();
    if (phenomenonTime.isSetHref() && phenomenonTime.getHref().startsWith("#")) {
        TimeInstant timeInstant = new TimeInstant();
        timeInstant.setGmlId(phenomenonTime.getHref());
        return timeInstant;
    } else if (phenomenonTime.isSetNilReason() && phenomenonTime.getNilReason() instanceof String && ((String) phenomenonTime.getNilReason()).equals(IndeterminateValue.TEMPLATE.getValue())) {
        return new TimeInstant(IndeterminateValue.TEMPLATE);
    } else if (phenomenonTime.isSetAbstractTimeObject()) {
        Object decodedObject = decodeXmlObject(phenomenonTime.getAbstractTimeObject());
        if (decodedObject instanceof Time) {
            return (Time) decodedObject;
        }
    // FIXME else
    }
    throw new DecodingException(Sos2Constants.InsertObservationParams.observation, "The requested phenomenonTime type is not supported by this service!");
}
Also used : TimeObjectPropertyType(net.opengis.om.x20.TimeObjectPropertyType) XmlObject(org.apache.xmlbeans.XmlObject) Time(org.n52.shetland.ogc.gml.time.Time) DecodingException(org.n52.svalbard.decode.exception.DecodingException) XmlString(org.apache.xmlbeans.XmlString) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant)

Example 2 with OMObservationType

use of net.opengis.om.x20.OMObservationType in project arctic-sea by 52North.

the class AbstractOmEncoderv20 method encodeOmObservation.

/**
 * Method to create an O&M 2.0 observation XmlBeans object
 *
 * @param sosObservation
 *            SosObservation to be encoded
 * @param context
 *            Additional values which are used during the encoding
 * @return XmlBeans representation of O&M 2.0 observation
 * @throws EncodingException
 *             If an error occurs
 */
protected XmlObject encodeOmObservation(OmObservation sosObservation, EncodingContext context) throws EncodingException {
    OMObservationType xbObservation = createOmObservationType();
    if (!sosObservation.isSetObservationID()) {
        sosObservation.setObservationID(JavaHelper.generateID(Double.toString(System.currentTimeMillis() * Math.random())));
    }
    String observationID = sosObservation.getObservationID();
    if (!sosObservation.isSetGmlID()) {
        sosObservation.setGmlId(OBSERVATION_ID_PREFIX + observationID);
    }
    // set a unique gml:id
    xbObservation.setId(generateObservationGMLId());
    if (!sosObservation.isSetObservationID()) {
        sosObservation.setObservationID(xbObservation.getId().replace(OBSERVATION_ID_PREFIX, ""));
    }
    setObservationIdentifier(sosObservation, xbObservation);
    setObservationName(sosObservation, xbObservation);
    setDescription(sosObservation, xbObservation);
    setMetaDataProperty(sosObservation, xbObservation);
    setObservationType(sosObservation, xbObservation);
    setRelatedObservations(sosObservation, xbObservation);
    setPhenomenonTime(sosObservation, xbObservation);
    setResultTime(sosObservation, xbObservation);
    setValidTime(sosObservation, xbObservation);
    setProcedure(sosObservation, xbObservation);
    setParameter(sosObservation, xbObservation);
    setObservableProperty(sosObservation, xbObservation);
    setFeatureOfInterest(sosObservation, xbObservation);
    setResultQualities(xbObservation, sosObservation);
    setResult(sosObservation, xbObservation);
    addAddtitionalInformation(xbObservation, sosObservation);
    if (context.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
        return createObservationPropertyType(xbObservation);
    } else if (context.has(XmlBeansEncodingFlags.DOCUMENT)) {
        return createObservationDocument(xbObservation);
    } else {
        return xbObservation;
    }
}
Also used : OMObservationType(net.opengis.om.x20.OMObservationType) XmlString(org.apache.xmlbeans.XmlString)

Example 3 with OMObservationType

use of net.opengis.om.x20.OMObservationType in project arctic-sea by 52North.

the class AbstractOmEncoderv20 method createObservationDocument.

private XmlObject createObservationDocument(OMObservationType xbObservation) {
    OMObservationDocument doc = createObservationDocument();
    doc.setOMObservation(xbObservation);
    return doc;
}
Also used : OMObservationDocument(net.opengis.om.x20.OMObservationDocument)

Example 4 with OMObservationType

use of net.opengis.om.x20.OMObservationType in project arctic-sea by 52North.

the class AbstractOmEncoderv20 method createObservationPropertyType.

private XmlObject createObservationPropertyType(OMObservationType obs) {
    OMObservationPropertyType opt = createObservationPropertyType();
    opt.setOMObservation(obs);
    return opt;
}
Also used : OMObservationPropertyType(net.opengis.om.x20.OMObservationPropertyType)

Example 5 with OMObservationType

use of net.opengis.om.x20.OMObservationType in project arctic-sea by 52North.

the class OmEncoderv20 method addProcedure.

private void addProcedure(OMObservationType xbObservationTemplate, Nillable<AbstractFeature> procedure) {
    OMProcessPropertyType xbProcedure = xbObservationTemplate.addNewProcedure();
    if (procedure.isNil() || procedure.isAbsent() || !procedure.get().isSetIdentifier()) {
        xbProcedure.setNil();
        xbProcedure.setNilReason(NIL_REASON_TEMPLATE);
    } else {
        xbProcedure.setHref(procedure.get().getIdentifier());
    }
}
Also used : OMProcessPropertyType(net.opengis.om.x20.OMProcessPropertyType)

Aggregations

OMObservationType (net.opengis.om.x20.OMObservationType)7 Test (org.junit.Test)5 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)4 OmObservationConstellation (org.n52.shetland.ogc.om.OmObservationConstellation)4 XmlObject (org.apache.xmlbeans.XmlObject)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 TimeObjectPropertyType (net.opengis.om.x20.TimeObjectPropertyType)2 SFSamplingFeatureDocument (net.opengis.sampling.x20.SFSamplingFeatureDocument)2 SFSamplingFeatureType (net.opengis.sampling.x20.SFSamplingFeatureType)2 XmlString (org.apache.xmlbeans.XmlString)2 OMObservationDocument (net.opengis.om.x20.OMObservationDocument)1 OMObservationPropertyType (net.opengis.om.x20.OMObservationPropertyType)1 OMProcessPropertyType (net.opengis.om.x20.OMProcessPropertyType)1 InsertResultTemplateDocument (net.opengis.sos.x20.InsertResultTemplateDocument)1 InsertResultTemplateType (net.opengis.sos.x20.InsertResultTemplateType)1 ResultTemplateType (net.opengis.sos.x20.ResultTemplateType)1 ObservationTemplate (net.opengis.sos.x20.ResultTemplateType.ObservationTemplate)1 CodeType (org.n52.shetland.ogc.gml.CodeType)1 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)1 Time (org.n52.shetland.ogc.gml.time.Time)1