mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-01-22 04:18:01 +00:00
Fill out layermaps when reading the output of the prefilter
This commit is contained in:
parent
5e7f718afc
commit
9c0e2cdfa7
35
plugin.cpp
35
plugin.cpp
@ -239,7 +239,7 @@ mvt_layer parse_layer(int fd, unsigned z, unsigned x, unsigned y, mvt_layer cons
|
||||
return ret;
|
||||
}
|
||||
|
||||
serial_feature parse_feature(json_pull *jp, unsigned z, unsigned x, unsigned y) {
|
||||
serial_feature parse_feature(json_pull *jp, unsigned z, unsigned x, unsigned y, std::vector<std::map<std::string, layermap_entry>> *layermaps, size_t tiling_seg) {
|
||||
serial_feature sf;
|
||||
|
||||
while (1) {
|
||||
@ -332,6 +332,16 @@ serial_feature parse_feature(json_pull *jp, unsigned z, unsigned x, unsigned y)
|
||||
}
|
||||
|
||||
if (dv.size() > 0) {
|
||||
std::string layername = "unknown";
|
||||
json_object *tippecanoe = json_hash_get(j, "tippecanoe");
|
||||
json_object *layer = NULL;
|
||||
if (tippecanoe != NULL) {
|
||||
layer = json_hash_get(tippecanoe, "layer");
|
||||
if (layer != NULL && layer->type == JSON_STRING) {
|
||||
layername = std::string(layer->string);
|
||||
}
|
||||
}
|
||||
|
||||
sf.t = mb_geometry[t];
|
||||
sf.geometry = dv;
|
||||
sf.segment = 0;
|
||||
@ -350,6 +360,8 @@ serial_feature parse_feature(json_pull *jp, unsigned z, unsigned x, unsigned y)
|
||||
sf.has_id = true;
|
||||
}
|
||||
|
||||
std::map<std::string, layermap_entry> &layermap = (*layermaps)[tiling_seg];
|
||||
|
||||
for (size_t i = 0; i < properties->length; i++) {
|
||||
serial_val v;
|
||||
v.type = -1;
|
||||
@ -358,6 +370,27 @@ serial_feature parse_feature(json_pull *jp, unsigned z, unsigned x, unsigned y)
|
||||
|
||||
if (v.type >= 0) {
|
||||
sf.kv.insert(std::pair<std::string, serial_val>(std::string(properties->keys[i]->string), v));
|
||||
|
||||
if (layermap.count(layername) == 0) {
|
||||
layermap_entry lme = layermap_entry(layermap.size());
|
||||
lme.minzoom = z;
|
||||
lme.maxzoom = z;
|
||||
|
||||
layermap.insert(std::pair<std::string, layermap_entry>(layername, lme));
|
||||
}
|
||||
|
||||
type_and_string tas;
|
||||
tas.string = std::string(properties->keys[i]->string);
|
||||
tas.type = v.type;
|
||||
|
||||
auto fk = layermap.find(layername);
|
||||
if (z < fk->second.minzoom) {
|
||||
fk->second.minzoom = z;
|
||||
}
|
||||
if (z > fk->second.maxzoom) {
|
||||
fk->second.maxzoom = z;
|
||||
}
|
||||
fk->second.file_keys.insert(tas);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
mvt_layer filter_layer(const char *filter, mvt_layer &layer, unsigned z, unsigned x, unsigned y, std::vector<std::map<std::string, layermap_entry>> *layermaps, size_t tiling_seg);
|
||||
void setup_filter(const char *filter, int *write_to, int *read_from, pid_t *pid, unsigned z, unsigned x, unsigned y);
|
||||
serial_feature parse_feature(json_pull *jp, unsigned z, unsigned x, unsigned y);
|
||||
serial_feature parse_feature(json_pull *jp, unsigned z, unsigned x, unsigned y, std::vector<std::map<std::string, layermap_entry>> *layermaps, size_t tiling_seg);
|
||||
|
2
tile.cpp
2
tile.cpp
@ -1522,7 +1522,7 @@ long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *s
|
||||
if (prefilter == NULL) {
|
||||
sf = next_feature(geoms, geompos_in, metabase, meta_off, z, tx, ty, initial_x, initial_y, &original_features, &unclipped_features, nextzoom, maxzoom, minzoom, max_zoom_increment, pass, passes, along, alongminus, buffer, within, &first_time, line_detail, geomfile, geompos, &oprogress, todo, fname, child_shards);
|
||||
} else {
|
||||
sf = parse_feature(prefilter_jp, z, tx, ty);
|
||||
sf = parse_feature(prefilter_jp, z, tx, ty, layermaps, tiling_seg);
|
||||
}
|
||||
|
||||
if (sf.t < 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user