Search in sources :

Example 11 with ObservationValue

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

the class WmlTVPEncoderv20 method addValues.

private String addValues(MeasurementTimeseriesType measurementTimeseries, ObservationValue<?> observationValue) throws CodedException {
    String unit = null;
    if (observationValue instanceof SingleObservationValue) {
        SingleObservationValue<?> singleObservationValue = (SingleObservationValue<?>) observationValue;
        String time = getTimeString(singleObservationValue.getPhenomenonTime());
        unit = singleObservationValue.getValue().getUnit();
        String value = null;
        if (singleObservationValue.getValue() instanceof QuantityValue) {
            QuantityValue quantityValue = (QuantityValue) singleObservationValue.getValue();
            if (quantityValue.isSetValue()) {
                value = quantityValue.getValue().toPlainString();
            }
        } else if (singleObservationValue.getValue() instanceof CountValue) {
            CountValue countValue = (CountValue) singleObservationValue.getValue();
            if (countValue.getValue() != null) {
                value = Integer.toString(countValue.getValue());
            }
        } else if (singleObservationValue.getValue() instanceof ProfileValue) {
            ProfileValue profileValue = (ProfileValue) singleObservationValue.getValue();
            if (profileValue.isSetValue()) {
                if (profileValue.getValue().iterator().next().getSimpleValue() instanceof QuantityValue) {
                    QuantityValue quantityValue = (QuantityValue) profileValue.getValue().iterator().next().getSimpleValue();
                    if (quantityValue.isSetValue()) {
                        value = Double.toString(quantityValue.getValue().doubleValue());
                    }
                }
            }
        }
        addValuesToMeasurementTVP(measurementTimeseries.addNewPoint().addNewMeasurementTVP(), time, value);
    } else if (observationValue instanceof MultiObservationValues) {
        MultiObservationValues<?> mov = (MultiObservationValues<?>) observationValue;
        TVPValue tvpValue = (TVPValue) mov.getValue();
        List<TimeValuePair> timeValuePairs = tvpValue.getValue();
        unit = tvpValue.getUnit();
        for (TimeValuePair timeValuePair : timeValuePairs) {
            String time = getTimeString(timeValuePair.getTime());
            String value = null;
            if (timeValuePair.getValue() instanceof QuantityValue) {
                QuantityValue quantityValue = (QuantityValue) timeValuePair.getValue();
                if (quantityValue.isSetValue()) {
                    value = quantityValue.getValue().toPlainString();
                }
            } else if (timeValuePair.getValue() instanceof ProfileValue) {
                ProfileValue profileValue = (ProfileValue) timeValuePair.getValue();
                if (profileValue.isSetValue()) {
                    if (profileValue.getValue().iterator().next().getSimpleValue() instanceof QuantityValue) {
                        QuantityValue quantityValue = (QuantityValue) profileValue.getValue().iterator().next().getSimpleValue();
                        if (quantityValue.isSetValue()) {
                            value = Double.toString(quantityValue.getValue().doubleValue());
                        }
                    }
                }
            } else if (timeValuePair.getValue() instanceof CountValue) {
                CountValue countValue = (CountValue) timeValuePair.getValue();
                if (countValue.isSetValue()) {
                    value = Integer.toString(countValue.getValue());
                }
            } else {
                throw new NoApplicableCodeException().withMessage("The types of values '%s' is not yet supported", mov.getValue().getClass().getSimpleName());
            }
            addValuesToMeasurementTVP(measurementTimeseries.addNewPoint().addNewMeasurementTVP(), time, value);
        }
    }
    return unit;
}
Also used : SingleObservationValue(org.n52.shetland.ogc.om.SingleObservationValue) TVPValue(org.n52.shetland.ogc.om.values.TVPValue) CountValue(org.n52.shetland.ogc.om.values.CountValue) QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue) NoApplicableCodeException(org.n52.shetland.ogc.ows.exception.NoApplicableCodeException) List(java.util.List) MultiObservationValues(org.n52.shetland.ogc.om.MultiObservationValues) ProfileValue(org.n52.shetland.ogc.om.values.ProfileValue) TimeValuePair(org.n52.shetland.ogc.om.TimeValuePair)

Example 12 with ObservationValue

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

the class WmlTVPEncoderv20XmlStreamWriter method writeInterpolationType.

/**
 * Write wml:interpolationType to stream
 *
 * @throws XMLStreamException
 *             If an error occurs when writing to stream
 */
private void writeInterpolationType(ObservationValue<?> value) throws XMLStreamException {
    empty(WaterMLConstants.QN_INTERPOLATION_TYPE);
    if (value != null && value.isSetMetadata() && value.getDefaultPointMetadata().isSetDefaultTVPMeasurementMetadata() && value.getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().isSetInterpolationType()) {
        InterpolationType interpolationtype = value.getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().getInterpolationtype();
        addXlinkHrefAttr(interpolationtype.getIdentifier());
        addXlinkTitleAttr(interpolationtype.getTitle());
    } else {
        addXlinkHrefAttr("http://www.opengis.net/def/timeseriesType/WaterML/2.0/continuous");
        addXlinkTitleAttr("Instantaneous");
    }
}
Also used : InterpolationType(org.n52.shetland.ogc.om.series.wml.WaterMLConstants.InterpolationType)

Example 13 with ObservationValue

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

the class TrajectoryObservation method mergeValues.

protected boolean mergeValues(ObservationValue<?> observationValue) {
    if (observationValue.getValue() instanceof TLVTValue) {
        TLVTValue tlvtValue = (TLVTValue) observationValue.getValue();
        List<TimeLocationValueTriple> valuesToMerge = tlvtValue.getValue();
        // List<TimeLocationValueTriple> valuesToMerge =
        // (List<TimeLocationValueTriple>)((TLVTValue)observationValue.getValue()).getValue();
        ((TLVTValue) getValue().getValue()).addValues(valuesToMerge);
        checkForFeature(valuesToMerge);
        return true;
    } else {
        return super.mergeValues(observationValue);
    }
}
Also used : TLVTValue(org.n52.shetland.ogc.om.values.TLVTValue) TimeLocationValueTriple(org.n52.shetland.ogc.om.TimeLocationValueTriple)

Example 14 with ObservationValue

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

the class MultiPointObservation method setValue.

@Override
public void setValue(ObservationValue<?> value) {
    if (value.getValue() instanceof MultiPointCoverage) {
        super.setValue(value);
    } else {
        MultiPointCoverage multiPointCoverage = new MultiPointCoverage(getObservationID());
        multiPointCoverage.setUnit(((AbstractObservationValue<?>) value).getUnit());
        multiPointCoverage.addValue(new PointValuePair(getPoint(), value.getValue()));
        super.setValue(new SingleObservationValue<>(value.getPhenomenonTime(), multiPointCoverage));
    }
}
Also used : MultiPointCoverage(org.n52.shetland.ogc.om.values.MultiPointCoverage) PointValuePair(org.n52.shetland.ogc.om.PointValuePair)

Example 15 with ObservationValue

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

the class PointObservation method setValue.

@Override
public void setValue(ObservationValue<?> value) {
    if (value instanceof StreamingValue<?>) {
        super.setValue(value);
    } else if (value.getValue() instanceof CvDiscretePointCoverage) {
        super.setValue(value);
    } else {
        CvDiscretePointCoverage cvDiscretePointCoverage = new CvDiscretePointCoverage(getObservationID());
        cvDiscretePointCoverage.setRangeType(new ReferenceType(getObservationConstellation().getObservablePropertyIdentifier()));
        cvDiscretePointCoverage.setUnit(((AbstractObservationValue<?>) value).getUnit());
        Geometry geometry = null;
        String domainExtent = "";
        if (isSetSpatialFilteringProfileParameter() && getSpatialFilteringProfileParameter().getValue() instanceof GeometryValue) {
            GeometryValue geometryValue = (GeometryValue) getSpatialFilteringProfileParameter().getValue();
            geometry = getSpatialFilteringProfileParameter().getValue().getValue();
            domainExtent = geometryValue.getGmlId();
        } else if (checkForFeatureGeometry(this)) {
            geometry = getGeometryFromFeature(this);
            domainExtent = getObservationConstellation().getFeatureOfInterest().getGmlId();
        }
        if (geometry != null) {
            cvDiscretePointCoverage.setDomainExtent("#" + geometry.getGeometryType() + "_" + domainExtent);
            Point point = null;
            if (geometry instanceof Point) {
                point = (Point) geometry;
            } else {
                point = geometry.getCentroid();
            }
            cvDiscretePointCoverage.setValue(new PointValuePair(point, value.getValue()));
        }
        super.setValue(new SingleObservationValue<>(value.getPhenomenonTime(), cvDiscretePointCoverage));
    }
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) CvDiscretePointCoverage(org.n52.shetland.ogc.om.values.CvDiscretePointCoverage) AbstractObservationValue(org.n52.shetland.ogc.om.AbstractObservationValue) GeometryValue(org.n52.shetland.ogc.om.values.GeometryValue) SingleObservationValue(org.n52.shetland.ogc.om.SingleObservationValue) StreamingValue(org.n52.shetland.ogc.om.StreamingValue) Point(org.locationtech.jts.geom.Point) ReferenceType(org.n52.shetland.ogc.gml.ReferenceType) PointValuePair(org.n52.shetland.ogc.om.PointValuePair)

Aggregations

MultiObservationValues (org.n52.shetland.ogc.om.MultiObservationValues)9 SingleObservationValue (org.n52.shetland.ogc.om.SingleObservationValue)9 Test (org.junit.Test)7 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)7 QuantityValue (org.n52.shetland.ogc.om.values.QuantityValue)6 List (java.util.List)5 TimeValuePair (org.n52.shetland.ogc.om.TimeValuePair)5 TVPValue (org.n52.shetland.ogc.om.values.TVPValue)5 Geometry (org.locationtech.jts.geom.Geometry)4 StreamingValue (org.n52.shetland.ogc.om.StreamingValue)4 TimeLocationValueTriple (org.n52.shetland.ogc.om.TimeLocationValueTriple)4 CountValue (org.n52.shetland.ogc.om.values.CountValue)4 GeometryValue (org.n52.shetland.ogc.om.values.GeometryValue)4 TVPDefaultMetadataPropertyType (net.opengis.waterml.x20.TVPDefaultMetadataPropertyType)3 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)3 BooleanValue (org.n52.shetland.ogc.om.values.BooleanValue)3 TLVTValue (org.n52.shetland.ogc.om.values.TLVTValue)3 SweDataArray (org.n52.shetland.ogc.swe.SweDataArray)3 MeasureOrNilReasonListType (net.opengis.gml.x32.MeasureOrNilReasonListType)2 QuantityListDocument (net.opengis.gml.x32.QuantityListDocument)2