From 2bee8656a4437d93b70567417949e126359de71d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Mon, 17 Sep 2018 20:11:23 +0200 Subject: [PATCH] Properly split the paths exactly at the date line --- src/GUI/pathitem.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/GUI/pathitem.cpp b/src/GUI/pathitem.cpp index 4749e178..93b4f8ab 100644 --- a/src/GUI/pathitem.cpp +++ b/src/GUI/pathitem.cpp @@ -49,9 +49,26 @@ void PathItem::updateShape() void PathItem::addSegment(const Coordinates &c1, const Coordinates &c2) { - if (fabs(c1.lon() - c2.lon()) > 180.0) - _painterPath.moveTo(_map->ll2xy(c2)); - else + if (fabs(c1.lon() - c2.lon()) > 180.0) { + QPointF p; + + if (c2.lon() < 0) { + QLineF l(QPointF(c1.lon(), c1.lat()), QPointF(c2.lon() + 360, + c2.lat())); + QLineF dl(QPointF(180, -90), QPointF(180, 90)); + l.intersect(dl, &p); + _painterPath.lineTo(_map->ll2xy(Coordinates(180, p.y()))); + _painterPath.moveTo(_map->ll2xy(Coordinates(-180, p.y()))); + } else { + QLineF l(QPointF(c1.lon(), c1.lat()), QPointF(c2.lon() - 360, + c2.lat())); + QLineF dl(QPointF(-180, -90), QPointF(-180, 90)); + l.intersect(dl, &p); + _painterPath.lineTo(_map->ll2xy(Coordinates(-180, p.y()))); + _painterPath.moveTo(_map->ll2xy(Coordinates(180, p.y()))); + } + _painterPath.lineTo(_map->ll2xy(c2)); + } else _painterPath.lineTo(_map->ll2xy(c2)); }