use of net.opengis.waterml.x20.TVPMeasurementMetadataType in project arctic-sea by 52North.
the class TrajectoryObservationTypeEncoder method createMeasurementTimeseries.
/**
* Encode {@link AbstractObservationValue} to
* {@link MeasurementTimeseriesDocument}
*
* @param observationValue
* The {@link AbstractObservationValue} to encode
* @return The encoded {@link AbstractObservationValue}
* @throws EncodingException
* If an error occurs
*/
private XmlObject createMeasurementTimeseries(AbstractObservationValue<?> observationValue) throws EncodingException {
MeasurementTimeseriesDocument measurementTimeseriesDoc = MeasurementTimeseriesDocument.Factory.newInstance();
MeasurementTimeseriesType measurementTimeseries = measurementTimeseriesDoc.addNewMeasurementTimeseries();
if (!observationValue.isSetObservationID()) {
observationValue.setObservationID(JavaHelper.generateID(observationValue.toString()));
}
measurementTimeseries.setId(TIMESERIES_PREFIX + observationValue.getObservationID());
measurementTimeseries.addNewMetadata().addNewTimeseriesMetadata().addNewTemporalExtent().setHref("#" + observationValue.getPhenomenonTime().getGmlId());
TVPDefaultMetadataPropertyType xbMetaComponent = measurementTimeseries.addNewDefaultPointMetadata();
DefaultTVPMeasurementMetadataDocument xbDefMeasureMetaComponent = DefaultTVPMeasurementMetadataDocument.Factory.newInstance();
TVPMeasurementMetadataType defaultTVPMeasurementMetadata = xbDefMeasureMetaComponent.addNewDefaultTVPMeasurementMetadata();
defaultTVPMeasurementMetadata.addNewInterpolationType().setHref("http://www.opengis.net/def/timeseriesType/WaterML/2.0/continuous");
xbDefMeasureMetaComponent.getDefaultTVPMeasurementMetadata().getInterpolationType().setTitle("Instantaneous");
String unit = null;
if (observationValue instanceof SingleObservationValue) {
SingleObservationValue<?> singleObservationValue = (SingleObservationValue<?>) observationValue;
unit = singleObservationValue.getValue().getUnit();
if (observationValue.getValue() instanceof TimeLocationValueTriple) {
measurementTimeseries.addNewPoint().addNewMeasurementTVP().set(encodeTLVT((TimeLocationValueTriple) observationValue.getValue()));
}
} else if (observationValue instanceof MultiObservationValues) {
MultiObservationValues<?> multiObservationValue = (MultiObservationValues<?>) observationValue;
if (multiObservationValue.getValue() instanceof TLVTValue) {
TLVTValue tlvtValue = (TLVTValue) multiObservationValue.getValue();
List<TimeLocationValueTriple> timeLocationValueTriples = tlvtValue.getValue();
unit = tlvtValue.getUnit();
int counter = 0;
for (TimeLocationValueTriple timeLocationValueTriple : timeLocationValueTriples) {
timeLocationValueTriple.getLocation().setUserData(getUserObject(observationValue.getObservationID(), counter));
measurementTimeseries.addNewPoint().addNewMeasurementTVP().set(encodeTLVT(timeLocationValueTriple));
counter++;
}
}
}
if (unit != null && !unit.isEmpty()) {
defaultTVPMeasurementMetadata.addNewUom().setCode(unit);
}
xbMetaComponent.set(xbDefMeasureMetaComponent);
return measurementTimeseriesDoc;
}
use of net.opengis.waterml.x20.TVPMeasurementMetadataType in project arctic-sea by 52North.
the class WmlTVPEncoderv20 method createMeasurementTimeseries.
/**
* Create a XML MeasurementTimeseries object from SOS observation for
* om:result
*
* @param sosObservation
* SOS observation
*
* @return XML MeasurementTimeseries object
*
* @throws CodedException
* if the encoding fails
*/
private XmlObject createMeasurementTimeseries(OmObservation sosObservation) throws OwsExceptionReport {
MeasurementTimeseriesDocument measurementTimeseriesDoc = MeasurementTimeseriesDocument.Factory.newInstance();
MeasurementTimeseriesType measurementTimeseries = measurementTimeseriesDoc.addNewMeasurementTimeseries();
measurementTimeseries.setId(TIMESERIES_ID_PREFIX + sosObservation.getObservationID());
// Default value
TimeseriesMetadata timeseriesMetadata = new MeasurementTimeseriesMetadata().setCumulative(false);
if (sosObservation.isSetValue() && sosObservation.getValue().isSetValue() && sosObservation.getValue().getValue().getClass().isAssignableFrom(TVPValue.class) && sosObservation.getObservationConstellation().isSetMetadata() && sosObservation.getObservationConstellation().getMetadata().isSetTimeseriesMetadata()) {
timeseriesMetadata = sosObservation.getObservationConstellation().getMetadata().getTimeseriesmetadata();
}
addTimeseriesMetadata(measurementTimeseries, sosObservation.getPhenomenonTime().getGmlId(), timeseriesMetadata);
TVPDefaultMetadataPropertyType xbMetaComponent = measurementTimeseries.addNewDefaultPointMetadata();
DefaultTVPMeasurementMetadataDocument xbDefMeasureMetaComponent = DefaultTVPMeasurementMetadataDocument.Factory.newInstance();
TVPMeasurementMetadataType defaultTVPMeasurementMetadata = xbDefMeasureMetaComponent.addNewDefaultTVPMeasurementMetadata();
// Default value
InterpolationType interpolationType = InterpolationType.Continuous;
if (sosObservation.isSetValue() && sosObservation.getValue().isSetValue() && sosObservation.getObservationConstellation().isSetDefaultPointMetadata() && sosObservation.getObservationConstellation().getDefaultPointMetadata().isSetDefaultTVPMeasurementMetadata() && sosObservation.getObservationConstellation().getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().isSetInterpolationType()) {
interpolationType = sosObservation.getObservationConstellation().getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().getInterpolationtype();
}
defaultTVPMeasurementMetadata.addNewInterpolationType().setHref(interpolationType.getIdentifier());
xbDefMeasureMetaComponent.getDefaultTVPMeasurementMetadata().getInterpolationType().setTitle(interpolationType.getTitle());
String unit = addValues(measurementTimeseries, sosObservation.getValue());
// set uom
if (unit != null && !unit.isEmpty()) {
defaultTVPMeasurementMetadata.addNewUom().setCode(unit);
} else {
OmObservableProperty observableProperty = (OmObservableProperty) sosObservation.getObservationConstellation().getObservableProperty();
if (observableProperty.isSetUnit()) {
defaultTVPMeasurementMetadata.addNewUom().setCode(observableProperty.getUnit());
}
}
xbMetaComponent.set(xbDefMeasureMetaComponent);
return measurementTimeseriesDoc;
}
use of net.opengis.waterml.x20.TVPMeasurementMetadataType in project arctic-sea by 52North.
the class WmlTVPEncoderv20 method createMeasurementTimeseries.
private XmlObject createMeasurementTimeseries(AbstractObservationValue<?> observationValue) throws CodedException {
MeasurementTimeseriesDocument measurementTimeseriesDoc = MeasurementTimeseriesDocument.Factory.newInstance();
MeasurementTimeseriesType measurementTimeseries = measurementTimeseriesDoc.addNewMeasurementTimeseries();
measurementTimeseries.setId(TIMESERIES_ID_PREFIX + observationValue.getObservationID());
// Default value
TimeseriesMetadata timeseriesMetadata = new MeasurementTimeseriesMetadata().setCumulative(false);
if (observationValue.isSetValue() && observationValue.isSetMetadata() && observationValue.getMetadata().isSetTimeseriesMetadata()) {
timeseriesMetadata = observationValue.getMetadata().getTimeseriesmetadata();
}
addTimeseriesMetadata(measurementTimeseries, observationValue.getPhenomenonTime().getGmlId(), timeseriesMetadata);
TVPDefaultMetadataPropertyType xbMetaComponent = measurementTimeseries.addNewDefaultPointMetadata();
DefaultTVPMeasurementMetadataDocument xbDefMeasureMetaComponent = DefaultTVPMeasurementMetadataDocument.Factory.newInstance();
TVPMeasurementMetadataType defaultTVPMeasurementMetadata = xbDefMeasureMetaComponent.addNewDefaultTVPMeasurementMetadata();
// Default value
InterpolationType interpolationType = InterpolationType.Continuous;
if (observationValue.isSetValue() && observationValue.isSetDefaultPointMetadata() && observationValue.getDefaultPointMetadata().isSetDefaultTVPMeasurementMetadata() && observationValue.getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().isSetInterpolationType()) {
interpolationType = observationValue.getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().getInterpolationtype();
}
defaultTVPMeasurementMetadata.addNewInterpolationType().setHref(interpolationType.getIdentifier());
xbDefMeasureMetaComponent.getDefaultTVPMeasurementMetadata().getInterpolationType().setTitle(interpolationType.getTitle());
String unit = addValues(measurementTimeseries, observationValue);
// set uom
if (unit != null && !unit.isEmpty()) {
defaultTVPMeasurementMetadata.addNewUom().setCode(unit);
// } else {
// OmObservableProperty observableProperty =
// (OmObservableProperty)
// sosObservation.getObservationConstellation().getObservableProperty();
// if (observableProperty.isSetUnit()) {
// defaultTVPMeasurementMetadata.addNewUom().setCode(observableProperty.getUnit());
// }
}
xbMetaComponent.set(xbDefMeasureMetaComponent);
return measurementTimeseriesDoc;
}
Aggregations