Move parseValue(pbf) to vector_tile.cpp

This code is specific to the vector tile format.
This commit is contained in:
John Firebaugh
2015-03-10 12:12:01 -07:00
parent 9e1f17a25b
commit c13227e35f
3 changed files with 30 additions and 30 deletions

View File

@@ -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);
}
}