Search in sources :

Example 1 with MultiObservationValues

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

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

use of org.n52.shetland.ogc.om.MultiObservationValues 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)

Example 4 with MultiObservationValues

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

the class TrajectoryObservationTypeEncoder method createCategoricalTimeseries.

/**
 * Encode {@link AbstractObservationValue} to
 * {@link CategoricalTimeseriesDocument}
 *
 * @param observationValue
 *            The {@link AbstractObservationValue} to encode
 * @return The encoded {@link AbstractObservationValue}
 * @throws EncodingException
 *             If an error occurs
 */
private XmlObject createCategoricalTimeseries(AbstractObservationValue<?> observationValue) throws EncodingException {
    CategoricalTimeseriesDocument categoricalTimeseriesDoc = CategoricalTimeseriesDocument.Factory.newInstance();
    CategoricalTimeseriesType categoricalTimeseries = categoricalTimeseriesDoc.addNewCategoricalTimeseries();
    categoricalTimeseries.setId(TIMESERIES_PREFIX + observationValue.getObservationID());
    categoricalTimeseries.addNewMetadata().addNewTimeseriesMetadata().addNewTemporalExtent().setHref("#" + observationValue.getPhenomenonTime().getGmlId());
    TVPDefaultMetadataPropertyType xbMetaComponent = categoricalTimeseries.addNewDefaultPointMetadata();
    DefaultTVPCategoricalMetadataDocument xbDefCateMetaComponent = DefaultTVPCategoricalMetadataDocument.Factory.newInstance();
    DefaultCategoricalTVPMetadataType defaultTVPCateMetadata = xbDefCateMetaComponent.addNewDefaultTVPCategoricalMetadata();
    String unit = null;
    if (observationValue instanceof SingleObservationValue) {
        SingleObservationValue<?> singleObservationValue = (SingleObservationValue<?>) observationValue;
        unit = singleObservationValue.getValue().getUnit();
        if (observationValue.getValue() instanceof TimeLocationValueTriple) {
            categoricalTimeseries.addNewPoint().addNewCategoricalTVP().set(encodeTLVT((TimeLocationValueTriple) observationValue.getValue()));
        }
    } else if (observationValue instanceof MultiObservationValues) {
        MultiObservationValues<?> multiObservationValue = (MultiObservationValues<?>) observationValue;
        if (multiObservationValue.getValue() instanceof TLVTValue) {
            TLVTValue tlvtValue = (TLVTValue) multiObservationValue.getValue();
            List<TimeLocationValueTriple> timeLocationValueTriples = tlvtValue.getValue();
            unit = tlvtValue.getUnit();
            int counter = 0;
            for (TimeLocationValueTriple timeLocationValueTriple : timeLocationValueTriples) {
                timeLocationValueTriple.getLocation().setUserData(getUserObject(observationValue.getObservationID(), counter));
                categoricalTimeseries.addNewPoint().addNewCategoricalTVP().set(encodeTLVT(timeLocationValueTriple));
                counter++;
            }
        }
    }
    if (unit != null && !unit.isEmpty()) {
        defaultTVPCateMetadata.setCodeSpace(unit);
    }
    xbMetaComponent.set(xbDefCateMetaComponent);
    return categoricalTimeseriesDoc;
}
Also used : DefaultTVPCategoricalMetadataDocument(net.opengis.waterml.x20.DefaultTVPCategoricalMetadataDocument) CategoricalTimeseriesDocument(net.opengis.waterml.x20.CategoricalTimeseriesDocument) SingleObservationValue(org.n52.shetland.ogc.om.SingleObservationValue) TVPDefaultMetadataPropertyType(net.opengis.waterml.x20.TVPDefaultMetadataPropertyType) DefaultCategoricalTVPMetadataType(net.opengis.waterml.x20.DefaultCategoricalTVPMetadataType) List(java.util.List) CategoricalTimeseriesType(net.opengis.waterml.x20.CategoricalTimeseriesType) TLVTValue(org.n52.shetland.ogc.om.values.TLVTValue) TimeLocationValueTriple(org.n52.shetland.ogc.om.TimeLocationValueTriple) MultiObservationValues(org.n52.shetland.ogc.om.MultiObservationValues)

Example 5 with MultiObservationValues

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

the class TrajectoryObservationTypeEncoder method createMeasurementTimeseries.

/**
 * Encode {@link AbstractObservationValue} to
 * {@link MeasurementTimeseriesDocument}
 *
 * @param observationValue
 *            The {@link AbstractObservationValue} to encode
 * @return The encoded {@link AbstractObservationValue}
 * @throws EncodingException
 *             If an error occurs
 */
private XmlObject createMeasurementTimeseries(AbstractObservationValue<?> observationValue) throws EncodingException {
    MeasurementTimeseriesDocument measurementTimeseriesDoc = MeasurementTimeseriesDocument.Factory.newInstance();
    MeasurementTimeseriesType measurementTimeseries = measurementTimeseriesDoc.addNewMeasurementTimeseries();
    if (!observationValue.isSetObservationID()) {
        observationValue.setObservationID(JavaHelper.generateID(observationValue.toString()));
    }
    measurementTimeseries.setId(TIMESERIES_PREFIX + observationValue.getObservationID());
    measurementTimeseries.addNewMetadata().addNewTimeseriesMetadata().addNewTemporalExtent().setHref("#" + observationValue.getPhenomenonTime().getGmlId());
    TVPDefaultMetadataPropertyType xbMetaComponent = measurementTimeseries.addNewDefaultPointMetadata();
    DefaultTVPMeasurementMetadataDocument xbDefMeasureMetaComponent = DefaultTVPMeasurementMetadataDocument.Factory.newInstance();
    TVPMeasurementMetadataType defaultTVPMeasurementMetadata = xbDefMeasureMetaComponent.addNewDefaultTVPMeasurementMetadata();
    defaultTVPMeasurementMetadata.addNewInterpolationType().setHref("http://www.opengis.net/def/timeseriesType/WaterML/2.0/continuous");
    xbDefMeasureMetaComponent.getDefaultTVPMeasurementMetadata().getInterpolationType().setTitle("Instantaneous");
    String unit = null;
    if (observationValue instanceof SingleObservationValue) {
        SingleObservationValue<?> singleObservationValue = (SingleObservationValue<?>) observationValue;
        unit = singleObservationValue.getValue().getUnit();
        if (observationValue.getValue() instanceof TimeLocationValueTriple) {
            measurementTimeseries.addNewPoint().addNewMeasurementTVP().set(encodeTLVT((TimeLocationValueTriple) observationValue.getValue()));
        }
    } else if (observationValue instanceof MultiObservationValues) {
        MultiObservationValues<?> multiObservationValue = (MultiObservationValues<?>) observationValue;
        if (multiObservationValue.getValue() instanceof TLVTValue) {
            TLVTValue tlvtValue = (TLVTValue) multiObservationValue.getValue();
            List<TimeLocationValueTriple> timeLocationValueTriples = tlvtValue.getValue();
            unit = tlvtValue.getUnit();
            int counter = 0;
            for (TimeLocationValueTriple timeLocationValueTriple : timeLocationValueTriples) {
                timeLocationValueTriple.getLocation().setUserData(getUserObject(observationValue.getObservationID(), counter));
                measurementTimeseries.addNewPoint().addNewMeasurementTVP().set(encodeTLVT(timeLocationValueTriple));
                counter++;
            }
        }
    }
    if (unit != null && !unit.isEmpty()) {
        defaultTVPMeasurementMetadata.addNewUom().setCode(unit);
    }
    xbMetaComponent.set(xbDefMeasureMetaComponent);
    return measurementTimeseriesDoc;
}
Also used : MeasurementTimeseriesType(net.opengis.waterml.x20.MeasurementTimeseriesType) SingleObservationValue(org.n52.shetland.ogc.om.SingleObservationValue) TVPDefaultMetadataPropertyType(net.opengis.waterml.x20.TVPDefaultMetadataPropertyType) TVPMeasurementMetadataType(net.opengis.waterml.x20.TVPMeasurementMetadataType) DefaultTVPMeasurementMetadataDocument(net.opengis.waterml.x20.DefaultTVPMeasurementMetadataDocument) List(java.util.List) MeasurementTimeseriesDocument(net.opengis.waterml.x20.MeasurementTimeseriesDocument) TLVTValue(org.n52.shetland.ogc.om.values.TLVTValue) TimeLocationValueTriple(org.n52.shetland.ogc.om.TimeLocationValueTriple) MultiObservationValues(org.n52.shetland.ogc.om.MultiObservationValues)

Aggregations

MultiObservationValues (org.n52.shetland.ogc.om.MultiObservationValues)13 List (java.util.List)10 TVPValue (org.n52.shetland.ogc.om.values.TVPValue)8 SingleObservationValue (org.n52.shetland.ogc.om.SingleObservationValue)7 TimeValuePair (org.n52.shetland.ogc.om.TimeValuePair)7 TimeLocationValueTriple (org.n52.shetland.ogc.om.TimeLocationValueTriple)6 TLVTValue (org.n52.shetland.ogc.om.values.TLVTValue)6 OmObservation (org.n52.shetland.ogc.om.OmObservation)4 QuantityValue (org.n52.shetland.ogc.om.values.QuantityValue)3 MeasureOrNilReasonListType (net.opengis.gml.x32.MeasureOrNilReasonListType)2 QuantityListDocument (net.opengis.gml.x32.QuantityListDocument)2 TVPDefaultMetadataPropertyType (net.opengis.waterml.x20.TVPDefaultMetadataPropertyType)2 MeasurementTimeseriesCoverageType (net.opengis.watermlDr.x20.MeasurementTimeseriesCoverageType)2 MeasurementTimeseriesDomainRangeDocument (net.opengis.watermlDr.x20.MeasurementTimeseriesDomainRangeDocument)2 TimePositionListDocument (net.opengis.watermlDr.x20.TimePositionListDocument)2 TimePositionListType (net.opengis.watermlDr.x20.TimePositionListType)2 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)2 StreamingValue (org.n52.shetland.ogc.om.StreamingValue)2 CountValue (org.n52.shetland.ogc.om.values.CountValue)2 SweDataArrayValue (org.n52.shetland.ogc.om.values.SweDataArrayValue)2