summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-05-31 09:03:02 -0700
committerMinh Nguyễn <mxn@1ec5.org>2016-06-01 12:07:53 -0700
commitfcacbb87ef9a808bf3554e60c978710c04cff9f5 (patch)
tree097437937cff9bf6f5dc09955a543b7b94c1a342
parentf7ce5b3a7b16f1152059b9fb519993b0fa680267 (diff)
downloadqtlocation-mapboxgl-fcacbb87ef9a808bf3554e60c978710c04cff9f5.tar.gz
[core] Store feature keys in same order as in vector tile
The keys in the vector tile may not be in alphabetical order. Building a vector of keys by looping over std::map<std::string, …> effectively sorts the keys by alphabetical order without sorting the associated values. This change inserts keys in the same order in which they appear in the vector tile.
-rw-r--r--package.json2
-rw-r--r--src/mbgl/tile/vector_tile.cpp9
2 files changed, 5 insertions, 6 deletions
diff --git a/package.json b/package.json
index 7620e1d9d5..b205aee693 100644
--- a/package.json
+++ b/package.json
@@ -20,7 +20,7 @@
"aws-sdk": "^2.3.5",
"express": "^4.11.1",
"mapbox-gl-shaders": "mapbox/mapbox-gl-shaders#36278b864e60e1dba937a6863064c03d69526854",
- "mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#b3441d9a285ffbe9b876677acb13d7df07e5b975",
+ "mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#f45fd7aba98650c7f3bf778c9cbbfd3b548a4ee8",
"node-gyp": "^3.3.1",
"request": "^2.72.0",
"tape": "^4.5.1"
diff --git a/src/mbgl/tile/vector_tile.cpp b/src/mbgl/tile/vector_tile.cpp
index 4af6a12271..8a69a82314 100644
--- a/src/mbgl/tile/vector_tile.cpp
+++ b/src/mbgl/tile/vector_tile.cpp
@@ -191,7 +191,10 @@ VectorTileLayer::VectorTileLayer(protozero::pbf_reader layer_pbf) {
features.push_back(layer_pbf.get_message());
break;
case 3: // keys
- keysMap.emplace(layer_pbf.get_string(), keysMap.size());
+ {
+ auto iter = keysMap.emplace(layer_pbf.get_string(), keysMap.size());
+ keys.emplace_back(std::reference_wrapper<const std::string>(iter.first->first));
+ }
break;
case 4: // values
values.emplace_back(parseValue(layer_pbf.get_message()));
@@ -207,10 +210,6 @@ VectorTileLayer::VectorTileLayer(protozero::pbf_reader layer_pbf) {
break;
}
}
-
- for (auto &pair : keysMap) {
- keys.emplace_back(std::reference_wrapper<const std::string>(pair.first));
- }
}
util::ptr<const GeometryTileFeature> VectorTileLayer::getFeature(std::size_t i) const {