From 7ac01660d7efd8ce7939a7934a6f5546e26f6c86 Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Thu, 9 Apr 2015 12:17:43 -0700 Subject: [PATCH] port line icon angle fix -js: 37a498a7aa2c37d6b94611b614b4efe134e6dd59 --- src/mbgl/text/quads.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mbgl/text/quads.cpp b/src/mbgl/text/quads.cpp index 42b01b748..a30269035 100644 --- a/src/mbgl/text/quads.cpp +++ b/src/mbgl/text/quads.cpp @@ -22,8 +22,8 @@ SymbolQuads getIconQuads(Anchor &anchor, const PositionedIcon &shapedIcon, float angle = layout.icon.rotate * M_PI / 180.0f; if (alongLine) { assert(static_cast(anchor.segment) < line.size()); - const Coordinate &next = line[anchor.segment]; - angle += -std::atan2(next.x - anchor.x, next.y - anchor.y) + M_PI / 2; + const Coordinate &prev= line[anchor.segment]; + angle += std::atan2(anchor.y - prev.y, anchor.x - prev.x); } @@ -82,7 +82,9 @@ void getSegmentGlyphs(std::back_insert_iterator glyphs, Anchor & while (true) { const float dist = util::dist(newAnchor, end); const float scale = offset / dist; - float angle = -std::atan2(end.x - newAnchor.x, end.y - newAnchor.y) + direction * M_PI / 2.0f; + float angle = std::atan2(end.y - newAnchor.y, end.x - newAnchor.x); + if (direction < 0) + angle += M_PI; if (upsideDown) angle += M_PI;