From 7a0878da9bd8fa4d29b96b079e65a26d4e1245ba Mon Sep 17 00:00:00 2001 From: Erica Fischer Date: Fri, 13 Sep 2024 11:32:51 -0700 Subject: [PATCH] Fix backwards conditional --- Makefile | 6 +++--- clip.cpp | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index aab3484a..0be7285d 100644 --- a/Makefile +++ b/Makefile @@ -367,15 +367,15 @@ overzoom-test: tippecanoe-overzoom cmp tests/pbf/bin-11-327-791.pbf.out.json.check tests/pbf/bin-11-327-791.pbf.out.json rm tests/pbf/bin-11-327-791.pbf.out.json.check tests/pbf/bin-11-327-791.pbf.out # Binning with longitude wraparound problems - ./tippecanoe-overzoom -o tests/pbf/0-0-0-pop-2-0-1.pbf.out --assign-to-bins tests/pbf/h3-2-0-1.geojson tests/pbf/0-0-0.pbf 2/0/1 2/0/1 + ./tippecanoe-overzoom -o tests/pbf/0-0-0-pop-2-0-1.pbf.out --accumulate-numeric-attributes --assign-to-bins tests/pbf/h3-2-0-1.geojson tests/pbf/0-0-0.pbf 2/0/1 2/0/1 ./tippecanoe-decode tests/pbf/0-0-0-pop-2-0-1.pbf.out 2 0 1 > tests/pbf/0-0-0-pop-2-0-1.pbf.out.json.check cmp tests/pbf/0-0-0-pop-2-0-1.pbf.out.json.check tests/pbf/0-0-0-pop-2-0-1.pbf.out.json rm tests/pbf/0-0-0-pop-2-0-1.pbf.out tests/pbf/0-0-0-pop-2-0-1.pbf.out.json.check - ./tippecanoe-overzoom -o tests/pbf/0-0-0-pop-1-1-0.pbf.out --assign-to-bins tests/pbf/h3-1-1-0.geojson tests/pbf/0-0-0.pbf 1/1/0 1/1/0 + ./tippecanoe-overzoom -o tests/pbf/0-0-0-pop-1-1-0.pbf.out --accumulate-numeric-attributes --assign-to-bins tests/pbf/h3-1-1-0.geojson tests/pbf/0-0-0.pbf 1/1/0 1/1/0 ./tippecanoe-decode tests/pbf/0-0-0-pop-1-1-0.pbf.out 1 1 0 > tests/pbf/0-0-0-pop-1-1-0.pbf.out.json.check cmp tests/pbf/0-0-0-pop-1-1-0.pbf.out.json.check tests/pbf/0-0-0-pop-1-1-0.pbf.out.json rm tests/pbf/0-0-0-pop-1-1-0.pbf.out tests/pbf/0-0-0-pop-1-1-0.pbf.out.json.check - ./tippecanoe-overzoom -o tests/pbf/0-0-0-pop-0-0-0.pbf.out --assign-to-bins tests/pbf/h3-0-0-0.geojson tests/pbf/0-0-0.pbf 0/0/0 0/0/0 + ./tippecanoe-overzoom -o tests/pbf/0-0-0-pop-0-0-0.pbf.out --accumulate-numeric-attributes --assign-to-bins tests/pbf/h3-0-0-0.geojson tests/pbf/0-0-0.pbf 0/0/0 0/0/0 ./tippecanoe-decode tests/pbf/0-0-0-pop-0-0-0.pbf.out 0 0 0 > tests/pbf/0-0-0-pop-0-0-0.pbf.out.json.check cmp tests/pbf/0-0-0-pop-0-0-0.pbf.out.json.check tests/pbf/0-0-0-pop-0-0-0.pbf.out.json rm tests/pbf/0-0-0-pop-0-0-0.pbf.out tests/pbf/0-0-0-pop-0-0-0.pbf.out.json.check diff --git a/clip.cpp b/clip.cpp index 2b7642b4..6b976b8c 100644 --- a/clip.cpp +++ b/clip.cpp @@ -1157,14 +1157,14 @@ static void feature_out(std::vector const &features, mvt_layer &ou std::map numeric_out_field; for (size_t i = 0; i + 1 < features[0].tags.size(); i += 2) { - auto f = attribute_accum.find(features[0].layer->keys[features[0].tags[i]]); + const std::string &key = features[0].layer->keys[features[0].tags[i]]; + auto f = attribute_accum.find(key); if (f != attribute_accum.end()) { // this attribute has an accumulator, so convert it full_keys.push_back(features[0].layer->keys[features[0].tags[i]]); full_values.push_back(mvt_value_to_serial_val(features[0].layer->values[features[0].tags[i + 1]])); } else if (accumulate_numeric && features[0].layer->values[features[0].tags[i + 1]].is_numeric()) { // convert numeric for accumulation - const std::string &key = features[0].layer->keys[features[0].tags[i]]; numeric_out_field.emplace(key, full_keys.size()); full_keys.push_back(key); full_values.push_back(mvt_value_to_serial_val(features[0].layer->values[features[0].tags[i + 1]])); @@ -1202,8 +1202,9 @@ static void feature_out(std::vector const &features, mvt_layer &ou // same attribute, we want to use that one instead of this one. for (auto const &op : numeric_operations) { - auto compound_found = keys.find("tipppecanoe:" + op.first + ":" + key); - if (compound_found == keys.end()) { + std::string compound_key = "tipppecanoe:" + op.first + ":" + key; + auto compound_found = keys.find(compound_key); + if (compound_found != keys.end()) { // found, so skip this one } else { // not found, so accumulate this one