diff --git a/decode.cpp b/decode.cpp index 3b90100d..8a9bbc28 100644 --- a/decode.cpp +++ b/decode.cpp @@ -102,6 +102,11 @@ void handle(std::string message, int z, unsigned x, unsigned y, int describe) { within = 1; printf("{ \"type\": \"Feature\""); + + if (feat.has_id) { + printf(", \"id\": %llu", feat.id); + } + printf(", \"properties\": { "); for (size_t t = 0; t + 1 < feat.tags.size(); t += 2) { diff --git a/mvt.cpp b/mvt.cpp index 669a58de..92d49717 100644 --- a/mvt.cpp +++ b/mvt.cpp @@ -178,6 +178,11 @@ bool mvt_tile::decode(std::string &message) { while (feature_reader.next()) { switch (feature_reader.tag()) { + case 1: /* id */ + feature.id = feature_reader.get_uint64(); + feature.has_id = true; + break; + case 2: /* tag */ { auto pi = feature_reader.get_packed_uint32(); diff --git a/mvt.hpp b/mvt.hpp index 386fae1f..ff074677 100644 --- a/mvt.hpp +++ b/mvt.hpp @@ -25,6 +25,13 @@ struct mvt_feature { std::vector tags; std::vector geometry; int /* mvt_geometry_type */ type; + unsigned long long id; + bool has_id; + + mvt_feature() { + has_id = false; + id = 0; + } }; enum mvt_value_type {