mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-02-24 02:41:15 +00:00
Read string IDs at all, and use the right IDs when writing
This commit is contained in:
parent
bd186664ac
commit
13879d0fa1
@ -139,7 +139,7 @@ int serialize_geojson_feature(struct serialization_state *sst, json_object *geom
|
||||
|
||||
if (!warned_nan) {
|
||||
char *s = json_stringify(id);
|
||||
fprintf(stderr, "Warning: Can't represent non-numeric feature ID %s\n", s);
|
||||
fprintf(stderr, "Warning: Can't represent non-numeric, non-string feature ID %s\n", s);
|
||||
free(s); // stringify
|
||||
warned_nan = true;
|
||||
}
|
||||
|
3
mvt.cpp
3
mvt.cpp
@ -303,7 +303,6 @@ bool mvt_tile::decode(std::string &message, bool &was_compressed) {
|
||||
std::vector<uint32_t> geoms;
|
||||
size_t dimensions = 0;
|
||||
std::vector<double> elevations;
|
||||
ssize_t string_id = -1;
|
||||
|
||||
while (feature_reader.next()) {
|
||||
switch (feature_reader.tag()) {
|
||||
@ -369,7 +368,7 @@ bool mvt_tile::decode(std::string &message, bool &was_compressed) {
|
||||
|
||||
case 10: /* string id */
|
||||
{
|
||||
string_id = feature_reader.get_uint32();
|
||||
feature.string_id = feature_reader.get_uint32();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -228,7 +228,7 @@ std::vector<mvt_layer> parse_layers(int fd, int z, unsigned x, unsigned y, std::
|
||||
fprintf(stderr, "Internal error: tagging a string value didn't have a length of 1\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
feature.string_id = onto[0];
|
||||
feature.string_id = onto[0] >> 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -516,7 +516,7 @@
|
||||
] }
|
||||
,
|
||||
{ "type": "FeatureCollection", "properties": { "layer": "notlayer827905613", "version": 2, "extent": 4096 }, "features": [
|
||||
{ "type": "Feature", "properties": { "rule": "not \"id\": \"1234\", [\"==\", \"$id\", 1234]" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } }
|
||||
{ "type": "Feature", "id": "1234", "properties": { "rule": "not \"id\": \"1234\", [\"==\", \"$id\", 1234]" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } }
|
||||
,
|
||||
{ "type": "Feature", "properties": { "id": 1234, "rule": "not \"properties\": {\"id\": 1234}, [\"==\", \"$id\", 1234]" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } }
|
||||
] }
|
||||
|
@ -16,7 +16,7 @@
|
||||
,
|
||||
{ "type": "Feature", "properties": { "LINEARID": "1104469713187", "FULLNAME": "Macarthur Blvd", "RTTYP": "M", "MTFCC": "S1400" }, "geometry": { "type": "LineString", "coordinates": [ [ -122.241526, 37.807309 ], [ -122.241440, 37.807173 ] ] } }
|
||||
,
|
||||
{ "type": "Feature", "properties": { "LINEARID": "1102638069562", "FULLNAME": "Macarthur", "RTTYP": "M", "MTFCC": "S1400" }, "geometry": { "type": "LineString", "coordinates": [ [ -122.241526, 37.807309 ], [ -122.241440, 37.807105 ], [ -122.241011, 37.806902 ], [ -122.240667, 37.806834 ], [ -122.239809, 37.806800 ], [ -122.239552, 37.806732 ], [ -122.238479, 37.806088 ], [ -122.237277, 37.805647 ] ] } }
|
||||
{ "type": "Feature", "id": "not a number", "properties": { "LINEARID": "1102638069562", "FULLNAME": "Macarthur", "RTTYP": "M", "MTFCC": "S1400" }, "geometry": { "type": "LineString", "coordinates": [ [ -122.241526, 37.807309 ], [ -122.241440, 37.807105 ], [ -122.241011, 37.806902 ], [ -122.240667, 37.806834 ], [ -122.239809, 37.806800 ], [ -122.239552, 37.806732 ], [ -122.238479, 37.806088 ], [ -122.237277, 37.805647 ] ] } }
|
||||
,
|
||||
{ "type": "Feature", "properties": { "LINEARID": "1104486090991", "FULLNAME": "Macarthur Fwy", "RTTYP": "M", "MTFCC": "S1100" }, "geometry": { "type": "LineString", "coordinates": [ [ -122.294569, 37.833039 ], [ -122.294312, 37.832531 ], [ -122.294054, 37.831684 ], [ -122.293839, 37.830395 ], [ -122.293882, 37.829413 ], [ -122.293839, 37.829040 ], [ -122.293625, 37.828565 ], [ -122.293239, 37.828158 ], [ -122.292895, 37.827887 ], [ -122.290578, 37.826667 ], [ -122.289548, 37.826396 ], [ -122.288604, 37.826362 ], [ -122.288003, 37.826362 ], [ -122.283196, 37.827243 ], [ -122.282338, 37.827311 ], [ -122.281265, 37.827243 ], [ -122.279892, 37.826938 ], [ -122.275257, 37.825786 ], [ -122.270451, 37.824735 ], [ -122.268648, 37.824226 ], [ -122.267361, 37.823989 ], [ -122.265944, 37.823616 ], [ -122.262340, 37.822904 ], [ -122.259164, 37.821853 ], [ -122.256675, 37.820633 ], [ -122.255344, 37.819887 ], [ -122.254272, 37.819209 ], [ -122.253070, 37.818192 ], [ -122.252340, 37.817277 ], [ -122.251697, 37.816158 ], [ -122.251353, 37.815107 ], [ -122.250624, 37.812361 ], [ -122.250409, 37.811852 ], [ -122.249980, 37.811276 ], [ -122.249637, 37.810937 ], [ -122.249207, 37.810632 ], [ -122.248735, 37.810360 ], [ -122.245946, 37.809479 ], [ -122.242513, 37.808496 ], [ -122.241311, 37.808089 ], [ -122.236032, 37.805715 ], [ -122.234874, 37.805071 ], [ -122.233586, 37.804257 ], [ -122.230797, 37.802053 ], [ -122.230024, 37.801511 ], [ -122.229166, 37.801036 ], [ -122.228522, 37.800799 ], [ -122.227750, 37.800595 ], [ -122.221055, 37.799171 ], [ -122.216506, 37.798120 ], [ -122.215776, 37.797848 ], [ -122.213717, 37.797407 ], [ -122.211957, 37.796933 ], [ -122.210498, 37.796390 ], [ -122.206550, 37.794525 ], [ -122.205219, 37.793745 ], [ -122.203932, 37.792626 ], [ -122.201357, 37.789879 ], [ -122.200627, 37.789201 ], [ -122.199812, 37.788658 ], [ -122.199082, 37.788251 ], [ -122.193761, 37.785639 ], [ -122.192516, 37.785165 ], [ -122.191272, 37.784792 ], [ -122.189770, 37.784452 ], [ -122.188482, 37.784249 ], [ -122.184706, 37.784011 ], [ -122.179556, 37.783876 ], [ -122.178268, 37.783604 ], [ -122.173676, 37.780959 ], [ -122.167969, 37.778008 ], [ -122.164536, 37.776481 ] ] } }
|
||||
,
|
||||
@ -72,7 +72,7 @@
|
||||
,
|
||||
{ "type": "Feature", "properties": { "LINEARID": "1104469713187", "FULLNAME": "Macarthur Blvd", "RTTYP": "M", "MTFCC": "S1400" }, "geometry": { "type": "LineString", "coordinates": [ [ -122.241526, 37.807292 ], [ -122.241418, 37.807173 ] ] } }
|
||||
,
|
||||
{ "type": "Feature", "properties": { "LINEARID": "1102638069562", "FULLNAME": "Macarthur", "RTTYP": "M", "MTFCC": "S1400" }, "geometry": { "type": "LineString", "coordinates": [ [ -122.241526, 37.807292 ], [ -122.241418, 37.807173 ], [ -122.241461, 37.807139 ], [ -122.241418, 37.807088 ], [ -122.241225, 37.806970 ], [ -122.240989, 37.806885 ], [ -122.240667, 37.806817 ], [ -122.239809, 37.806800 ], [ -122.239530, 37.806732 ], [ -122.239316, 37.806631 ], [ -122.238822, 37.806292 ], [ -122.238457, 37.806088 ], [ -122.237921, 37.805851 ], [ -122.237277, 37.805647 ] ] } }
|
||||
{ "type": "Feature", "id": "not a number", "properties": { "LINEARID": "1102638069562", "FULLNAME": "Macarthur", "RTTYP": "M", "MTFCC": "S1400" }, "geometry": { "type": "LineString", "coordinates": [ [ -122.241526, 37.807292 ], [ -122.241418, 37.807173 ], [ -122.241461, 37.807139 ], [ -122.241418, 37.807088 ], [ -122.241225, 37.806970 ], [ -122.240989, 37.806885 ], [ -122.240667, 37.806817 ], [ -122.239809, 37.806800 ], [ -122.239530, 37.806732 ], [ -122.239316, 37.806631 ], [ -122.238822, 37.806292 ], [ -122.238457, 37.806088 ], [ -122.237921, 37.805851 ], [ -122.237277, 37.805647 ] ] } }
|
||||
,
|
||||
{ "type": "Feature", "properties": { "LINEARID": "1104486090991", "FULLNAME": "Macarthur Fwy", "RTTYP": "M", "MTFCC": "S1100" }, "geometry": { "type": "LineString", "coordinates": [ [ -122.257576, 37.821107 ], [ -122.255859, 37.820209 ], [ -122.254272, 37.819192 ], [ -122.253671, 37.818734 ], [ -122.253048, 37.818192 ], [ -122.252469, 37.817497 ], [ -122.252126, 37.816972 ], [ -122.251697, 37.816158 ], [ -122.251332, 37.815090 ], [ -122.250602, 37.812344 ], [ -122.250431, 37.811937 ], [ -122.250152, 37.811479 ], [ -122.249808, 37.811089 ], [ -122.249486, 37.810801 ], [ -122.249036, 37.810513 ], [ -122.248478, 37.810242 ], [ -122.246568, 37.809682 ], [ -122.245946, 37.809462 ], [ -122.245302, 37.809292 ], [ -122.242491, 37.808479 ], [ -122.241311, 37.808072 ], [ -122.239637, 37.807360 ], [ -122.238650, 37.806919 ], [ -122.238071, 37.806614 ], [ -122.237449, 37.806359 ], [ -122.236011, 37.805698 ], [ -122.234852, 37.805054 ], [ -122.233586, 37.804257 ], [ -122.230797, 37.802053 ], [ -122.230003, 37.801494 ], [ -122.229145, 37.801036 ], [ -122.228501, 37.800782 ], [ -122.227728, 37.800578 ], [ -122.226999, 37.800442 ], [ -122.224274, 37.799832 ], [ -122.221055, 37.799171 ], [ -122.216485, 37.798103 ], [ -122.215776, 37.797848 ], [ -122.213717, 37.797391 ], [ -122.211957, 37.796916 ], [ -122.211142, 37.796661 ], [ -122.210476, 37.796373 ], [ -122.206528, 37.794508 ], [ -122.205884, 37.794186 ], [ -122.205219, 37.793745 ], [ -122.204490, 37.793168 ], [ -122.203932, 37.792626 ], [ -122.201357, 37.789862 ], [ -122.200670, 37.789234 ], [ -122.199554, 37.788488 ], [ -122.198782, 37.788081 ], [ -122.196035, 37.786725 ] ] } }
|
||||
] }
|
||||
@ -112,7 +112,7 @@
|
||||
,
|
||||
{ "type": "Feature", "properties": { "LINEARID": "1104469713187", "FULLNAME": "Macarthur Blvd", "RTTYP": "M", "MTFCC": "S1400" }, "geometry": { "type": "LineString", "coordinates": [ [ -122.241515, 37.807283 ], [ -122.241408, 37.807165 ] ] } }
|
||||
,
|
||||
{ "type": "Feature", "properties": { "LINEARID": "1102638069562", "FULLNAME": "Macarthur", "RTTYP": "M", "MTFCC": "S1400" }, "geometry": { "type": "LineString", "coordinates": [ [ -122.241515, 37.807283 ], [ -122.241408, 37.807165 ], [ -122.241461, 37.807131 ], [ -122.241408, 37.807080 ], [ -122.241225, 37.806961 ], [ -122.240978, 37.806877 ], [ -122.240657, 37.806809 ], [ -122.240421, 37.806792 ], [ -122.239927, 37.806800 ], [ -122.239798, 37.806792 ], [ -122.239627, 37.806758 ], [ -122.239530, 37.806724 ], [ -122.239316, 37.806622 ], [ -122.238811, 37.806283 ], [ -122.238457, 37.806088 ], [ -122.237921, 37.805851 ], [ -122.237277, 37.805647 ] ] } }
|
||||
{ "type": "Feature", "id": "not a number", "properties": { "LINEARID": "1102638069562", "FULLNAME": "Macarthur", "RTTYP": "M", "MTFCC": "S1400" }, "geometry": { "type": "LineString", "coordinates": [ [ -122.241515, 37.807283 ], [ -122.241408, 37.807165 ], [ -122.241461, 37.807131 ], [ -122.241408, 37.807080 ], [ -122.241225, 37.806961 ], [ -122.240978, 37.806877 ], [ -122.240657, 37.806809 ], [ -122.240421, 37.806792 ], [ -122.239927, 37.806800 ], [ -122.239798, 37.806792 ], [ -122.239627, 37.806758 ], [ -122.239530, 37.806724 ], [ -122.239316, 37.806622 ], [ -122.238811, 37.806283 ], [ -122.238457, 37.806088 ], [ -122.237921, 37.805851 ], [ -122.237277, 37.805647 ] ] } }
|
||||
,
|
||||
{ "type": "Feature", "properties": { "LINEARID": "1104486090991", "FULLNAME": "Macarthur Fwy", "RTTYP": "M", "MTFCC": "S1100" }, "geometry": { "type": "LineString", "coordinates": [ [ -122.256718, 37.820658 ], [ -122.255859, 37.820201 ], [ -122.255334, 37.819879 ], [ -122.254690, 37.819446 ], [ -122.254272, 37.819184 ], [ -122.253660, 37.818726 ], [ -122.253381, 37.818497 ], [ -122.253048, 37.818184 ], [ -122.252458, 37.817497 ], [ -122.252115, 37.816963 ], [ -122.251697, 37.816149 ], [ -122.251514, 37.815649 ], [ -122.251332, 37.815081 ], [ -122.250592, 37.812335 ], [ -122.250420, 37.811928 ], [ -122.250152, 37.811479 ], [ -122.249808, 37.811089 ], [ -122.249486, 37.810801 ], [ -122.249036, 37.810504 ], [ -122.248478, 37.810242 ], [ -122.246729, 37.809708 ], [ -122.246557, 37.809674 ], [ -122.245935, 37.809453 ], [ -122.245302, 37.809292 ], [ -122.242481, 37.808470 ], [ -122.241300, 37.808072 ], [ -122.239627, 37.807360 ], [ -122.238650, 37.806910 ], [ -122.238060, 37.806605 ], [ -122.237449, 37.806351 ], [ -122.236880, 37.806080 ], [ -122.236000, 37.805690 ], [ -122.235432, 37.805393 ], [ -122.234852, 37.805054 ], [ -122.234337, 37.804749 ], [ -122.233576, 37.804249 ], [ -122.233232, 37.803994 ], [ -122.230786, 37.802045 ], [ -122.230378, 37.801739 ], [ -122.230003, 37.801485 ], [ -122.229692, 37.801307 ], [ -122.229134, 37.801027 ], [ -122.228501, 37.800782 ], [ -122.228125, 37.800671 ], [ -122.227728, 37.800570 ], [ -122.226988, 37.800434 ], [ -122.224263, 37.799832 ], [ -122.221044, 37.799171 ], [ -122.220594, 37.799069 ], [ -122.218748, 37.798637 ], [ -122.217128, 37.798238 ], [ -122.216485, 37.798094 ], [ -122.215766, 37.797840 ], [ -122.213706, 37.797382 ], [ -122.211914, 37.796907 ], [ -122.211056, 37.796619 ] ] } }
|
||||
] }
|
||||
@ -188,7 +188,7 @@
|
||||
,
|
||||
{ "type": "FeatureCollection", "properties": { "zoom": 14, "x": 2628, "y": 6331 }, "features": [
|
||||
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
|
||||
{ "type": "Feature", "properties": { "LINEARID": "1102638069562", "FULLNAME": "Macarthur", "RTTYP": "M", "MTFCC": "S1400" }, "geometry": { "type": "LineString", "coordinates": [ [ -122.237706, 37.805783 ], [ -122.237272, 37.805643 ] ] } }
|
||||
{ "type": "Feature", "id": "not a number", "properties": { "LINEARID": "1102638069562", "FULLNAME": "Macarthur", "RTTYP": "M", "MTFCC": "S1400" }, "geometry": { "type": "LineString", "coordinates": [ [ -122.237706, 37.805783 ], [ -122.237272, 37.805643 ] ] } }
|
||||
,
|
||||
{ "type": "Feature", "properties": { "LINEARID": "1104486090991", "FULLNAME": "Macarthur Fwy", "RTTYP": "M", "MTFCC": "S1100" }, "geometry": { "type": "LineString", "coordinates": [ [ -122.236210, 37.805783 ], [ -122.235995, 37.805690 ], [ -122.235539, 37.805444 ], [ -122.234852, 37.805054 ], [ -122.234337, 37.804745 ], [ -122.233887, 37.804452 ], [ -122.233570, 37.804244 ], [ -122.233458, 37.804164 ] ] } }
|
||||
] }
|
||||
@ -200,7 +200,7 @@
|
||||
,
|
||||
{ "type": "Feature", "properties": { "LINEARID": "1104469713187", "FULLNAME": "Macarthur Blvd", "RTTYP": "M", "MTFCC": "S1400" }, "geometry": { "type": "LineString", "coordinates": [ [ -122.241515, 37.807279 ], [ -122.241408, 37.807160 ] ] } }
|
||||
,
|
||||
{ "type": "Feature", "properties": { "LINEARID": "1102638069562", "FULLNAME": "Macarthur", "RTTYP": "M", "MTFCC": "S1400" }, "geometry": { "type": "LineString", "coordinates": [ [ -122.241515, 37.807279 ], [ -122.241408, 37.807160 ], [ -122.241461, 37.807131 ], [ -122.241408, 37.807076 ], [ -122.241311, 37.807008 ], [ -122.241220, 37.806961 ], [ -122.240978, 37.806872 ], [ -122.240657, 37.806804 ], [ -122.240415, 37.806792 ], [ -122.239927, 37.806800 ], [ -122.239798, 37.806788 ], [ -122.239621, 37.806754 ], [ -122.239530, 37.806720 ], [ -122.239310, 37.806618 ], [ -122.238806, 37.806283 ], [ -122.238602, 37.806160 ], [ -122.238457, 37.806088 ], [ -122.238189, 37.805961 ], [ -122.237915, 37.805851 ], [ -122.237272, 37.805643 ] ] } }
|
||||
{ "type": "Feature", "id": "not a number", "properties": { "LINEARID": "1102638069562", "FULLNAME": "Macarthur", "RTTYP": "M", "MTFCC": "S1400" }, "geometry": { "type": "LineString", "coordinates": [ [ -122.241515, 37.807279 ], [ -122.241408, 37.807160 ], [ -122.241461, 37.807131 ], [ -122.241408, 37.807076 ], [ -122.241311, 37.807008 ], [ -122.241220, 37.806961 ], [ -122.240978, 37.806872 ], [ -122.240657, 37.806804 ], [ -122.240415, 37.806792 ], [ -122.239927, 37.806800 ], [ -122.239798, 37.806788 ], [ -122.239621, 37.806754 ], [ -122.239530, 37.806720 ], [ -122.239310, 37.806618 ], [ -122.238806, 37.806283 ], [ -122.238602, 37.806160 ], [ -122.238457, 37.806088 ], [ -122.238189, 37.805961 ], [ -122.237915, 37.805851 ], [ -122.237272, 37.805643 ] ] } }
|
||||
,
|
||||
{ "type": "Feature", "properties": { "LINEARID": "1104486090991", "FULLNAME": "Macarthur Fwy", "RTTYP": "M", "MTFCC": "S1100" }, "geometry": { "type": "LineString", "coordinates": [ [ -122.256289, 37.820429 ], [ -122.255859, 37.820196 ], [ -122.255334, 37.819879 ], [ -122.254685, 37.819442 ], [ -122.254266, 37.819184 ], [ -122.253660, 37.818726 ], [ -122.253381, 37.818497 ], [ -122.253048, 37.818179 ], [ -122.252796, 37.817900 ], [ -122.252458, 37.817493 ], [ -122.252115, 37.816963 ], [ -122.251772, 37.816319 ], [ -122.251691, 37.816149 ], [ -122.251509, 37.815649 ], [ -122.251326, 37.815081 ], [ -122.250715, 37.812785 ], [ -122.250586, 37.812335 ], [ -122.250500, 37.812102 ], [ -122.250372, 37.811835 ], [ -122.250146, 37.811479 ], [ -122.249980, 37.811276 ], [ -122.249803, 37.811085 ], [ -122.249615, 37.810911 ], [ -122.249481, 37.810801 ], [ -122.249202, 37.810602 ], [ -122.249036, 37.810500 ], [ -122.248574, 37.810276 ], [ -122.248478, 37.810237 ], [ -122.246724, 37.809708 ], [ -122.246557, 37.809674 ], [ -122.245935, 37.809449 ], [ -122.245302, 37.809288 ], [ -122.243564, 37.808788 ], [ -122.242475, 37.808466 ], [ -122.241858, 37.808267 ], [ -122.241300, 37.808072 ], [ -122.239627, 37.807355 ], [ -122.238645, 37.806906 ], [ -122.238060, 37.806601 ], [ -122.237443, 37.806351 ], [ -122.236875, 37.806080 ], [ -122.235995, 37.805690 ], [ -122.235539, 37.805444 ], [ -122.234944, 37.805105 ] ] } }
|
||||
] }
|
||||
|
@ -243,7 +243,7 @@ void handle(std::string message, int z, unsigned x, unsigned y, std::map<std::st
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
outfeature.string_id = onto[0];
|
||||
outfeature.string_id = onto[0] >> 4;
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, mvt_value>> todo;
|
||||
|
4
tile.cpp
4
tile.cpp
@ -1538,7 +1538,7 @@ void *run_prefilter(void *v) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
tmp_feature.string_id = onto[0];
|
||||
tmp_feature.string_id = onto[0] >> 4;
|
||||
}
|
||||
|
||||
// Offset from tile coordinates back to world coordinates
|
||||
@ -2283,7 +2283,7 @@ long long write_tile(FILE *geoms, std::atomic<long long> *geompos_in, char *meta
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
feature.string_id = onto[0];
|
||||
feature.string_id = onto[0] >> 4;
|
||||
}
|
||||
|
||||
decode_meta(layer_features[x].keys, layer_features[x].values, layer_features[x].stringpool, layer, feature, true);
|
||||
|
@ -416,7 +416,7 @@ void layer_to_geojson(mvt_layer const &layer, unsigned z, unsigned x, unsigned y
|
||||
if (feat.string_id >= 0) {
|
||||
state.json_write_string("id");
|
||||
if (feat.string_id >= (ssize_t) layer.string_values.string_values.size()) {
|
||||
fprintf(stderr, "Internal error: out of bounds string ID reference\n");
|
||||
fprintf(stderr, "Internal error: out of bounds string ID reference %zd\n", feat.string_id);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
state.json_write_string(layer.string_values.string_values[feat.string_id]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user