diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2015-03-10 12:12:01 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2015-03-10 12:14:13 -0700 |
commit | c13227e35f930c9e142006e03267469451528a3d (patch) | |
tree | 40d7487d618501355bf368dc34af2d29a238b300 /src | |
parent | 9e1f17a25b758e9e9046f62ffb03b1b722f6d453 (diff) | |
download | qtlocation-mapboxgl-c13227e35f930c9e142006e03267469451528a3d.tar.gz |
Move parseValue(pbf) to vector_tile.cpp
This code is specific to the vector tile format.
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/map/vector_tile.cpp | 31 | ||||
-rw-r--r-- | src/mbgl/style/value.cpp | 27 | ||||
-rw-r--r-- | src/mbgl/style/value.hpp | 2 |
3 files changed, 30 insertions, 30 deletions
diff --git a/src/mbgl/map/vector_tile.cpp b/src/mbgl/map/vector_tile.cpp index e9ae52e9ad..e0f6c2d733 100644 --- a/src/mbgl/map/vector_tile.cpp +++ b/src/mbgl/map/vector_tile.cpp @@ -1,6 +1,33 @@ #include <mbgl/map/vector_tile.hpp> -using namespace mbgl; +namespace mbgl { + +Value parseValue(pbf data) { + while (data.next()) + { + switch (data.tag) + { + case 1: // string_value + return data.string(); + case 2: // float_value + return static_cast<double>(data.float32()); + case 3: // double_value + return data.float64(); + case 4: // int_value + return data.varint<int64_t>(); + case 5: // uint_value + return data.varint<uint64_t>(); + case 6: // sint_value + return data.svarint<int64_t>(); + case 7: // bool_value + return data.boolean(); + default: + data.skip(); + break; + } + } + return false; +} VectorTileFeature::VectorTileFeature(pbf feature_pbf, const VectorTileLayer& layer) { while (feature_pbf.next()) { @@ -130,3 +157,5 @@ VectorTileLayer::VectorTileLayer(pbf layer_pbf) { util::ptr<const GeometryTileFeature> VectorTileLayer::feature(std::size_t i) const { return std::make_shared<VectorTileFeature>(features.at(i), *this); } + +} diff --git a/src/mbgl/style/value.cpp b/src/mbgl/style/value.cpp index ae51ce3783..41730470ed 100644 --- a/src/mbgl/style/value.cpp +++ b/src/mbgl/style/value.cpp @@ -1,33 +1,6 @@ #include <mbgl/style/value.hpp> #include <mbgl/util/string.hpp> -mbgl::Value mbgl::parseValue(pbf data) { - while (data.next()) - { - switch (data.tag) - { - case 1: // string_value - return data.string(); - case 2: // float_value - return static_cast<double>(data.float32()); - case 3: // double_value - return data.float64(); - case 4: // int_value - return data.varint<int64_t>(); - case 5: // uint_value - return data.varint<uint64_t>(); - case 6: // sint_value - return data.svarint<int64_t>(); - case 7: // bool_value - return data.boolean(); - default: - data.skip(); - break; - } - } - return false; -} - std::string mbgl::toString(const mbgl::Value& value) { if (value.is<std::string>()) return value.get<std::string>(); else if (value.is<bool>()) return value.get<bool>() ? "true" : "false"; diff --git a/src/mbgl/style/value.hpp b/src/mbgl/style/value.hpp index 87d6f4cda3..8b0b21c20c 100644 --- a/src/mbgl/style/value.hpp +++ b/src/mbgl/style/value.hpp @@ -2,7 +2,6 @@ #define MBGL_STYLE_VALUE #include <mbgl/util/variant.hpp> -#include <mbgl/util/pbf.hpp> #include <rapidjson/document.h> #include <cstdlib> @@ -14,7 +13,6 @@ typedef mapbox::util::variant<bool, int64_t, uint64_t, double, std::string> Valu std::string toString(const Value &value); -Value parseValue(pbf data); Value parseValue(const rapidjson::Value&); namespace util { |