Search in sources :

Example 6 with MultiObservationValues

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

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

Example 8 with MultiObservationValues

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

the class TrajectoryObservationTypeEncoderTest method getCountObservation.

private OmObservation getCountObservation() throws EncodingException, ParseException, DecodingException, XmlException, IOException {
    MultiObservationValues<List<TimeLocationValueTriple>> multiObservationValues = new MultiObservationValues<List<TimeLocationValueTriple>>();
    TLVTValue tlvtValue = new TLVTValue();
    tlvtValue.addValue(getTimeLocationValueTriple(new CountValue(15)));
    tlvtValue.addValue(getTimeLocationValueTriple(new CountValue(16)));
    tlvtValue.addValue(getTimeLocationValueTriple(new CountValue(17)));
    tlvtValue.addValue(getTimeLocationValueTriple(new CountValue(18)));
    multiObservationValues.setValue(tlvtValue);
    OmObservation observation = createObservation();
    observation.setValue(multiObservationValues);
    return observation;
}
Also used : CountValue(org.n52.shetland.ogc.om.values.CountValue) 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)

Example 9 with MultiObservationValues

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

the class WmlTVPEncoderv20Test method initObjects.

@Before
public void initObjects() {
    encoder = new WmlTVPEncoderv20();
    MultiValue<List<TimeValuePair>> value = new TVPValue();
    String unit = "test-unit";
    value.setUnit(unit);
    TimeValuePair tvp1 = new TimeValuePair(new TimeInstant(new Date(UTC_TIMESTAMP)), new QuantityValue(52.1234567890));
    List<TimeValuePair> valueList = CollectionHelper.list(tvp1);
    value.setValue(valueList);
    mv = new MultiObservationValues<>();
    mv.setValue(value);
}
Also used : TVPValue(org.n52.shetland.ogc.om.values.TVPValue) QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue) List(java.util.List) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) Date(java.util.Date) TimeValuePair(org.n52.shetland.ogc.om.TimeValuePair) Before(org.junit.Before)

Example 10 with MultiObservationValues

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

the class OmObservation method convertSingleValueToMultiValue.

/**
 * Convert {@link SingleObservationValue} to {@link TVPValue}.
 *
 * @param singleValue
 *            Single observation value
 *
 * @return Converted TVPValue value
 */
public TVPValue convertSingleValueToMultiValue(final SingleObservationValue<?> singleValue) {
    MultiObservationValues<List<TimeValuePair>> multiValue = new MultiObservationValues<>();
    TVPValue tvpValue = new TVPValue();
    if (singleValue.isSetUnit()) {
        tvpValue.setUnit(singleValue.getUnit());
    } else if (singleValue.getValue().isSetUnit()) {
        tvpValue.setUnit(singleValue.getValue().getUnit());
    }
    if (singleValue.isSetMetadata()) {
        multiValue.setMetadata(singleValue.getMetadata());
    }
    if (singleValue.isSetDefaultPointMetadata()) {
        multiValue.setDefaultPointMetadata(singleValue.getDefaultPointMetadata());
    }
    TimeValuePair timeValuePair = new TimeValuePair(singleValue.getPhenomenonTime(), singleValue.getValue());
    tvpValue.addValue(timeValuePair);
    multiValue.setValue(tvpValue);
    value = multiValue;
    return tvpValue;
}
Also used : TVPValue(org.n52.shetland.ogc.om.values.TVPValue) List(java.util.List)

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