Search in sources :

Example 46 with OmObservation

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

the class AqdEncoder 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)

Example 47 with OmObservation

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

the class AbstractOmEncoderv20 method setPhenomenonTime.

private void setPhenomenonTime(OmObservation observation, OMObservationType xb) throws EncodingException {
    // set validTime
    Time phenomenonTime = observation.getPhenomenonTime();
    if (phenomenonTime.getGmlId() == null) {
        phenomenonTime.setGmlId(OmConstants.PHENOMENON_TIME_NAME + "_" + observation.getObservationID());
    }
    addPhenomenonTime(xb.addNewPhenomenonTime(), phenomenonTime);
}
Also used : Time(org.n52.shetland.ogc.gml.time.Time)

Example 48 with OmObservation

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

the class AbstractOmEncoderv20 method setObservationName.

private void setObservationName(OmObservation observation, OMObservationType xb) throws EncodingException {
    // set observation identifier if available
    if (observation.isSetIdentifier()) {
        for (CodeType name : observation.getName()) {
            XmlObject xbId = encodeGML(name);
            xb.addNewName().set(xbId);
        }
    }
}
Also used : CodeType(org.n52.shetland.ogc.gml.CodeType) XmlObject(org.apache.xmlbeans.XmlObject)

Example 49 with OmObservation

use of org.n52.shetland.ogc.om.OmObservation 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 50 with OmObservation

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

the class ObservationEncoder method encodeTVPValue.

private JsonNode encodeTVPValue(OmObservation o) throws EncodingException {
    TVPValue tvpValue = (TVPValue) o.getValue().getValue();
    ObjectNode result = nodeFactory().objectNode();
    List<TimeValuePair> values = tvpValue.getValue();
    if (values != null && !values.isEmpty()) {
        String obsProp = o.getObservationConstellation().getObservableProperty().getIdentifier();
        SweTime timeDef = new SweTime();
        timeDef.setDefinition(OmConstants.PHENOMENON_TIME);
        timeDef.setUom(OmConstants.PHEN_UOM_ISO8601);
        SweField timeField = new SweField(OmConstants.PHENOMENON_TIME_NAME, timeDef);
        SweField valueField = getFieldForValue(obsProp, values.get(0).getValue());
        result.putArray(JSONConstants.FIELDS).add(encodeObjectToJson(timeField)).add(encodeObjectToJson(valueField));
        ArrayNode jvalues = result.putArray(JSONConstants.VALUES);
        for (TimeValuePair tvp : values) {
            if (tvp != null && tvp.getValue() != null && tvp.getValue().isSetValue()) {
                jvalues.addArray().add(encodeObjectToJson(tvp.getTime())).add(getTokenForValue(tvp.getValue()));
            }
        }
    }
    return result;
}
Also used : SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) TVPValue(org.n52.shetland.ogc.om.values.TVPValue) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SweField(org.n52.shetland.ogc.swe.SweField) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) TimeValuePair(org.n52.shetland.ogc.om.TimeValuePair)

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