use of org.n52.shetland.ogc.om.values.QuantityRangeValue 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.QuantityRangeValue in project arctic-sea by 52North.
the class RectifiedGridCoverageDocumentEncoderTest method getTextRectifiedGridCoverage.
private RectifiedGridCoverage getTextRectifiedGridCoverage() {
RectifiedGridCoverage rgc = new RectifiedGridCoverage("text");
rgc.setUnit("d");
rgc.setRangeParameters("text_param");
rgc.addValue(new QuantityRangeValue(BigDecimal.valueOf(0.0), BigDecimal.valueOf(5.0), "m"), new TextValue("test text"));
rgc.addValue(new QuantityRangeValue(BigDecimal.valueOf(5.0), BigDecimal.valueOf(10.0), "m"), new TextValue("test text 2"));
rgc.addValue(new QuantityRangeValue(BigDecimal.valueOf(10.0), BigDecimal.valueOf(15.0), "m"), new TextValue("test text 2 test"));
return rgc;
}
use of org.n52.shetland.ogc.om.values.QuantityRangeValue in project arctic-sea by 52North.
the class RectifiedGridCoverageDocumentEncoderTest method getCategoryRectifiedGridCoverage.
private RectifiedGridCoverage getCategoryRectifiedGridCoverage() {
RectifiedGridCoverage rgc = new RectifiedGridCoverage("category");
rgc.setUnit("d");
rgc.setRangeParameters("category_param");
rgc.addValue(new QuantityRangeValue(BigDecimal.valueOf(0.0), BigDecimal.valueOf(5.0), "m"), new CategoryValue("test category"));
rgc.addValue(new QuantityRangeValue(BigDecimal.valueOf(5.0), BigDecimal.valueOf(10.0), "m"), new CategoryValue("test category 2"));
rgc.addValue(new QuantityRangeValue(BigDecimal.valueOf(10.0), BigDecimal.valueOf(15.0), "m"), new CategoryValue("test category 2 test"));
return rgc;
}
Aggregations