mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 11:45:53 +01:00
Properly split the paths exactly at the date line
This commit is contained in:
parent
eaef588443
commit
2bee8656a4
@ -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));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user