From 9482649ae5fc34b646a3145bbe1a43fe0c2a8766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Mon, 5 Oct 2015 14:52:10 -0700 Subject: [PATCH] [core] Look the other way when placing icon at start of line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When an anchor is at the beginning of a line, its segment’s coordinates match its own coordinates, resulting in an angle of 0°. When the segment’s coordinates match the anchor’s coordinates, consider the next segment instead. Fixes #2474. --- src/mbgl/text/quads.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mbgl/text/quads.cpp b/src/mbgl/text/quads.cpp index 19c48d731..61f5eef71 100644 --- a/src/mbgl/text/quads.cpp +++ b/src/mbgl/text/quads.cpp @@ -28,7 +28,13 @@ SymbolQuads getIconQuads(Anchor &anchor, const PositionedIcon &shapedIcon, if (alongLine) { assert(static_cast(anchor.segment) < line.size()); const Coordinate &prev= line[anchor.segment]; - angle += std::atan2(anchor.y - prev.y, anchor.x - prev.x); + if (anchor.y == prev.y && anchor.x == prev.x && + static_cast(anchor.segment + 1) < line.size()) { + const Coordinate &next= line[anchor.segment + 1]; + angle += std::atan2(anchor.y - next.y, anchor.x - next.x) + M_PI; + } else { + angle += std::atan2(anchor.y - prev.y, anchor.x - prev.x); + } }