From c3d06f89315a43545d2e7773b1d17ab29e8f6890 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Thu, 11 Oct 2018 17:04:03 -0700 Subject: [PATCH] Only movetos and linetos have elevations, not closepaths --- mvt.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/mvt.cpp b/mvt.cpp index 0d18e50..2a2d934 100644 --- a/mvt.cpp +++ b/mvt.cpp @@ -468,18 +468,20 @@ bool mvt_tile::decode(std::string &message, bool &was_compressed) { std::vector &elevations = layer.features[i].elevations; if (elevations.size() != 0) { for (size_t j = 0; j < geom.size(); j++) { - if (off < elevations.size()) { - double el; + if (geom[j].op == mvt_moveto || geom[j].op == mvt_lineto) { + if (off < elevations.size()) { + double el; - current_elevation += elevations[off]; - el = elevation_scaling.base + elevation_scaling.multiplier * current_elevation; + current_elevation += elevations[off]; + el = elevation_scaling.base + elevation_scaling.multiplier * current_elevation; - geom[j].elevations.push_back(el); + geom[j].elevations.push_back(el); - off++; - } else { - fprintf(stderr, "Ran out of elevations\n"); - exit(EXIT_FAILURE); + off++; + } else { + fprintf(stderr, "Ran out of elevations\n"); + exit(EXIT_FAILURE); + } } } }