summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAsheem Mamoowala <asheem.mamoowala@mapbox.com>2018-11-12 14:58:13 -0800
committerAsheem Mamoowala <asheem.mamoowala@mapbox.com>2018-11-12 14:58:13 -0800
commitf2bc00267cd6430f85763beeb03b98109ff7b023 (patch)
treec589e1f6cc0759d5806af3b01a5c4d3773232deb /include
parent9f3cc7b7075b29595dec394733b10fbd26f274e4 (diff)
downloadqtlocation-mapboxgl-upstream/feature-state-changesets.tar.gz
Prototype ChangeSets based approach to feature state.upstream/feature-state-changesets
- A change set keeps track of all feature state changes for a source between two render. - The change set is applied to the TilePyramid to update the full feature state map, and generate the map of update features for the single frame. The Front end renderer may throttle updates. This results in some changesets not making it to the renderer, and data in that set being dropped entirely. To workaround this the front end renderers would need to accumulate the changes, or some other way to collect all change sets between throttled frames.
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/style/sources/geojson_source.hpp5
-rw-r--r--include/mbgl/util/feature_state.hpp19
2 files changed, 22 insertions, 2 deletions
diff --git a/include/mbgl/style/sources/geojson_source.hpp b/include/mbgl/style/sources/geojson_source.hpp
index a03b910279..803588ac7e 100644
--- a/include/mbgl/style/sources/geojson_source.hpp
+++ b/include/mbgl/style/sources/geojson_source.hpp
@@ -2,8 +2,10 @@
#include <mbgl/style/source.hpp>
#include <mbgl/util/geojson.hpp>
+#include <mbgl/util/feature_state.hpp>
#include <mbgl/util/optional.hpp>
#include <mbgl/util/constants.hpp>
+#include <mbgl/util/immutable.hpp>
namespace mbgl {
@@ -33,6 +35,7 @@ public:
void setURL(const std::string& url);
void setGeoJSON(const GeoJSON&);
+ void setFeatureState(const FeatureIdentifier&, const std::string&, const mbgl::Value&);
optional<std::string> getURL() const;
@@ -41,9 +44,11 @@ public:
void loadDescription(FileSource&) final;
+ Immutable<std::vector<FeatureStateChange>> collectFeatureStates();
private:
optional<std::string> url;
std::unique_ptr<AsyncRequest> req;
+ Mutable<std::vector<FeatureStateChange>> stateChanges;
};
template <>
diff --git a/include/mbgl/util/feature_state.hpp b/include/mbgl/util/feature_state.hpp
index e97926c6e1..f63f3dcbff 100644
--- a/include/mbgl/util/feature_state.hpp
+++ b/include/mbgl/util/feature_state.hpp
@@ -15,17 +15,32 @@ struct FeatureStateChange {
};
ChangeType type;
+ std::string sourceLayer;
FeatureIdentifier id;
std::string key;
optional<Value> value;
FeatureStateChange(ChangeType type_,
- FeatureIdentifier&& id_,
- std::string&& key_,
+ const std::string& sourceLayer_,
+ const FeatureIdentifier& id_,
+ const std::string& key_,
optional<Value> value_) :
type(type_),
+ sourceLayer(sourceLayer_),
id(std::move(id_)),
key(std::move(key_)),
value(std::move(value_)) {}
+
+ FeatureStateChange(ChangeType type_,
+ const FeatureIdentifier& id_,
+ const std::string& key_,
+ optional<Value> value_) :
+ type(type_),
+ id(std::move(id_)),
+ key(std::move(key_)),
+ value(std::move(value_)) {}
+
};
+using FeatureStateChangeSet = std::vector<FeatureStateChange>;
+
} // namespace mbgl