From e43c0594d1469db254e044e145b21d42a7cd3186 Mon Sep 17 00:00:00 2001 From: AdenKoperczak Date: Sun, 9 Feb 2025 13:07:42 -0500 Subject: [PATCH 1/3] Change IsPointInPolygon to check polygon with equal points correctly --- scwx-qt/source/scwx/qt/util/maplibre.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scwx-qt/source/scwx/qt/util/maplibre.cpp b/scwx-qt/source/scwx/qt/util/maplibre.cpp index 3414af41..5ff8b4ef 100644 --- a/scwx-qt/source/scwx/qt/util/maplibre.cpp +++ b/scwx-qt/source/scwx/qt/util/maplibre.cpp @@ -47,6 +47,7 @@ bool IsPointInPolygon(const std::vector& vertices, const glm::vec2& point) { bool inPolygon = true; + bool allSame = true; // For each vertex, assume counterclockwise order for (std::size_t i = 0; i < vertices.size(); ++i) @@ -55,6 +56,8 @@ bool IsPointInPolygon(const std::vector& vertices, const auto& p2 = (i == vertices.size() - 1) ? vertices[0] : vertices[i + 1]; + allSame = allSame && p1.x == p2.x && p1.y == p2.y; + // Test which side of edge point lies on const float a = -(p2.y - p1.y); const float b = p2.x - p1.x; @@ -70,6 +73,12 @@ bool IsPointInPolygon(const std::vector& vertices, } } + if (allSame) + { + inPolygon = vertices.size() > 0 && vertices[0].x == point.x && + vertices[0].y == point.y; + } + return inPolygon; } From fbed3fc8abab28759fbd89e0ef113f427748f94a Mon Sep 17 00:00:00 2001 From: AdenKoperczak Date: Sun, 9 Feb 2025 13:13:15 -0500 Subject: [PATCH 2/3] Clang tidy/format fixes for fix_tooltips_at_high_zooms --- scwx-qt/source/scwx/qt/util/maplibre.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scwx-qt/source/scwx/qt/util/maplibre.cpp b/scwx-qt/source/scwx/qt/util/maplibre.cpp index 5ff8b4ef..37387f99 100644 --- a/scwx-qt/source/scwx/qt/util/maplibre.cpp +++ b/scwx-qt/source/scwx/qt/util/maplibre.cpp @@ -47,7 +47,7 @@ bool IsPointInPolygon(const std::vector& vertices, const glm::vec2& point) { bool inPolygon = true; - bool allSame = true; + bool allSame = true; // For each vertex, assume counterclockwise order for (std::size_t i = 0; i < vertices.size(); ++i) From 84ce6589a314decbb66bc4176c2dc7aaa8da0078 Mon Sep 17 00:00:00 2001 From: AdenKoperczak Date: Fri, 14 Feb 2025 08:32:34 -0500 Subject: [PATCH 3/3] clang-tidy fixes for fix_tooltips_at_high_zooms --- scwx-qt/source/scwx/qt/util/maplibre.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scwx-qt/source/scwx/qt/util/maplibre.cpp b/scwx-qt/source/scwx/qt/util/maplibre.cpp index 37387f99..63f5112e 100644 --- a/scwx-qt/source/scwx/qt/util/maplibre.cpp +++ b/scwx-qt/source/scwx/qt/util/maplibre.cpp @@ -46,6 +46,8 @@ glm::vec2 GetMapScale(const QMapLibre::CustomLayerRenderParameters& params) bool IsPointInPolygon(const std::vector& vertices, const glm::vec2& point) { + // All members of these unions are floats, so no type safety violation + // NOLINTBEGIN(cppcoreguidelines-pro-type-union-access) bool inPolygon = true; bool allSame = true; @@ -80,6 +82,7 @@ bool IsPointInPolygon(const std::vector& vertices, } return inPolygon; + // NOLINTEND(cppcoreguidelines-pro-type-union-access) } glm::vec2 LatLongToScreenCoordinate(const QMapLibre::Coordinate& coordinate)