use of org.n52.shetland.ogc.om.values.ProfileLevel 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.ProfileLevel in project arctic-sea by 52North.
the class ProfileValue method getGeometry.
public Geometry getGeometry() {
if (isSetGeometry()) {
TreeMap<Time, Coordinate> map = new TreeMap<>();
int srid = -1;
for (ProfileLevel level : getValue()) {
if (level.isSetPhenomenonTime() && level.isSetLocation()) {
if (srid < 0) {
srid = level.getLocation().getSRID();
}
map.put(level.getPhenomenonTime(), level.getLocation().getCoordinate());
}
}
if (!map.isEmpty()) {
if (new HashSet<>(map.values()).size() == 1) {
return getValue().iterator().next().getLocation();
} else {
return new GeometryFactory(new PrecisionModel(), srid).createLineString(map.values().toArray(new Coordinate[1]));
}
}
}
return null;
}
use of org.n52.shetland.ogc.om.values.ProfileLevel in project arctic-sea by 52North.
the class ProfileValueTest method createProfileLevel.
private ProfileLevel createProfileLevel(boolean fromDepth, boolean toDepth, double start) {
ProfileLevel profileLevel = new ProfileLevel();
if (fromDepth) {
profileLevel.setLevelStart(createQuantity("fromDepth", start, "m"));
}
if (toDepth) {
profileLevel.setLevelEnd(createQuantity("toDepth", start + 10.0, "m"));
}
profileLevel.setValue(createProfileLevel());
return profileLevel;
}
use of org.n52.shetland.ogc.om.values.ProfileLevel in project arctic-sea by 52North.
the class GWGeologyLogCoveragePropertyEncoderTest method createLogValue.
private ProfileLevel createLogValue(boolean fromDepth, boolean toDepth, double start) {
ProfileLevel profileLevel = new ProfileLevel();
if (fromDepth) {
profileLevel.setLevelStart(createQuantity("fromDepth", start, "m"));
}
if (toDepth) {
profileLevel.setLevelEnd(createQuantity("toDepth", start + 10.0, "m"));
}
profileLevel.setValue(createProfileLevel());
return profileLevel;
}
use of org.n52.shetland.ogc.om.values.ProfileLevel in project arctic-sea by 52North.
the class ProfileValue method asDataRecord.
public SweDataRecord asDataRecord() {
SweDataRecord dataRecord = new SweDataRecord();
if (isSetIdentifier()) {
dataRecord.setIdentifier(getIdentifier());
}
if (isSetName()) {
dataRecord.setName(getName());
}
if (isSetDescription()) {
dataRecord.setDescription(getDescription());
}
int counter = 0;
for (ProfileLevel level : getValue()) {
dataRecord.addField(new SweField("level_" + counter++, level.asDataRecord()));
}
return dataRecord;
}
Aggregations