use of org.n52.shetland.ogc.om.ObservationValue 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.ObservationValue in project arctic-sea by 52North.
the class WmlTVPEncoderv20XmlStreamWriter method writeInterpolationType.
/**
* Write wml:interpolationType to stream
*
* @throws XMLStreamException
* If an error occurs when writing to stream
*/
private void writeInterpolationType(ObservationValue<?> value) throws XMLStreamException {
empty(WaterMLConstants.QN_INTERPOLATION_TYPE);
if (value != null && value.isSetMetadata() && value.getDefaultPointMetadata().isSetDefaultTVPMeasurementMetadata() && value.getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().isSetInterpolationType()) {
InterpolationType interpolationtype = value.getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().getInterpolationtype();
addXlinkHrefAttr(interpolationtype.getIdentifier());
addXlinkTitleAttr(interpolationtype.getTitle());
} else {
addXlinkHrefAttr("http://www.opengis.net/def/timeseriesType/WaterML/2.0/continuous");
addXlinkTitleAttr("Instantaneous");
}
}
use of org.n52.shetland.ogc.om.ObservationValue in project arctic-sea by 52North.
the class TrajectoryObservation method mergeValues.
protected boolean mergeValues(ObservationValue<?> observationValue) {
if (observationValue.getValue() instanceof TLVTValue) {
TLVTValue tlvtValue = (TLVTValue) observationValue.getValue();
List<TimeLocationValueTriple> valuesToMerge = tlvtValue.getValue();
// List<TimeLocationValueTriple> valuesToMerge =
// (List<TimeLocationValueTriple>)((TLVTValue)observationValue.getValue()).getValue();
((TLVTValue) getValue().getValue()).addValues(valuesToMerge);
checkForFeature(valuesToMerge);
return true;
} else {
return super.mergeValues(observationValue);
}
}
use of org.n52.shetland.ogc.om.ObservationValue in project arctic-sea by 52North.
the class MultiPointObservation method setValue.
@Override
public void setValue(ObservationValue<?> value) {
if (value.getValue() instanceof MultiPointCoverage) {
super.setValue(value);
} else {
MultiPointCoverage multiPointCoverage = new MultiPointCoverage(getObservationID());
multiPointCoverage.setUnit(((AbstractObservationValue<?>) value).getUnit());
multiPointCoverage.addValue(new PointValuePair(getPoint(), value.getValue()));
super.setValue(new SingleObservationValue<>(value.getPhenomenonTime(), multiPointCoverage));
}
}
use of org.n52.shetland.ogc.om.ObservationValue in project arctic-sea by 52North.
the class PointObservation method setValue.
@Override
public void setValue(ObservationValue<?> value) {
if (value instanceof StreamingValue<?>) {
super.setValue(value);
} else if (value.getValue() instanceof CvDiscretePointCoverage) {
super.setValue(value);
} else {
CvDiscretePointCoverage cvDiscretePointCoverage = new CvDiscretePointCoverage(getObservationID());
cvDiscretePointCoverage.setRangeType(new ReferenceType(getObservationConstellation().getObservablePropertyIdentifier()));
cvDiscretePointCoverage.setUnit(((AbstractObservationValue<?>) value).getUnit());
Geometry geometry = null;
String domainExtent = "";
if (isSetSpatialFilteringProfileParameter() && getSpatialFilteringProfileParameter().getValue() instanceof GeometryValue) {
GeometryValue geometryValue = (GeometryValue) getSpatialFilteringProfileParameter().getValue();
geometry = getSpatialFilteringProfileParameter().getValue().getValue();
domainExtent = geometryValue.getGmlId();
} else if (checkForFeatureGeometry(this)) {
geometry = getGeometryFromFeature(this);
domainExtent = getObservationConstellation().getFeatureOfInterest().getGmlId();
}
if (geometry != null) {
cvDiscretePointCoverage.setDomainExtent("#" + geometry.getGeometryType() + "_" + domainExtent);
Point point = null;
if (geometry instanceof Point) {
point = (Point) geometry;
} else {
point = geometry.getCentroid();
}
cvDiscretePointCoverage.setValue(new PointValuePair(point, value.getValue()));
}
super.setValue(new SingleObservationValue<>(value.getPhenomenonTime(), cvDiscretePointCoverage));
}
}
Aggregations