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
+18 -15
View File
@@ -368,15 +368,6 @@ serial_feature parse_feature(json_pull *jp, int z, unsigned x, unsigned y, std::
std::map<std::string, layermap_entry> &layermap = (*layermaps)[tiling_seg]; 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;
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) { if (layermap.count(layername) == 0) {
layermap_entry lme = layermap_entry(layermap.size()); layermap_entry lme = layermap_entry(layermap.size());
lme.minzoom = z; lme.minzoom = z;
@@ -390,20 +381,32 @@ serial_feature parse_feature(json_pull *jp, int z, unsigned x, unsigned y, std::
} }
} }
type_and_string tas;
tas.string = std::string(properties->keys[i]->string);
tas.type = v.type;
auto fk = layermap.find(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) { if (z < fk->second.minzoom) {
fk->second.minzoom = z; fk->second.minzoom = z;
} }
if (z > fk->second.maxzoom) { if (z > fk->second.maxzoom) {
fk->second.maxzoom = z; fk->second.maxzoom = z;
} }
fk->second.file_keys.insert(tas);
sf.layer = fk->second.id; for (size_t i = 0; i < properties->length; i++) {
serial_val v;
v.type = -1;
stringify_value(properties->values[i], v.type, v.s, "Filter output", jp->line, j);
if (v.type >= 0) {
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;
fk->second.file_keys.insert(tas);
} }
} }
+2 -1
View File
@@ -52,7 +52,8 @@ struct serial_feature {
// XXX This isn't serialized. Should it be here? // XXX This isn't serialized. Should it be here?
long long bbox[4]; 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); void serialize_feature(FILE *geomfile, serial_feature *sf, long long *geompos, const char *fname, long long wx, long long wy, bool include_minzoom);
+12 -7
View File
@@ -78,7 +78,8 @@ struct coalesce {
char *stringpool; char *stringpool;
std::vector<long long> keys; std::vector<long long> keys;
std::vector<long long> values; 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; drawvec geom;
unsigned long long index; unsigned long long index;
unsigned long long index2; unsigned long long index2;
@@ -315,7 +316,8 @@ struct partial {
std::vector<drawvec> geoms; std::vector<drawvec> geoms;
std::vector<long long> keys; std::vector<long long> keys;
std::vector<long long> values; 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; std::vector<ssize_t> arc_polygon;
long long layer; long long layer;
long long original_seq; 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.maxzoom = maxzoom;
p.keys = sf.keys; p.keys = sf.keys;
p.values = sf.values; p.values = sf.values;
p.kv = sf.kv; p.full_keys = sf.full_keys;
p.full_values = sf.full_values;
p.spacing = spacing; p.spacing = spacing;
p.simplification = simplification; p.simplification = simplification;
p.id = sf.id; 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.stringpool = stringpool + pool_off[partials[i].segment];
c.keys = partials[i].keys; c.keys = partials[i].keys;
c.values = partials[i].values; 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.spacing = partials[i].spacing;
c.id = partials[i].id; c.id = partials[i].id;
c.has_id = partials[i].has_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; 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); 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) { for (size_t a = 0; a < layer_features[x].full_keys.size(); a++) {
mvt_value v = stringified_to_mvt_value(kv.second.type, kv.second.s.c_str()); serial_val sv = layer_features[x].full_values[a];
layer.tag(feature, kv.first, v); 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]) { if (additional[A_CALCULATE_FEATURE_DENSITY]) {