1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 05:34:47 +01:00

Properly split the paths exactly at the date line

This commit is contained in:
Martin Tůma 2018-09-17 20:11:23 +02:00
parent eaef588443
commit 2bee8656a4

View File

@ -49,9 +49,26 @@ void PathItem::updateShape()
void PathItem::addSegment(const Coordinates &c1, const Coordinates &c2) void PathItem::addSegment(const Coordinates &c1, const Coordinates &c2)
{ {
if (fabs(c1.lon() - c2.lon()) > 180.0) if (fabs(c1.lon() - c2.lon()) > 180.0) {
_painterPath.moveTo(_map->ll2xy(c2)); QPointF p;
else
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)); _painterPath.lineTo(_map->ll2xy(c2));
} }