use of net.opengis.waterml.x20.CategoricalTimeseriesDocument in project arctic-sea by 52North.
the class TrajectoryObservationTypeEncoder method createCategoricalTimeseries.
/**
* Encode {@link AbstractObservationValue} to
* {@link CategoricalTimeseriesDocument}
*
* @param observationValue
* The {@link AbstractObservationValue} to encode
* @return The encoded {@link AbstractObservationValue}
* @throws EncodingException
* If an error occurs
*/
private XmlObject createCategoricalTimeseries(AbstractObservationValue<?> observationValue) throws EncodingException {
CategoricalTimeseriesDocument categoricalTimeseriesDoc = CategoricalTimeseriesDocument.Factory.newInstance();
CategoricalTimeseriesType categoricalTimeseries = categoricalTimeseriesDoc.addNewCategoricalTimeseries();
categoricalTimeseries.setId(TIMESERIES_PREFIX + observationValue.getObservationID());
categoricalTimeseries.addNewMetadata().addNewTimeseriesMetadata().addNewTemporalExtent().setHref("#" + observationValue.getPhenomenonTime().getGmlId());
TVPDefaultMetadataPropertyType xbMetaComponent = categoricalTimeseries.addNewDefaultPointMetadata();
DefaultTVPCategoricalMetadataDocument xbDefCateMetaComponent = DefaultTVPCategoricalMetadataDocument.Factory.newInstance();
DefaultCategoricalTVPMetadataType defaultTVPCateMetadata = xbDefCateMetaComponent.addNewDefaultTVPCategoricalMetadata();
String unit = null;
if (observationValue instanceof SingleObservationValue) {
SingleObservationValue<?> singleObservationValue = (SingleObservationValue<?>) observationValue;
unit = singleObservationValue.getValue().getUnit();
if (observationValue.getValue() instanceof TimeLocationValueTriple) {
categoricalTimeseries.addNewPoint().addNewCategoricalTVP().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));
categoricalTimeseries.addNewPoint().addNewCategoricalTVP().set(encodeTLVT(timeLocationValueTriple));
counter++;
}
}
}
if (unit != null && !unit.isEmpty()) {
defaultTVPCateMetadata.setCodeSpace(unit);
}
xbMetaComponent.set(xbDefCateMetaComponent);
return categoricalTimeseriesDoc;
}
Aggregations