Search in sources :

Example 41 with OmObservation

use of org.n52.shetland.ogc.om.OmObservation in project arctic-sea by 52North.

the class TrajectoryObservation method cloneTemplate.

@Override
public OmObservation cloneTemplate() {
    SamplingFeature sf = new SamplingFeature(new CodeWithAuthority(""));
    sf.setFeatureType(SfConstants.SAMPLING_FEAT_TYPE_SF_SAMPLING_CURVE);
    getObservationConstellation().setFeatureOfInterest(sf);
    if (isSetSpatialFilteringProfileParameter()) {
        removeSpatialFilteringProfileParameter();
    }
    return cloneTemplate(new TrajectoryObservation());
}
Also used : SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) AbstractSamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority)

Example 42 with OmObservation

use of org.n52.shetland.ogc.om.OmObservation in project arctic-sea by 52North.

the class OmObservation method mergeValues.

private void mergeValues(OmObservation merged, OmObservation observation) {
    SweDataArray combinedValue = (SweDataArray) merged.getValue().getValue().getValue();
    SweDataArray v = (SweDataArray) observation.getValue().getValue().getValue();
    if (v.isSetValues()) {
        combinedValue.addAll(v.getValues());
    }
}
Also used : SweDataArray(org.n52.shetland.ogc.swe.SweDataArray)

Example 43 with OmObservation

use of org.n52.shetland.ogc.om.OmObservation in project arctic-sea by 52North.

the class OmDecoderv20 method getResultTime.

private TimeInstant getResultTime(OMObservationType omObservation) throws DecodingException {
    if (omObservation.getResultTime().isSetHref()) {
        TimeInstant timeInstant = new TimeInstant();
        timeInstant.setGmlId(omObservation.getResultTime().getHref());
        if (omObservation.getResultTime().getHref().charAt(0) == '#') {
            // document internal link
            // TODO parse linked element
            timeInstant.setReference(Sos2Constants.EN_PHENOMENON_TIME);
        } else {
            timeInstant.setReference(omObservation.getResultTime().getHref());
        }
        return timeInstant;
    } else if (omObservation.getResultTime().isSetNilReason() && omObservation.getResultTime().getNilReason() instanceof String && NilReason.template.equals(NilReason.getEnumForString((String) omObservation.getResultTime().getNilReason()))) {
        TimeInstant timeInstant = new TimeInstant();
        timeInstant.setNilReason(NilReason.getEnumForString((String) omObservation.getResultTime().getNilReason()));
        return timeInstant;
    } else if (omObservation.getResultTime().isSetTimeInstant()) {
        Object decodedObject = decodeXmlObject(omObservation.getResultTime().getTimeInstant());
        if (decodedObject instanceof TimeInstant) {
            return (TimeInstant) decodedObject;
        }
        throw unsupportedResultTimeType();
    } else {
        throw unsupportedResultTimeType();
    }
}
Also used : XmlObject(org.apache.xmlbeans.XmlObject) XmlString(org.apache.xmlbeans.XmlString) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant)

Example 44 with OmObservation

use of org.n52.shetland.ogc.om.OmObservation in project arctic-sea by 52North.

the class OmDecoderv20 method getObservationValue.

private ObservationValue<?> getObservationValue(OMObservationType omObservation) throws DecodingException {
    Time phenomenonTime = getPhenomenonTime(omObservation);
    ObservationValue<?> observationValue;
    if (!omObservation.getResult().getDomNode().hasChildNodes() && phenomenonTime.isSetNilReason() && phenomenonTime.getNilReason().equals(NilReason.template)) {
        observationValue = new SingleObservationValue<>(new NilTemplateValue());
    } else {
        observationValue = getResult(omObservation);
    }
    observationValue.setPhenomenonTime(phenomenonTime);
    return observationValue;
}
Also used : Time(org.n52.shetland.ogc.gml.time.Time) NilTemplateValue(org.n52.shetland.ogc.om.values.NilTemplateValue)

Example 45 with OmObservation

use of org.n52.shetland.ogc.om.OmObservation in project arctic-sea by 52North.

the class AbstractWmlEncoderv20 method createWmlGetObservationResponse.

/**
 * Encodes a SOS GetObservationResponse to a single WaterML 2.0 observation
 * or to a WaterML 1.0 ObservationCollection
 *
 * @param getObservationResonse
 *            SOS GetObservationResponse
 * @return Encoded response
 * @throws EncodingException
 *             If an error occurs
 */
protected XmlObject createWmlGetObservationResponse(GetObservationResponse getObservationResonse) throws EncodingException {
    // TODO: set schemaLocation if final
    Map<CodeWithAuthority, String> gmlID4sfIdentifier = Maps.newHashMap();
    int sfIdCounter = 1;
    try {
        if (getObservationResonse.getObservationCollection() != null && !getObservationResonse.getObservationCollection().hasNext()) {
            ObservationStream observations = getObservationResonse.getObservationCollection();
            OmObservation observation = observations.next();
            if (!observations.hasNext()) {
                OMObservationDocument omObservationDoc = OMObservationDocument.Factory.newInstance(getXmlOptions());
                omObservationDoc.setOMObservation(encodeObservation(observation, gmlID4sfIdentifier, sfIdCounter));
                sfIdCounter++;
                return omObservationDoc;
            } else {
                CollectionDocument xmlCollectionDoc = CollectionDocument.Factory.newInstance(getXmlOptions());
                CollectionType wmlCollection = xmlCollectionDoc.addNewCollection();
                wmlCollection.addNewObservationMember().setOMObservation(encodeObservation(observation, gmlID4sfIdentifier, sfIdCounter));
                sfIdCounter++;
                while (observations.hasNext()) {
                    wmlCollection.addNewObservationMember().setOMObservation(encodeObservation(observations.next(), gmlID4sfIdentifier, sfIdCounter));
                    sfIdCounter++;
                }
                return xmlCollectionDoc;
            }
        } else {
            // TODO: HydrologieProfile-Exception
            throw new EncodingException("Combination does not exists!");
        }
    } catch (NoSuchElementException | OwsExceptionReport e) {
        throw new EncodingException(e);
    }
}
Also used : EncodingException(org.n52.svalbard.encode.exception.EncodingException) CollectionDocument(net.opengis.waterml.x20.CollectionDocument) OmObservation(org.n52.shetland.ogc.om.OmObservation) OMObservationDocument(net.opengis.om.x20.OMObservationDocument) WmlMonitoringPoint(org.n52.shetland.ogc.om.series.wml.WmlMonitoringPoint) ObservationStream(org.n52.shetland.ogc.om.ObservationStream) CollectionType(net.opengis.waterml.x20.CollectionType) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport) NoSuchElementException(java.util.NoSuchElementException)

Aggregations

OmObservation (org.n52.shetland.ogc.om.OmObservation)32 XmlObject (org.apache.xmlbeans.XmlObject)17 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)16 Time (org.n52.shetland.ogc.gml.time.Time)15 EncodingException (org.n52.svalbard.encode.exception.EncodingException)14 DateTime (org.joda.time.DateTime)13 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)11 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)11 OwsExceptionReport (org.n52.shetland.ogc.ows.exception.OwsExceptionReport)10 XmlString (org.apache.xmlbeans.XmlString)9 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)9 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)9 MultiObservationValues (org.n52.shetland.ogc.om.MultiObservationValues)7 ObservationStream (org.n52.shetland.ogc.om.ObservationStream)7 SingleObservationValue (org.n52.shetland.ogc.om.SingleObservationValue)7 OmObservationConstellation (org.n52.shetland.ogc.om.OmObservationConstellation)6 SweDataArray (org.n52.shetland.ogc.swe.SweDataArray)6 List (java.util.List)5 SamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature)5 QuantityValue (org.n52.shetland.ogc.om.values.QuantityValue)5