mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-02-23 18:40:17 +00:00
Ignore leading zeroes when converting string attributes to feature IDs
This commit is contained in:
parent
949468e6f5
commit
f9c9ff3853
@ -1,3 +1,7 @@
|
|||||||
|
## 1.32.4
|
||||||
|
|
||||||
|
* Ignore leading zeroes when converting string attributes to feature IDs
|
||||||
|
|
||||||
## 1.32.3
|
## 1.32.3
|
||||||
|
|
||||||
* Add an option to convert stringified number feature IDs to numbers
|
* Add an option to convert stringified number feature IDs to numbers
|
||||||
|
13
serial.cpp
13
serial.cpp
@ -373,6 +373,17 @@ static long long scale_geometry(struct serialization_state *sst, long long *bbox
|
|||||||
return geom.size();
|
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
|
// called from frontends
|
||||||
int serialize_feature(struct serialization_state *sst, serial_feature &sf) {
|
int serialize_feature(struct serialization_state *sst, serial_feature &sf) {
|
||||||
struct reader *r = &(*sst->readers)[sst->segment];
|
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());
|
fprintf(stderr, "Warning: Can't represent non-integer feature ID %s\n", sf.full_values[i].s.c_str());
|
||||||
warned_frac = true;
|
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;
|
static bool warned = false;
|
||||||
|
|
||||||
if (!warned) {
|
if (!warned) {
|
||||||
|
@ -9,3 +9,4 @@
|
|||||||
{ "type": "Feature", "id": 1234, "properties": { "yes": "no", "special": 27.5, "something": false }, "geometry": { "type": "Point", "coordinates": [ 9, 1 ] } }
|
{ "type": "Feature", "id": 1234, "properties": { "yes": "no", "special": 27.5, "something": false }, "geometry": { "type": "Point", "coordinates": [ 9, 1 ] } }
|
||||||
{ "type": "Feature", "id": 1234, "properties": { "yes": "no", "special": 98237489273489274389728497289472839478297489274892734892, "something": false }, "geometry": { "type": "Point", "coordinates": [ 10, 1 ] } }
|
{ "type": "Feature", "id": 1234, "properties": { "yes": "no", "special": 98237489273489274389728497289472839478297489274892734892, "something": false }, "geometry": { "type": "Point", "coordinates": [ 10, 1 ] } }
|
||||||
{ "type": "Feature", "properties": { "yes": "no", "special": 27, "something": false }, "geometry": { "type": "Point", "coordinates": [ 11, 1 ] } }
|
{ "type": "Feature", "properties": { "yes": "no", "special": 27, "something": false }, "geometry": { "type": "Point", "coordinates": [ 11, 1 ] } }
|
||||||
|
{ "type": "Feature", "properties": { "yes": "no", "special": "01005", "something": false }, "geometry": { "type": "Point", "coordinates": [ 12, 1 ] } }
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{ "type": "FeatureCollection", "properties": {
|
{ "type": "FeatureCollection", "properties": {
|
||||||
"bounds": "1.000000,1.000000,11.000000,1.000000",
|
"bounds": "1.000000,1.000000,12.000000,1.000000",
|
||||||
"center": "1.000000,1.000000,0",
|
"center": "1.000000,1.000000,0",
|
||||||
"description": "tests/stringid/out/-z0.json.check.mbtiles",
|
"description": "tests/stringid/out/-z0.json.check.mbtiles",
|
||||||
"format": "pbf",
|
"format": "pbf",
|
||||||
"json": "{\"vector_layers\": [ { \"id\": \"in\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 0, \"fields\": {\"something\": \"Boolean\", \"special\": \"Mixed\", \"yes\": \"String\"} } ],\"tilestats\": {\"layerCount\": 1,\"layers\": [{\"layer\": \"in\",\"count\": 11,\"geometry\": \"Point\",\"attributeCount\": 3,\"attributes\": [{\"attribute\": \"something\",\"count\": 1,\"type\": \"boolean\",\"values\": [false]},{\"attribute\": \"special\",\"count\": 4,\"type\": \"mixed\",\"values\": [\"27\",27,27.5,9.823748927348929e+55],\"min\": 27,\"max\": 9.823748927348929e+55},{\"attribute\": \"yes\",\"count\": 1,\"type\": \"string\",\"values\": [\"no\"]}]}]}}",
|
"json": "{\"vector_layers\": [ { \"id\": \"in\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 0, \"fields\": {\"something\": \"Boolean\", \"special\": \"Mixed\", \"yes\": \"String\"} } ],\"tilestats\": {\"layerCount\": 1,\"layers\": [{\"layer\": \"in\",\"count\": 12,\"geometry\": \"Point\",\"attributeCount\": 3,\"attributes\": [{\"attribute\": \"something\",\"count\": 1,\"type\": \"boolean\",\"values\": [false]},{\"attribute\": \"special\",\"count\": 5,\"type\": \"mixed\",\"values\": [\"01005\",\"27\",27,27.5,9.823748927348929e+55],\"min\": 27,\"max\": 9.823748927348929e+55},{\"attribute\": \"yes\",\"count\": 1,\"type\": \"string\",\"values\": [\"no\"]}]}]}}",
|
||||||
"maxzoom": "0",
|
"maxzoom": "0",
|
||||||
"minzoom": "0",
|
"minzoom": "0",
|
||||||
"name": "tests/stringid/out/-z0.json.check.mbtiles",
|
"name": "tests/stringid/out/-z0.json.check.mbtiles",
|
||||||
@ -33,6 +33,8 @@
|
|||||||
{ "type": "Feature", "id": 1234, "properties": { "yes": "no", "special": 9.823748927348929e+55, "something": false }, "geometry": { "type": "Point", "coordinates": [ 9.931641, 1.054628 ] } }
|
{ "type": "Feature", "id": 1234, "properties": { "yes": "no", "special": 9.823748927348929e+55, "something": false }, "geometry": { "type": "Point", "coordinates": [ 9.931641, 1.054628 ] } }
|
||||||
,
|
,
|
||||||
{ "type": "Feature", "properties": { "yes": "no", "special": 27, "something": false }, "geometry": { "type": "Point", "coordinates": [ 10.986328, 1.054628 ] } }
|
{ "type": "Feature", "properties": { "yes": "no", "special": 27, "something": false }, "geometry": { "type": "Point", "coordinates": [ 10.986328, 1.054628 ] } }
|
||||||
|
,
|
||||||
|
{ "type": "Feature", "properties": { "yes": "no", "special": "01005", "something": false }, "geometry": { "type": "Point", "coordinates": [ 11.953125, 1.054628 ] } }
|
||||||
] }
|
] }
|
||||||
] }
|
] }
|
||||||
] }
|
] }
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{ "type": "FeatureCollection", "properties": {
|
{ "type": "FeatureCollection", "properties": {
|
||||||
"bounds": "1.000000,1.000000,11.000000,1.000000",
|
"bounds": "1.000000,1.000000,12.000000,1.000000",
|
||||||
"center": "1.000000,1.000000,0",
|
"center": "1.000000,1.000000,0",
|
||||||
"description": "tests/stringid/out/-z0_--use-attribute-for-id_special.json.check.mbtiles",
|
"description": "tests/stringid/out/-z0_--use-attribute-for-id_special.json.check.mbtiles",
|
||||||
"format": "pbf",
|
"format": "pbf",
|
||||||
"json": "{\"vector_layers\": [ { \"id\": \"in\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 0, \"fields\": {\"something\": \"Boolean\", \"special\": \"Mixed\", \"yes\": \"String\"} } ],\"tilestats\": {\"layerCount\": 1,\"layers\": [{\"layer\": \"in\",\"count\": 11,\"geometry\": \"Point\",\"attributeCount\": 3,\"attributes\": [{\"attribute\": \"something\",\"count\": 1,\"type\": \"boolean\",\"values\": [false]},{\"attribute\": \"special\",\"count\": 3,\"type\": \"mixed\",\"values\": [\"27\",27.5,9.823748927348929e+55],\"min\": 27.5,\"max\": 9.823748927348929e+55},{\"attribute\": \"yes\",\"count\": 1,\"type\": \"string\",\"values\": [\"no\"]}]}]}}",
|
"json": "{\"vector_layers\": [ { \"id\": \"in\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 0, \"fields\": {\"something\": \"Boolean\", \"special\": \"Mixed\", \"yes\": \"String\"} } ],\"tilestats\": {\"layerCount\": 1,\"layers\": [{\"layer\": \"in\",\"count\": 12,\"geometry\": \"Point\",\"attributeCount\": 3,\"attributes\": [{\"attribute\": \"something\",\"count\": 1,\"type\": \"boolean\",\"values\": [false]},{\"attribute\": \"special\",\"count\": 4,\"type\": \"mixed\",\"values\": [\"01005\",\"27\",27.5,9.823748927348929e+55],\"min\": 27.5,\"max\": 9.823748927348929e+55},{\"attribute\": \"yes\",\"count\": 1,\"type\": \"string\",\"values\": [\"no\"]}]}]}}",
|
||||||
"maxzoom": "0",
|
"maxzoom": "0",
|
||||||
"minzoom": "0",
|
"minzoom": "0",
|
||||||
"name": "tests/stringid/out/-z0_--use-attribute-for-id_special.json.check.mbtiles",
|
"name": "tests/stringid/out/-z0_--use-attribute-for-id_special.json.check.mbtiles",
|
||||||
@ -33,6 +33,8 @@
|
|||||||
{ "type": "Feature", "id": 1234, "properties": { "yes": "no", "special": 9.823748927348929e+55, "something": false }, "geometry": { "type": "Point", "coordinates": [ 9.931641, 1.054628 ] } }
|
{ "type": "Feature", "id": 1234, "properties": { "yes": "no", "special": 9.823748927348929e+55, "something": false }, "geometry": { "type": "Point", "coordinates": [ 9.931641, 1.054628 ] } }
|
||||||
,
|
,
|
||||||
{ "type": "Feature", "id": 27, "properties": { "yes": "no", "something": false }, "geometry": { "type": "Point", "coordinates": [ 10.986328, 1.054628 ] } }
|
{ "type": "Feature", "id": 27, "properties": { "yes": "no", "something": false }, "geometry": { "type": "Point", "coordinates": [ 10.986328, 1.054628 ] } }
|
||||||
|
,
|
||||||
|
{ "type": "Feature", "properties": { "yes": "no", "special": "01005", "something": false }, "geometry": { "type": "Point", "coordinates": [ 11.953125, 1.054628 ] } }
|
||||||
] }
|
] }
|
||||||
] }
|
] }
|
||||||
] }
|
] }
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{ "type": "FeatureCollection", "properties": {
|
{ "type": "FeatureCollection", "properties": {
|
||||||
"bounds": "1.000000,1.000000,11.000000,1.000000",
|
"bounds": "1.000000,1.000000,12.000000,1.000000",
|
||||||
"center": "1.000000,1.000000,0",
|
"center": "1.000000,1.000000,0",
|
||||||
"description": "tests/stringid/out/-z0_-aI.json.check.mbtiles",
|
"description": "tests/stringid/out/-z0_-aI.json.check.mbtiles",
|
||||||
"format": "pbf",
|
"format": "pbf",
|
||||||
"json": "{\"vector_layers\": [ { \"id\": \"in\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 0, \"fields\": {\"something\": \"Boolean\", \"special\": \"Mixed\", \"yes\": \"String\"} } ],\"tilestats\": {\"layerCount\": 1,\"layers\": [{\"layer\": \"in\",\"count\": 11,\"geometry\": \"Point\",\"attributeCount\": 3,\"attributes\": [{\"attribute\": \"something\",\"count\": 1,\"type\": \"boolean\",\"values\": [false]},{\"attribute\": \"special\",\"count\": 4,\"type\": \"mixed\",\"values\": [\"27\",27,27.5,9.823748927348929e+55],\"min\": 27,\"max\": 9.823748927348929e+55},{\"attribute\": \"yes\",\"count\": 1,\"type\": \"string\",\"values\": [\"no\"]}]}]}}",
|
"json": "{\"vector_layers\": [ { \"id\": \"in\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 0, \"fields\": {\"something\": \"Boolean\", \"special\": \"Mixed\", \"yes\": \"String\"} } ],\"tilestats\": {\"layerCount\": 1,\"layers\": [{\"layer\": \"in\",\"count\": 12,\"geometry\": \"Point\",\"attributeCount\": 3,\"attributes\": [{\"attribute\": \"something\",\"count\": 1,\"type\": \"boolean\",\"values\": [false]},{\"attribute\": \"special\",\"count\": 5,\"type\": \"mixed\",\"values\": [\"01005\",\"27\",27,27.5,9.823748927348929e+55],\"min\": 27,\"max\": 9.823748927348929e+55},{\"attribute\": \"yes\",\"count\": 1,\"type\": \"string\",\"values\": [\"no\"]}]}]}}",
|
||||||
"maxzoom": "0",
|
"maxzoom": "0",
|
||||||
"minzoom": "0",
|
"minzoom": "0",
|
||||||
"name": "tests/stringid/out/-z0_-aI.json.check.mbtiles",
|
"name": "tests/stringid/out/-z0_-aI.json.check.mbtiles",
|
||||||
@ -33,6 +33,8 @@
|
|||||||
{ "type": "Feature", "id": 1234, "properties": { "yes": "no", "special": 9.823748927348929e+55, "something": false }, "geometry": { "type": "Point", "coordinates": [ 9.931641, 1.054628 ] } }
|
{ "type": "Feature", "id": 1234, "properties": { "yes": "no", "special": 9.823748927348929e+55, "something": false }, "geometry": { "type": "Point", "coordinates": [ 9.931641, 1.054628 ] } }
|
||||||
,
|
,
|
||||||
{ "type": "Feature", "properties": { "yes": "no", "special": 27, "something": false }, "geometry": { "type": "Point", "coordinates": [ 10.986328, 1.054628 ] } }
|
{ "type": "Feature", "properties": { "yes": "no", "special": 27, "something": false }, "geometry": { "type": "Point", "coordinates": [ 10.986328, 1.054628 ] } }
|
||||||
|
,
|
||||||
|
{ "type": "Feature", "properties": { "yes": "no", "special": "01005", "something": false }, "geometry": { "type": "Point", "coordinates": [ 11.953125, 1.054628 ] } }
|
||||||
] }
|
] }
|
||||||
] }
|
] }
|
||||||
] }
|
] }
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{ "type": "FeatureCollection", "properties": {
|
{ "type": "FeatureCollection", "properties": {
|
||||||
"bounds": "1.000000,1.000000,11.000000,1.000000",
|
"bounds": "1.000000,1.000000,12.000000,1.000000",
|
||||||
"center": "1.000000,1.000000,0",
|
"center": "1.000000,1.000000,0",
|
||||||
"description": "tests/stringid/out/-z0_-aI_--use-attribute-for-id_special.json.check.mbtiles",
|
"description": "tests/stringid/out/-z0_-aI_--use-attribute-for-id_special.json.check.mbtiles",
|
||||||
"format": "pbf",
|
"format": "pbf",
|
||||||
"json": "{\"vector_layers\": [ { \"id\": \"in\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 0, \"fields\": {\"something\": \"Boolean\", \"special\": \"Number\", \"yes\": \"String\"} } ],\"tilestats\": {\"layerCount\": 1,\"layers\": [{\"layer\": \"in\",\"count\": 11,\"geometry\": \"Point\",\"attributeCount\": 3,\"attributes\": [{\"attribute\": \"something\",\"count\": 1,\"type\": \"boolean\",\"values\": [false]},{\"attribute\": \"special\",\"count\": 2,\"type\": \"number\",\"values\": [27.5,9.823748927348929e+55],\"min\": 27.5,\"max\": 9.823748927348929e+55},{\"attribute\": \"yes\",\"count\": 1,\"type\": \"string\",\"values\": [\"no\"]}]}]}}",
|
"json": "{\"vector_layers\": [ { \"id\": \"in\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 0, \"fields\": {\"something\": \"Boolean\", \"special\": \"Number\", \"yes\": \"String\"} } ],\"tilestats\": {\"layerCount\": 1,\"layers\": [{\"layer\": \"in\",\"count\": 12,\"geometry\": \"Point\",\"attributeCount\": 3,\"attributes\": [{\"attribute\": \"something\",\"count\": 1,\"type\": \"boolean\",\"values\": [false]},{\"attribute\": \"special\",\"count\": 2,\"type\": \"number\",\"values\": [27.5,9.823748927348929e+55],\"min\": 27.5,\"max\": 9.823748927348929e+55},{\"attribute\": \"yes\",\"count\": 1,\"type\": \"string\",\"values\": [\"no\"]}]}]}}",
|
||||||
"maxzoom": "0",
|
"maxzoom": "0",
|
||||||
"minzoom": "0",
|
"minzoom": "0",
|
||||||
"name": "tests/stringid/out/-z0_-aI_--use-attribute-for-id_special.json.check.mbtiles",
|
"name": "tests/stringid/out/-z0_-aI_--use-attribute-for-id_special.json.check.mbtiles",
|
||||||
@ -33,6 +33,8 @@
|
|||||||
{ "type": "Feature", "id": 1234, "properties": { "yes": "no", "special": 9.823748927348929e+55, "something": false }, "geometry": { "type": "Point", "coordinates": [ 9.931641, 1.054628 ] } }
|
{ "type": "Feature", "id": 1234, "properties": { "yes": "no", "special": 9.823748927348929e+55, "something": false }, "geometry": { "type": "Point", "coordinates": [ 9.931641, 1.054628 ] } }
|
||||||
,
|
,
|
||||||
{ "type": "Feature", "id": 27, "properties": { "yes": "no", "something": false }, "geometry": { "type": "Point", "coordinates": [ 10.986328, 1.054628 ] } }
|
{ "type": "Feature", "id": 27, "properties": { "yes": "no", "something": false }, "geometry": { "type": "Point", "coordinates": [ 10.986328, 1.054628 ] } }
|
||||||
|
,
|
||||||
|
{ "type": "Feature", "id": 1005, "properties": { "yes": "no", "something": false }, "geometry": { "type": "Point", "coordinates": [ 11.953125, 1.054628 ] } }
|
||||||
] }
|
] }
|
||||||
] }
|
] }
|
||||||
] }
|
] }
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#ifndef VERSION_HPP
|
#ifndef VERSION_HPP
|
||||||
#define VERSION_HPP
|
#define VERSION_HPP
|
||||||
|
|
||||||
#define VERSION "v1.32.3"
|
#define VERSION "v1.32.4"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user