Merge pull request #365 from AdenKoperczak/fix_tooltips_at_high_zooms

Fix tooltips at high zooms
This commit is contained in:
Dan Paulat 2025-02-14 08:44:12 -06:00 committed by GitHub
commit efb54b123c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -46,7 +46,10 @@ glm::vec2 GetMapScale(const QMapLibre::CustomLayerRenderParameters& params)
bool IsPointInPolygon(const std::vector<glm::vec2>& 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;
// For each vertex, assume counterclockwise order
for (std::size_t i = 0; i < vertices.size(); ++i)
@ -55,6 +58,8 @@ bool IsPointInPolygon(const std::vector<glm::vec2>& 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,7 +75,14 @@ bool IsPointInPolygon(const std::vector<glm::vec2>& vertices,
}
}
if (allSame)
{
inPolygon = vertices.size() > 0 && vertices[0].x == point.x &&
vertices[0].y == point.y;
}
return inPolygon;
// NOLINTEND(cppcoreguidelines-pro-type-union-access)
}
glm::vec2 LatLongToScreenCoordinate(const QMapLibre::Coordinate& coordinate)