Search in sources :

Example 1 with ProfileValue

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

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

the class ProfileValueTest method createProfileValue.

private ProfileValue createProfileValue(boolean fromDepth, boolean toDepth) {
    ProfileValue coverage = new ProfileValue("");
    coverage.addValue(createProfileLevel(fromDepth, toDepth, 0.0));
    coverage.addValue(createProfileLevel(fromDepth, toDepth, 10.0));
    coverage.addValue(createProfileLevel(fromDepth, toDepth, 20.0));
    return coverage;
}
Also used : ProfileValue(org.n52.shetland.ogc.om.values.ProfileValue)

Example 3 with ProfileValue

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

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

the class GWGeologyLogCoveragePropertyEncoderTest method should_encode_GWGeologyLogCoverage_fromDepth.

@Test
public void should_encode_GWGeologyLogCoverage_fromDepth() throws EncodingException, DecodingException {
    ProfileValue coverage = createGWGeologyLogCoverage(true, false);
    XmlObject encodedObject = encoder.encode(coverage);
    assertThat(XmlHelper.validateDocument(encodedObject), is(TRUE));
    assertThat(encodedObject, instanceOf(GWGeologyLogCoveragePropertyType.class));
}
Also used : XmlObject(org.apache.xmlbeans.XmlObject) ProfileValue(org.n52.shetland.ogc.om.values.ProfileValue) GWGeologyLogCoveragePropertyType(net.opengis.gwmlWell.x22.GWGeologyLogCoveragePropertyType) Test(org.junit.Test)

Example 5 with ProfileValue

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

the class GWGeologyLogCoveragePropertyEncoderTest method should_encode_GWGeologyLogCoverage_only_value.

@Test
public void should_encode_GWGeologyLogCoverage_only_value() throws EncodingException, DecodingException {
    ProfileValue coverage = createGWGeologyLogCoverage(false, false);
    XmlObject encodedObject = encoder.encode(coverage);
    assertThat(XmlHelper.validateDocument(encodedObject), is(TRUE));
    assertThat(encodedObject, instanceOf(GWGeologyLogCoveragePropertyType.class));
}
Also used : XmlObject(org.apache.xmlbeans.XmlObject) ProfileValue(org.n52.shetland.ogc.om.values.ProfileValue) GWGeologyLogCoveragePropertyType(net.opengis.gwmlWell.x22.GWGeologyLogCoveragePropertyType) Test(org.junit.Test)

Aggregations

ProfileValue (org.n52.shetland.ogc.om.values.ProfileValue)8 GWGeologyLogCoveragePropertyType (net.opengis.gwmlWell.x22.GWGeologyLogCoveragePropertyType)4 XmlObject (org.apache.xmlbeans.XmlObject)4 Test (org.junit.Test)4 QuantityValue (org.n52.shetland.ogc.om.values.QuantityValue)2 List (java.util.List)1 Coordinate (org.locationtech.jts.geom.Coordinate)1 MultiObservationValues (org.n52.shetland.ogc.om.MultiObservationValues)1 SingleObservationValue (org.n52.shetland.ogc.om.SingleObservationValue)1 StreamingValue (org.n52.shetland.ogc.om.StreamingValue)1 TimeValuePair (org.n52.shetland.ogc.om.TimeValuePair)1 CountValue (org.n52.shetland.ogc.om.values.CountValue)1 ProfileLevel (org.n52.shetland.ogc.om.values.ProfileLevel)1 QuantityRangeValue (org.n52.shetland.ogc.om.values.QuantityRangeValue)1 RectifiedGridCoverage (org.n52.shetland.ogc.om.values.RectifiedGridCoverage)1 ReferencableGridCoverage (org.n52.shetland.ogc.om.values.ReferencableGridCoverage)1 TVPValue (org.n52.shetland.ogc.om.values.TVPValue)1 NoApplicableCodeException (org.n52.shetland.ogc.ows.exception.NoApplicableCodeException)1