Search in sources :

Example 1 with CategoricalTimeseriesType

use of net.opengis.waterml.x20.CategoricalTimeseriesType 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;
}
Also used : DefaultTVPCategoricalMetadataDocument(net.opengis.waterml.x20.DefaultTVPCategoricalMetadataDocument) CategoricalTimeseriesDocument(net.opengis.waterml.x20.CategoricalTimeseriesDocument) SingleObservationValue(org.n52.shetland.ogc.om.SingleObservationValue) TVPDefaultMetadataPropertyType(net.opengis.waterml.x20.TVPDefaultMetadataPropertyType) DefaultCategoricalTVPMetadataType(net.opengis.waterml.x20.DefaultCategoricalTVPMetadataType) List(java.util.List) CategoricalTimeseriesType(net.opengis.waterml.x20.CategoricalTimeseriesType) TLVTValue(org.n52.shetland.ogc.om.values.TLVTValue) TimeLocationValueTriple(org.n52.shetland.ogc.om.TimeLocationValueTriple) MultiObservationValues(org.n52.shetland.ogc.om.MultiObservationValues)

Aggregations

List (java.util.List)1 CategoricalTimeseriesDocument (net.opengis.waterml.x20.CategoricalTimeseriesDocument)1 CategoricalTimeseriesType (net.opengis.waterml.x20.CategoricalTimeseriesType)1 DefaultCategoricalTVPMetadataType (net.opengis.waterml.x20.DefaultCategoricalTVPMetadataType)1 DefaultTVPCategoricalMetadataDocument (net.opengis.waterml.x20.DefaultTVPCategoricalMetadataDocument)1 TVPDefaultMetadataPropertyType (net.opengis.waterml.x20.TVPDefaultMetadataPropertyType)1 MultiObservationValues (org.n52.shetland.ogc.om.MultiObservationValues)1 SingleObservationValue (org.n52.shetland.ogc.om.SingleObservationValue)1 TimeLocationValueTriple (org.n52.shetland.ogc.om.TimeLocationValueTriple)1 TLVTValue (org.n52.shetland.ogc.om.values.TLVTValue)1