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)); }