Skip to content

Commit

Permalink
warn on rejected line geometry
Browse files Browse the repository at this point in the history
  • Loading branch information
TimSylvester committed Dec 12, 2024
1 parent 72d2c70 commit 7cf4738
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/mbgl/renderer/buckets/line_bucket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,19 @@ void LineBucket::addGeometry(const GeometryCoordinates& coordinates,
}();

// Ignore invalid geometry.
if (len < (options.type == FeatureType::Polygon ? 3 : 2)) {
const std::size_t minLen = (options.type == FeatureType::Polygon ? 3 : 2);
if (len < minLen) {
// Warn once, but only if the source geometry is invalid, not if de-duplication made it invalid.
// This happens, e.g., when attempting to use a GeoJSON `MultiPoint`
// or `MLNPointCollectionFeature` as the source for a line layer.
// Unfortunately, we cannot show the layer or source name from here.
if (coordinates.size() < minLen) {
static bool warned = false; // not thread-safe, there's a small chance of warning more than once
if (!warned) {
warned = true;
Log::Warning(Event::General, "Invalid geometry in line layer");
}
}
return;
}

Expand Down

0 comments on commit 7cf4738

Please sign in to comment.