From 7cf4738a8b0d096f22b7c725a2ff2c04049ec514 Mon Sep 17 00:00:00 2001 From: Tim Sylvester Date: Thu, 12 Dec 2024 09:47:33 -0800 Subject: [PATCH] warn on rejected line geometry --- src/mbgl/renderer/buckets/line_bucket.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/mbgl/renderer/buckets/line_bucket.cpp b/src/mbgl/renderer/buckets/line_bucket.cpp index f8c0198a728..ccfbdba8255 100644 --- a/src/mbgl/renderer/buckets/line_bucket.cpp +++ b/src/mbgl/renderer/buckets/line_bucket.cpp @@ -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; }