Avoid crash if the first bin gets clipped away

This commit is contained in:
Erica Fischer
2024-11-12 22:10:06 -08:00
parent 794ae2b1eb
commit 1e9be2f740
+8 -3
View File
@@ -1299,7 +1299,8 @@ static void handle_closepath_from_mvt(drawvec &geom) {
} }
} }
static void feature_out(std::vector<tile_feature> const &features, mvt_layer &outlayer, // returns true if a feature was output; false if it was clipped away
static bool feature_out(std::vector<tile_feature> const &features, mvt_layer &outlayer,
std::set<std::string> const &keep, std::set<std::string> const &keep,
std::set<std::string> const &exclude, std::set<std::string> const &exclude,
std::vector<std::string> const &exclude_prefix, std::vector<std::string> const &exclude_prefix,
@@ -1427,7 +1428,10 @@ static void feature_out(std::vector<tile_feature> const &features, mvt_layer &ou
} }
outlayer.features.push_back(std::move(outfeature)); outlayer.features.push_back(std::move(outfeature));
return true;
} }
return false;
} }
static struct preservecmp { static struct preservecmp {
@@ -1719,9 +1723,9 @@ mvt_tile assign_to_bins(mvt_tile &features,
for (size_t i = 0; i < outfeatures.size(); i++) { for (size_t i = 0; i < outfeatures.size(); i++) {
if (outfeatures[i].size() > 1) { if (outfeatures[i].size() > 1) {
feature_out(outfeatures[i], outlayer, if (feature_out(outfeatures[i], outlayer,
keep, exclude, exclude_prefix, attribute_accum, keep, exclude, exclude_prefix, attribute_accum,
accumulate_numeric, key_pool, buffer); accumulate_numeric, key_pool, buffer)) {
mvt_feature &nfeature = outlayer.features.back(); mvt_feature &nfeature = outlayer.features.back();
mvt_value val; mvt_value val;
val.type = mvt_uint; val.type = mvt_uint;
@@ -1736,6 +1740,7 @@ mvt_tile assign_to_bins(mvt_tile &features,
outlayer.tag(nfeature, attrname, val); outlayer.tag(nfeature, attrname, val);
} }
} }
}
mvt_tile ret; mvt_tile ret;
ret.layers.push_back(outlayer); ret.layers.push_back(outlayer);