Fix reordering of attributes and failure to update layer name table

This commit is contained in:
Eric Fischer 2016-12-20 16:41:23 -08:00
parent a2060299c9
commit 6a5461763c
3 changed files with 40 additions and 31 deletions

View File

@ -368,6 +368,30 @@ serial_feature parse_feature(json_pull *jp, int z, unsigned x, unsigned y, std::
std::map<std::string, layermap_entry> &layermap = (*layermaps)[tiling_seg];
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));
if (lme.id >= (*layer_unmaps)[tiling_seg].size()) {
(*layer_unmaps)[tiling_seg].resize(lme.id + 1);
(*layer_unmaps)[tiling_seg][lme.id] = layername;
}
}
auto fk = layermap.find(layername);
fprintf(stderr, "assign layer %zu\n", fk->second.id);
sf.layer = fk->second.id;
if (z < fk->second.minzoom) {
fk->second.minzoom = z;
}
if (z > fk->second.maxzoom) {
fk->second.maxzoom = z;
}
for (size_t i = 0; i < properties->length; i++) {
serial_val v;
v.type = -1;
@ -375,35 +399,14 @@ serial_feature parse_feature(json_pull *jp, int z, unsigned x, unsigned y, std::
stringify_value(properties->values[i], v.type, v.s, "Filter output", jp->line, j);
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));
if (lme.id >= (*layer_unmaps)[tiling_seg].size()) {
(*layer_unmaps)[tiling_seg].resize(lme.id + 1);
(*layer_unmaps)[tiling_seg][lme.id] = layername;
}
}
sf.full_keys.push_back(std::string(properties->keys[i]->string));
sf.full_values.push_back(v);
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);
sf.layer = fk->second.id;
}
}

View File

@ -52,7 +52,8 @@ struct serial_feature {
// XXX This isn't serialized. Should it be here?
long long bbox[4];
std::map<std::string, serial_val> kv;
std::vector<std::string> full_keys;
std::vector<serial_val> full_values;
};
void serialize_feature(FILE *geomfile, serial_feature *sf, long long *geompos, const char *fname, long long wx, long long wy, bool include_minzoom);

View File

@ -78,7 +78,8 @@ struct coalesce {
char *stringpool;
std::vector<long long> keys;
std::vector<long long> values;
std::map<std::string, serial_val> kv;
std::vector<std::string> full_keys;
std::vector<serial_val> full_values;
drawvec geom;
unsigned long long index;
unsigned long long index2;
@ -315,7 +316,8 @@ struct partial {
std::vector<drawvec> geoms;
std::vector<long long> keys;
std::vector<long long> values;
std::map<std::string, serial_val> kv;
std::vector<std::string> full_keys;
std::vector<serial_val> full_values;
std::vector<ssize_t> arc_polygon;
long long layer;
long long original_seq;
@ -1583,7 +1585,8 @@ long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *s
p.maxzoom = maxzoom;
p.keys = sf.keys;
p.values = sf.values;
p.kv = sf.kv;
p.full_keys = sf.full_keys;
p.full_values = sf.full_values;
p.spacing = spacing;
p.simplification = simplification;
p.id = sf.id;
@ -1681,7 +1684,8 @@ long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *s
c.stringpool = stringpool + pool_off[partials[i].segment];
c.keys = partials[i].keys;
c.values = partials[i].values;
c.kv = partials[i].kv;
c.full_keys = partials[i].full_keys;
c.full_values = partials[i].full_values;
c.spacing = partials[i].spacing;
c.id = partials[i].id;
c.has_id = partials[i].has_id;
@ -1798,9 +1802,10 @@ long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *s
feature.has_id = layer_features[x].has_id;
decode_meta(layer_features[x].m, layer_features[x].keys, layer_features[x].values, layer_features[x].stringpool, layer, feature);
for (auto kv : layer_features[x].kv) {
mvt_value v = stringified_to_mvt_value(kv.second.type, kv.second.s.c_str());
layer.tag(feature, kv.first, v);
for (size_t a = 0; a < layer_features[x].full_keys.size(); a++) {
serial_val sv = layer_features[x].full_values[a];
mvt_value v = stringified_to_mvt_value(sv.type, sv.s.c_str());
layer.tag(feature, layer_features[x].full_keys[a], v);
}
if (additional[A_CALCULATE_FEATURE_DENSITY]) {