Work around differences of opinion about the range of feature IDs

Geobuf uses signed 64-bit ints
Vector tile spec uses unsigned 64-bit ints
Geobuf silently corrupts IDs through use of floating point
This commit is contained in:
Eric Fischer
2017-08-30 14:34:59 -07:00
parent f65faaf3da
commit 076dfcdfeb
3 changed files with 60 additions and 46 deletions
+15 -1
View File
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <string>
#include <limits.h>
#include "mvt.hpp"
#include "serial.hpp"
#include "geobuf.hpp"
@@ -279,8 +280,16 @@ void readFeature(protozero::pbf_reader &pbf, size_t dim, double e, std::vector<s
}
case 12:
id = pbf.get_int64();
has_id = true;
id = pbf.get_sint64();
if (id < 0) {
static bool warned = false;
if (!warned) {
fprintf(stderr, "Out of range feature id %lld\n", id);
warned = true;
}
has_id = false;
}
break;
case 13: {
@@ -380,6 +389,11 @@ void readFeature(protozero::pbf_reader &pbf, size_t dim, double e, std::vector<s
sf.has_tippecanoe_maxzoom = true;
sf.tippecanoe_maxzoom = atoi(max->string);
}
json_object *tlayer = json_hash_get(o, "layer");
if (tlayer != NULL && (tlayer->type == JSON_STRING || tlayer->type == JSON_NUMBER)) {
sf.layername = tlayer->string;
}
}
json_free(o);