mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
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:
+15
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user