summaryrefslogtreecommitdiff
path: root/include/mbgl/util/feature.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/mbgl/util/feature.hpp')
-rw-r--r--include/mbgl/util/feature.hpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/mbgl/util/feature.hpp b/include/mbgl/util/feature.hpp
index 9e2286018c..390cc65720 100644
--- a/include/mbgl/util/feature.hpp
+++ b/include/mbgl/util/feature.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <mbgl/util/optional.hpp>
+#include <mbgl/util/string.hpp>
#include <mapbox/feature.hpp>
@@ -11,6 +12,9 @@ using NullValue = mapbox::feature::null_value_t;
using PropertyMap = mapbox::feature::property_map;
using FeatureIdentifier = mapbox::feature::identifier;
using Feature = mapbox::feature::feature<double>;
+using FeatureState = PropertyMap;
+using FeatureStates = std::unordered_map<std::string, FeatureState>; // <featureID, FeatureState>
+using LayerFeatureStates = std::unordered_map<std::string, FeatureStates>; // <sourceLayer, FeatureStates>
template <class T>
optional<T> numericValue(const Value& value) {
@@ -29,4 +33,15 @@ optional<T> numericValue(const Value& value) {
});
}
+inline optional<std::string> featureIDtoString(const FeatureIdentifier& id) {
+ if (id.is<NullValue>()) {
+ return nullopt;
+ }
+
+ return id.match(
+ [](const std::string& value_) { return value_; }, [](uint64_t value_) { return util::toString(value_); },
+ [](int64_t value_) { return util::toString(value_); }, [](double value_) { return util::toString(value_); },
+ [](const auto&) -> optional<std::string> { return nullopt; });
+}
+
} // namespace mbgl