mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-05 18:05:42 +02:00
Add a tippecanoe-decode option to restrict which attributes to decode
This commit is contained in:
+7
-1
@@ -28,6 +28,7 @@
|
|||||||
int minzoom = 0;
|
int minzoom = 0;
|
||||||
int maxzoom = 32;
|
int maxzoom = 32;
|
||||||
bool force = false;
|
bool force = false;
|
||||||
|
std::set<std::string> include_attr;
|
||||||
|
|
||||||
bool progress_time() {
|
bool progress_time() {
|
||||||
return false;
|
return false;
|
||||||
@@ -217,7 +218,7 @@ void handle(std::string message, int z, unsigned x, unsigned y, std::set<std::st
|
|||||||
} else if (coordinate_mode == 2) { // integer
|
} else if (coordinate_mode == 2) { // integer
|
||||||
scale = 1;
|
scale = 1;
|
||||||
}
|
}
|
||||||
layer_to_geojson(layer, z, x, y, !pipeline, pipeline, pipeline, false, 0, 0, 0, !force, state, scale);
|
layer_to_geojson(layer, z, x, y, !pipeline, pipeline, pipeline, false, 0, 0, 0, !force, state, scale, include_attr);
|
||||||
|
|
||||||
if (!pipeline) {
|
if (!pipeline) {
|
||||||
if (true) {
|
if (true) {
|
||||||
@@ -571,6 +572,7 @@ int main(int argc, char **argv) {
|
|||||||
{"stats", no_argument, 0, 'S'},
|
{"stats", no_argument, 0, 'S'},
|
||||||
{"force", no_argument, 0, 'f'},
|
{"force", no_argument, 0, 'f'},
|
||||||
{"exclude-metadata-row", required_argument, 0, 'x'},
|
{"exclude-metadata-row", required_argument, 0, 'x'},
|
||||||
|
{"include", required_argument, 0, 'y'},
|
||||||
{0, 0, 0, 0},
|
{0, 0, 0, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -630,6 +632,10 @@ int main(int argc, char **argv) {
|
|||||||
exclude_meta.insert(optarg);
|
exclude_meta.insert(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'y':
|
||||||
|
include_attr.insert(optarg);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
usage(argv);
|
usage(argv);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -55,7 +55,7 @@ void *run_writer(void *a) {
|
|||||||
|
|
||||||
json_writer state(fp);
|
json_writer state(fp);
|
||||||
for (size_t i = 0; i < wa->layers->size(); i++) {
|
for (size_t i = 0; i < wa->layers->size(); i++) {
|
||||||
layer_to_geojson((*(wa->layers))[i], wa->z, wa->x, wa->y, false, true, false, true, 0, 0, 0, true, state, 0);
|
layer_to_geojson((*(wa->layers))[i], wa->z, wa->x, wa->y, false, true, false, true, 0, 0, 0, true, state, 0, std::set<std::string>());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fclose(fp) != 0) {
|
if (fclose(fp) != 0) {
|
||||||
|
|||||||
@@ -1358,7 +1358,7 @@ void *run_prefilter(void *v) {
|
|||||||
decode_meta(sf, tmp_layer, tmp_feature);
|
decode_meta(sf, tmp_layer, tmp_feature);
|
||||||
tmp_layer.features.push_back(tmp_feature);
|
tmp_layer.features.push_back(tmp_feature);
|
||||||
|
|
||||||
layer_to_geojson(tmp_layer, 0, 0, 0, false, true, false, true, sf.index, sf.seq, sf.extent, true, state, 0);
|
layer_to_geojson(tmp_layer, 0, 0, 0, false, true, false, true, sf.index, sf.seq, sf.extent, true, state, 0, std::set<std::string>());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fclose(rpa->prefilter_fp) != 0) {
|
if (fclose(rpa->prefilter_fp) != 0) {
|
||||||
|
|||||||
+5
-1
@@ -268,7 +268,7 @@ void write_coords(json_writer &state, lonlat const &ll, double scale) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void layer_to_geojson(mvt_layer const &layer, unsigned z, unsigned x, unsigned y, bool comma, bool name, bool zoom, bool write_dropped, unsigned long long index, long long sequence, long long extent, bool complain, json_writer &state, double scale) {
|
void layer_to_geojson(mvt_layer const &layer, unsigned z, unsigned x, unsigned y, bool comma, bool name, bool zoom, bool write_dropped, unsigned long long index, long long sequence, long long extent, bool complain, json_writer &state, double scale, std::set<std::string> const &include_attr) {
|
||||||
for (size_t f = 0; f < layer.features.size(); f++) {
|
for (size_t f = 0; f < layer.features.size(); f++) {
|
||||||
mvt_feature const &feat = layer.features[f];
|
mvt_feature const &feat = layer.features[f];
|
||||||
|
|
||||||
@@ -334,6 +334,10 @@ void layer_to_geojson(mvt_layer const &layer, unsigned z, unsigned x, unsigned y
|
|||||||
exit(EXIT_IMPOSSIBLE);
|
exit(EXIT_IMPOSSIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (include_attr.size() > 0 && include_attr.find(layer.keys[feat.tags[t]]) == include_attr.end()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const char *key = layer.keys[feat.tags[t]].c_str();
|
const char *key = layer.keys[feat.tags[t]].c_str();
|
||||||
mvt_value const &val = layer.values[feat.tags[t + 1]];
|
mvt_value const &val = layer.values[feat.tags[t + 1]];
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -4,6 +4,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
enum json_write_tok {
|
enum json_write_tok {
|
||||||
JSON_WRITE_HASH,
|
JSON_WRITE_HASH,
|
||||||
@@ -61,7 +62,7 @@ struct json_writer {
|
|||||||
void adds(std::string const &s);
|
void adds(std::string const &s);
|
||||||
};
|
};
|
||||||
|
|
||||||
void layer_to_geojson(mvt_layer const &layer, unsigned z, unsigned x, unsigned y, bool comma, bool name, bool zoom, bool dropped, unsigned long long index, long long sequence, long long extent, bool complain, json_writer &state, double scale);
|
void layer_to_geojson(mvt_layer const &layer, unsigned z, unsigned x, unsigned y, bool comma, bool name, bool zoom, bool dropped, unsigned long long index, long long sequence, long long extent, bool complain, json_writer &state, double scale, std::set<std::string> const &include_attr);
|
||||||
void fprintq(FILE *f, const char *s);
|
void fprintq(FILE *f, const char *s);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user