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));
}
}
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;
}
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;
}
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));
}
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));
}
Aggregations