Search in sources :

Example 1 with SingleObservationValue

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

the class ProfileObservation method setValue.

@Override
public void setValue(ObservationValue<?> value) {
    if (value instanceof StreamingValue<?>) {
        super.setValue(value);
    } else if (value.getValue() instanceof RectifiedGridCoverage || value.getValue() instanceof ReferencableGridCoverage) {
        super.setValue(value);
    } else if (value.getValue() instanceof ProfileValue) {
        ProfileValue profile = (ProfileValue) value.getValue();
        RectifiedGridCoverage rectifiedGridCoverage = new RectifiedGridCoverage(getObservationID());
        rectifiedGridCoverage.setUnit(value.getValue().getUnit());
        rectifiedGridCoverage.setRangeParameters(getObservationConstellation().getObservablePropertyIdentifier());
        List<Coordinate> coordinates = Lists.newArrayList();
        int srid = 0;
        for (ProfileLevel level : profile.getValue()) {
            if (level.isSetLevelEnd()) {
                rectifiedGridCoverage.addValue(new QuantityRangeValue(level.getLevelStart().getValue(), level.getLevelEnd().getValue(), level.getLevelStart().getUnit()), level.getSimpleValue());
            } else {
                rectifiedGridCoverage.addValue(level.getLevelStart(), level.getSimpleValue());
            }
            if (level.isSetLocation()) {
                Coordinate coordinate = level.getLocation().getCoordinate();
                coordinate.z = level.getLevelStart().getValue().doubleValue();
                coordinates.add(coordinate);
                if (srid == 0) {
                    srid = level.getLocation().getSRID();
                }
            }
        }
        if (CollectionHelper.isNotEmpty(coordinates)) {
            setFeatureGeometry(coordinates, srid);
        }
        super.setValue(new SingleObservationValue<>(value.getPhenomenonTime(), rectifiedGridCoverage));
    } else {
        QuantityValue heightDepth = new QuantityValue(0.0);
        if (isSetHeightDepthParameter()) {
            heightDepth = (QuantityValue) getHeightDepthParameter().getValue();
            removeParameter(getHeightDepthParameter());
        }
        RectifiedGridCoverage rectifiedGridCoverage = new RectifiedGridCoverage(getObservationID());
        rectifiedGridCoverage.setUnit(value.getValue().getUnit());
        rectifiedGridCoverage.addValue(heightDepth, value.getValue());
        super.setValue(new SingleObservationValue<>(value.getPhenomenonTime(), rectifiedGridCoverage));
    }
}
Also used : StreamingValue(org.n52.shetland.ogc.om.StreamingValue) Coordinate(org.locationtech.jts.geom.Coordinate) QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue) ProfileLevel(org.n52.shetland.ogc.om.values.ProfileLevel) QuantityRangeValue(org.n52.shetland.ogc.om.values.QuantityRangeValue) RectifiedGridCoverage(org.n52.shetland.ogc.om.values.RectifiedGridCoverage) ReferencableGridCoverage(org.n52.shetland.ogc.om.values.ReferencableGridCoverage) ProfileValue(org.n52.shetland.ogc.om.values.ProfileValue)

Example 2 with SingleObservationValue

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

the class TrajectoryObservation method convertSingleValueToMultiValue.

/**
 * Convert {@link SingleObservationValue} to {@link TVPValue}
 *
 * @param singleValue
 *            Single observation value
 * @return Converted TVPValue value
 */
private TLVTValue convertSingleValueToMultiValue(final SingleObservationValue<?> singleValue, Geometry geom) {
    final TLVTValue tlvpValue = new TLVTValue();
    tlvpValue.setUnit(singleValue.getValue().getUnit());
    final TimeLocationValueTriple timeLocationValueTriple = new TimeLocationValueTriple(singleValue.getPhenomenonTime(), singleValue.getValue(), geom);
    tlvpValue.addValue(timeLocationValueTriple);
    return tlvpValue;
}
Also used : TLVTValue(org.n52.shetland.ogc.om.values.TLVTValue) TimeLocationValueTriple(org.n52.shetland.ogc.om.TimeLocationValueTriple)

Example 3 with SingleObservationValue

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

the class TrajectoryObservation method setValue.

@SuppressWarnings("rawtypes")
@Override
public void setValue(ObservationValue<?> value) {
    if (value instanceof StreamingValue || value.getValue() instanceof TLVTValue) {
        super.setValue(value);
    } else {
        Geometry geometry = null;
        if (isSetSpatialFilteringProfileParameter()) {
            geometry = getSpatialFilteringProfileParameter().getValue().getValue();
        } else {
            if (getObservationConstellation().getFeatureOfInterest() instanceof AbstractSamplingFeature && ((AbstractSamplingFeature) getObservationConstellation().getFeatureOfInterest()).isSetGeometry()) {
                geometry = ((AbstractSamplingFeature) getObservationConstellation().getFeatureOfInterest()).getGeometry();
            }
        }
        TLVTValue tlvpValue = convertSingleValueToMultiValue((SingleObservationValue<?>) value, geometry);
        if (!tlvpValue.isSetUnit() && ((AbstractObservationValue<?>) value).isSetUnit()) {
            tlvpValue.setUnit(((AbstractObservationValue<?>) value).getUnit());
        }
        final MultiObservationValues<List<TimeLocationValueTriple>> multiValue = new MultiObservationValues<List<TimeLocationValueTriple>>();
        multiValue.setValue(tlvpValue);
        if (!multiValue.isSetObservationID()) {
            if (value instanceof AbstractObservationValue && ((AbstractObservationValue) value).isSetObservationID()) {
                multiValue.setObservationID(((AbstractObservationValue) value).getObservationID());
            } else if (isSetObservationID()) {
                multiValue.setObservationID(getObservationID());
            }
        }
        super.setValue(multiValue);
    }
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) AbstractObservationValue(org.n52.shetland.ogc.om.AbstractObservationValue) AbstractSamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature) StreamingValue(org.n52.shetland.ogc.om.StreamingValue) List(java.util.List) TLVTValue(org.n52.shetland.ogc.om.values.TLVTValue) MultiObservationValues(org.n52.shetland.ogc.om.MultiObservationValues) TimeLocationValueTriple(org.n52.shetland.ogc.om.TimeLocationValueTriple)

Example 4 with SingleObservationValue

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

the class SweHelper method createSosSweDataArray.

/**
 * Create {@link SweDataArray} from {@link AbstractObservationValue}
 *
 * @param observationValue
 *            The {@link AbstractObservationValue} to create
 *            {@link SweDataArray} from
 *
 * @return Created {@link SweDataArray}
 *
 * @throws EncodingException
 *             If the service does not support the {@link SweDataArray}
 *             creation from {@link AbstractObservationValue}
 */
public SweDataArray createSosSweDataArray(AbstractObservationValue<?> observationValue) throws EncodingException {
    String observablePropertyIdentifier = observationValue.getObservableProperty();
    SweDataArrayValue dataArrayValue = new SweDataArrayValue();
    SweDataArray dataArray = new SweDataArray();
    dataArray.setEncoding(createTextEncoding(observationValue));
    dataArrayValue.setValue(dataArray);
    if (observationValue instanceof SingleObservationValue) {
        SingleObservationValue<?> singleValue = (SingleObservationValue<?>) observationValue;
        if (singleValue.getValue() instanceof SweDataArrayValue) {
            return (SweDataArray) singleValue.getValue().getValue();
        } else {
            dataArray.setElementType(createElementType(singleValue, observablePropertyIdentifier));
            dataArrayValue.addBlock(createBlock(dataArray.getElementType(), observationValue.getPhenomenonTime(), observablePropertyIdentifier, singleValue.getValue()));
        }
    } else if (observationValue instanceof MultiObservationValues) {
        MultiObservationValues<?> multiValue = (MultiObservationValues<?>) observationValue;
        if (multiValue.getValue() instanceof SweDataArrayValue) {
            return ((SweDataArrayValue) multiValue.getValue()).getValue();
        } else if (multiValue.getValue() instanceof TVPValue) {
            TVPValue tvpValues = (TVPValue) multiValue.getValue();
            for (TimeValuePair timeValuePair : tvpValues.getValue()) {
                if (timeValuePair != null && timeValuePair.getValue() != null && timeValuePair.getValue().isSetValue()) {
                    if (!dataArray.isSetElementTyp()) {
                        dataArray.setElementType(createElementType(timeValuePair, observablePropertyIdentifier));
                    }
                    List<String> newBlock = createBlock(dataArray.getElementType(), timeValuePair.getTime(), observablePropertyIdentifier, timeValuePair.getValue());
                    dataArrayValue.addBlock(newBlock);
                }
            }
        }
    }
    return dataArray;
}
Also used : SingleObservationValue(org.n52.shetland.ogc.om.SingleObservationValue) TVPValue(org.n52.shetland.ogc.om.values.TVPValue) SweDataArray(org.n52.shetland.ogc.swe.SweDataArray) SweDataArrayValue(org.n52.shetland.ogc.om.values.SweDataArrayValue) MultiObservationValues(org.n52.shetland.ogc.om.MultiObservationValues) TimeValuePair(org.n52.shetland.ogc.om.TimeValuePair)

Example 5 with SingleObservationValue

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

the class SweHelper method createSosSweDataArray.

/**
 * Create {@link SweDataArray} from {@link OmObservation}
 *
 * @param sosObservation
 *            The {@link OmObservation} to create {@link SweDataArray} from
 *
 * @return Created {@link SweDataArray}
 *
 * @throws EncodingException
 *             If the service does not support the {@link SweDataArray}
 *             creation from value of {@link OmObservation}
 */
public SweDataArray createSosSweDataArray(OmObservation sosObservation) throws EncodingException {
    String observablePropertyIdentifier = sosObservation.getObservationConstellation().getObservableProperty().getIdentifier();
    SweDataArrayValue dataArrayValue = new SweDataArrayValue();
    SweDataArray dataArray = new SweDataArray();
    dataArray.setEncoding(createTextEncoding(sosObservation));
    dataArrayValue.setValue(dataArray);
    if (sosObservation.getValue() instanceof SingleObservationValue) {
        SingleObservationValue<?> singleValue = (SingleObservationValue<?>) sosObservation.getValue();
        if (singleValue.getValue() instanceof SweDataArrayValue) {
            return (SweDataArray) singleValue.getValue().getValue();
        } else {
            dataArray.setElementType(createElementType(singleValue, observablePropertyIdentifier));
            dataArrayValue.addBlock(createBlock(dataArray.getElementType(), sosObservation.getPhenomenonTime(), observablePropertyIdentifier, singleValue.getValue()));
        }
    } else if (sosObservation.getValue() instanceof MultiObservationValues) {
        MultiObservationValues<?> multiValue = (MultiObservationValues<?>) sosObservation.getValue();
        if (multiValue.getValue() instanceof SweDataArrayValue) {
            return ((SweDataArrayValue) multiValue.getValue()).getValue();
        } else if (multiValue.getValue() instanceof TVPValue) {
            TVPValue tvpValues = (TVPValue) multiValue.getValue();
            for (TimeValuePair timeValuePair : tvpValues.getValue()) {
                if (timeValuePair != null && timeValuePair.getValue() != null && timeValuePair.getValue().isSetValue()) {
                    if (!dataArray.isSetElementTyp()) {
                        dataArray.setElementType(createElementType(timeValuePair, observablePropertyIdentifier));
                    }
                    List<String> newBlock = createBlock(dataArray.getElementType(), timeValuePair.getTime(), observablePropertyIdentifier, timeValuePair.getValue());
                    dataArrayValue.addBlock(newBlock);
                }
            }
        }
    }
    return dataArray;
}
Also used : SingleObservationValue(org.n52.shetland.ogc.om.SingleObservationValue) TVPValue(org.n52.shetland.ogc.om.values.TVPValue) SweDataArray(org.n52.shetland.ogc.swe.SweDataArray) SweDataArrayValue(org.n52.shetland.ogc.om.values.SweDataArrayValue) MultiObservationValues(org.n52.shetland.ogc.om.MultiObservationValues) TimeValuePair(org.n52.shetland.ogc.om.TimeValuePair)

Aggregations

SingleObservationValue (org.n52.shetland.ogc.om.SingleObservationValue)11 MultiObservationValues (org.n52.shetland.ogc.om.MultiObservationValues)7 List (java.util.List)6 QuantityValue (org.n52.shetland.ogc.om.values.QuantityValue)5 TVPValue (org.n52.shetland.ogc.om.values.TVPValue)5 StreamingValue (org.n52.shetland.ogc.om.StreamingValue)4 TimeLocationValueTriple (org.n52.shetland.ogc.om.TimeLocationValueTriple)4 TimeValuePair (org.n52.shetland.ogc.om.TimeValuePair)4 TLVTValue (org.n52.shetland.ogc.om.values.TLVTValue)4 SweDataArray (org.n52.shetland.ogc.swe.SweDataArray)4 Geometry (org.locationtech.jts.geom.Geometry)3 CountValue (org.n52.shetland.ogc.om.values.CountValue)3 GeometryValue (org.n52.shetland.ogc.om.values.GeometryValue)3 SweDataArrayValue (org.n52.shetland.ogc.om.values.SweDataArrayValue)3 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)3 TVPDefaultMetadataPropertyType (net.opengis.waterml.x20.TVPDefaultMetadataPropertyType)2 XmlBoolean (org.apache.xmlbeans.XmlBoolean)2 XmlInteger (org.apache.xmlbeans.XmlInteger)2 XmlString (org.apache.xmlbeans.XmlString)2 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)2