Support feature IDs for decoding

This commit is contained in:
Eric Fischer 2016-07-15 13:58:15 -07:00
parent a1f8564631
commit 2bc1b9bd91
3 changed files with 17 additions and 0 deletions

View File

@ -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) {

View File

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

View File

@ -25,6 +25,13 @@ struct mvt_feature {
std::vector<unsigned> tags;
std::vector<mvt_geometry> geometry;
int /* mvt_geometry_type */ type;
unsigned long long id;
bool has_id;
mvt_feature() {
has_id = false;
id = 0;
}
};
enum mvt_value_type {