use of org.n52.shetland.ogc.om.SingleObservationValue 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.SingleObservationValue in project arctic-sea by 52North.
the class TrajectoryObservation method convertSingleValueToMultiValue.
/**
* Convert {@link SingleObservationValue} to {@link TVPValue}
*
* @param singleValue
* Single observation value
* @return Converted TVPValue value
*/
private TLVTValue convertSingleValueToMultiValue(final SingleObservationValue<?> singleValue, Geometry geom) {
final TLVTValue tlvpValue = new TLVTValue();
tlvpValue.setUnit(singleValue.getValue().getUnit());
final TimeLocationValueTriple timeLocationValueTriple = new TimeLocationValueTriple(singleValue.getPhenomenonTime(), singleValue.getValue(), geom);
tlvpValue.addValue(timeLocationValueTriple);
return tlvpValue;
}
use of org.n52.shetland.ogc.om.SingleObservationValue in project arctic-sea by 52North.
the class TrajectoryObservation method setValue.
@SuppressWarnings("rawtypes")
@Override
public void setValue(ObservationValue<?> value) {
if (value instanceof StreamingValue || value.getValue() instanceof TLVTValue) {
super.setValue(value);
} else {
Geometry geometry = null;
if (isSetSpatialFilteringProfileParameter()) {
geometry = getSpatialFilteringProfileParameter().getValue().getValue();
} else {
if (getObservationConstellation().getFeatureOfInterest() instanceof AbstractSamplingFeature && ((AbstractSamplingFeature) getObservationConstellation().getFeatureOfInterest()).isSetGeometry()) {
geometry = ((AbstractSamplingFeature) getObservationConstellation().getFeatureOfInterest()).getGeometry();
}
}
TLVTValue tlvpValue = convertSingleValueToMultiValue((SingleObservationValue<?>) value, geometry);
if (!tlvpValue.isSetUnit() && ((AbstractObservationValue<?>) value).isSetUnit()) {
tlvpValue.setUnit(((AbstractObservationValue<?>) value).getUnit());
}
final MultiObservationValues<List<TimeLocationValueTriple>> multiValue = new MultiObservationValues<List<TimeLocationValueTriple>>();
multiValue.setValue(tlvpValue);
if (!multiValue.isSetObservationID()) {
if (value instanceof AbstractObservationValue && ((AbstractObservationValue) value).isSetObservationID()) {
multiValue.setObservationID(((AbstractObservationValue) value).getObservationID());
} else if (isSetObservationID()) {
multiValue.setObservationID(getObservationID());
}
}
super.setValue(multiValue);
}
}
use of org.n52.shetland.ogc.om.SingleObservationValue in project arctic-sea by 52North.
the class SweHelper method createSosSweDataArray.
/**
* Create {@link SweDataArray} from {@link AbstractObservationValue}
*
* @param observationValue
* The {@link AbstractObservationValue} to create
* {@link SweDataArray} from
*
* @return Created {@link SweDataArray}
*
* @throws EncodingException
* If the service does not support the {@link SweDataArray}
* creation from {@link AbstractObservationValue}
*/
public SweDataArray createSosSweDataArray(AbstractObservationValue<?> observationValue) throws EncodingException {
String observablePropertyIdentifier = observationValue.getObservableProperty();
SweDataArrayValue dataArrayValue = new SweDataArrayValue();
SweDataArray dataArray = new SweDataArray();
dataArray.setEncoding(createTextEncoding(observationValue));
dataArrayValue.setValue(dataArray);
if (observationValue instanceof SingleObservationValue) {
SingleObservationValue<?> singleValue = (SingleObservationValue<?>) observationValue;
if (singleValue.getValue() instanceof SweDataArrayValue) {
return (SweDataArray) singleValue.getValue().getValue();
} else {
dataArray.setElementType(createElementType(singleValue, observablePropertyIdentifier));
dataArrayValue.addBlock(createBlock(dataArray.getElementType(), observationValue.getPhenomenonTime(), observablePropertyIdentifier, singleValue.getValue()));
}
} else if (observationValue instanceof MultiObservationValues) {
MultiObservationValues<?> multiValue = (MultiObservationValues<?>) observationValue;
if (multiValue.getValue() instanceof SweDataArrayValue) {
return ((SweDataArrayValue) multiValue.getValue()).getValue();
} else if (multiValue.getValue() instanceof TVPValue) {
TVPValue tvpValues = (TVPValue) multiValue.getValue();
for (TimeValuePair timeValuePair : tvpValues.getValue()) {
if (timeValuePair != null && timeValuePair.getValue() != null && timeValuePair.getValue().isSetValue()) {
if (!dataArray.isSetElementTyp()) {
dataArray.setElementType(createElementType(timeValuePair, observablePropertyIdentifier));
}
List<String> newBlock = createBlock(dataArray.getElementType(), timeValuePair.getTime(), observablePropertyIdentifier, timeValuePair.getValue());
dataArrayValue.addBlock(newBlock);
}
}
}
}
return dataArray;
}
use of org.n52.shetland.ogc.om.SingleObservationValue in project arctic-sea by 52North.
the class SweHelper method createSosSweDataArray.
/**
* Create {@link SweDataArray} from {@link OmObservation}
*
* @param sosObservation
* The {@link OmObservation} to create {@link SweDataArray} from
*
* @return Created {@link SweDataArray}
*
* @throws EncodingException
* If the service does not support the {@link SweDataArray}
* creation from value of {@link OmObservation}
*/
public SweDataArray createSosSweDataArray(OmObservation sosObservation) throws EncodingException {
String observablePropertyIdentifier = sosObservation.getObservationConstellation().getObservableProperty().getIdentifier();
SweDataArrayValue dataArrayValue = new SweDataArrayValue();
SweDataArray dataArray = new SweDataArray();
dataArray.setEncoding(createTextEncoding(sosObservation));
dataArrayValue.setValue(dataArray);
if (sosObservation.getValue() instanceof SingleObservationValue) {
SingleObservationValue<?> singleValue = (SingleObservationValue<?>) sosObservation.getValue();
if (singleValue.getValue() instanceof SweDataArrayValue) {
return (SweDataArray) singleValue.getValue().getValue();
} else {
dataArray.setElementType(createElementType(singleValue, observablePropertyIdentifier));
dataArrayValue.addBlock(createBlock(dataArray.getElementType(), sosObservation.getPhenomenonTime(), observablePropertyIdentifier, singleValue.getValue()));
}
} else if (sosObservation.getValue() instanceof MultiObservationValues) {
MultiObservationValues<?> multiValue = (MultiObservationValues<?>) sosObservation.getValue();
if (multiValue.getValue() instanceof SweDataArrayValue) {
return ((SweDataArrayValue) multiValue.getValue()).getValue();
} else if (multiValue.getValue() instanceof TVPValue) {
TVPValue tvpValues = (TVPValue) multiValue.getValue();
for (TimeValuePair timeValuePair : tvpValues.getValue()) {
if (timeValuePair != null && timeValuePair.getValue() != null && timeValuePair.getValue().isSetValue()) {
if (!dataArray.isSetElementTyp()) {
dataArray.setElementType(createElementType(timeValuePair, observablePropertyIdentifier));
}
List<String> newBlock = createBlock(dataArray.getElementType(), timeValuePair.getTime(), observablePropertyIdentifier, timeValuePair.getValue());
dataArrayValue.addBlock(newBlock);
}
}
}
}
return dataArray;
}
Aggregations