Search in sources :

Example 1 with TLVTValue

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

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

use of org.n52.shetland.ogc.om.values.TLVTValue 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 4 with TLVTValue

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

Example 5 with TLVTValue

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

the class TrajectoryObservationTypeEncoderTest method getQuantityObservation.

private OmObservation getQuantityObservation() throws EncodingException, ParseException, DecodingException, XmlException, IOException {
    MultiObservationValues<List<TimeLocationValueTriple>> multiObservationValues = new MultiObservationValues<List<TimeLocationValueTriple>>();
    TLVTValue tlvtValue = new TLVTValue();
    tlvtValue.addValue(getTimeLocationValueTriple(new QuantityValue(15.6, "C")));
    tlvtValue.addValue(getTimeLocationValueTriple(new QuantityValue(16.5, "C")));
    tlvtValue.addValue(getTimeLocationValueTriple(new QuantityValue(17.6, "C")));
    tlvtValue.addValue(getTimeLocationValueTriple(new QuantityValue(18.7, "C")));
    multiObservationValues.setValue(tlvtValue);
    OmObservation observation = createObservation();
    observation.setValue(multiObservationValues);
    return observation;
}
Also used : QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue) OmObservation(org.n52.shetland.ogc.om.OmObservation) 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)

Aggregations

TimeLocationValueTriple (org.n52.shetland.ogc.om.TimeLocationValueTriple)8 TLVTValue (org.n52.shetland.ogc.om.values.TLVTValue)8 List (java.util.List)6 MultiObservationValues (org.n52.shetland.ogc.om.MultiObservationValues)6 OmObservation (org.n52.shetland.ogc.om.OmObservation)3 TVPDefaultMetadataPropertyType (net.opengis.waterml.x20.TVPDefaultMetadataPropertyType)2 SingleObservationValue (org.n52.shetland.ogc.om.SingleObservationValue)2 CategoricalTimeseriesDocument (net.opengis.waterml.x20.CategoricalTimeseriesDocument)1 CategoricalTimeseriesType (net.opengis.waterml.x20.CategoricalTimeseriesType)1 DefaultCategoricalTVPMetadataType (net.opengis.waterml.x20.DefaultCategoricalTVPMetadataType)1 DefaultTVPCategoricalMetadataDocument (net.opengis.waterml.x20.DefaultTVPCategoricalMetadataDocument)1 DefaultTVPMeasurementMetadataDocument (net.opengis.waterml.x20.DefaultTVPMeasurementMetadataDocument)1 MeasurementTimeseriesDocument (net.opengis.waterml.x20.MeasurementTimeseriesDocument)1 MeasurementTimeseriesType (net.opengis.waterml.x20.MeasurementTimeseriesType)1 TVPMeasurementMetadataType (net.opengis.waterml.x20.TVPMeasurementMetadataType)1 Geometry (org.locationtech.jts.geom.Geometry)1 AbstractObservationValue (org.n52.shetland.ogc.om.AbstractObservationValue)1 StreamingValue (org.n52.shetland.ogc.om.StreamingValue)1 AbstractSamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature)1 CategoryValue (org.n52.shetland.ogc.om.values.CategoryValue)1