mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Ignore leading zeroes when converting string attributes to feature IDs
This commit is contained in:
+12
-1
@@ -373,6 +373,17 @@ static long long scale_geometry(struct serialization_state *sst, long long *bbox
|
||||
return geom.size();
|
||||
}
|
||||
|
||||
static std::string strip_zeroes(std::string s) {
|
||||
// Doesn't do anything special with '-' followed by leading zeros
|
||||
// since integer IDs must be positive
|
||||
|
||||
while (s.size() > 0 && s[0] == '0') {
|
||||
s.erase(s.begin());
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
// called from frontends
|
||||
int serialize_feature(struct serialization_state *sst, serial_feature &sf) {
|
||||
struct reader *r = &(*sst->readers)[sst->segment];
|
||||
@@ -595,7 +606,7 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf) {
|
||||
fprintf(stderr, "Warning: Can't represent non-integer feature ID %s\n", sf.full_values[i].s.c_str());
|
||||
warned_frac = true;
|
||||
}
|
||||
} else if (std::to_string(id_value) != sf.full_values[i].s) {
|
||||
} else if (std::to_string(id_value) != strip_zeroes(sf.full_values[i].s)) {
|
||||
static bool warned = false;
|
||||
|
||||
if (!warned) {
|
||||
|
||||
Reference in New Issue
Block a user