float MapScale::getScreenRotation(float angle, const atools::geo::Pos& position, float zoomDistanceMeter) const { if(viewport != nullptr && viewport->projection() == Marble::Spherical && zoomDistanceMeter > 50) { // Get screen coordinates or origin Marble::GeoDataCoordinates coords(position.getLonX(), position.getLatY(), 0., GeoDataCoordinates::Degree); bool globeHidesPoint = false, globeHidesPointEnd = false; double x = 0., y = 0., xEnd = 0., yEnd = 0.; bool visible = viewport->screenCoordinates(coords, x, y, globeHidesPoint); if(globeHidesPoint || !visible) // Not visible return map::INVALID_COURSE_VALUE; // Use a tenth of the zoom distance which results in a screen length of 15 - 30 pixel // Calculate endpoint in global coordinate system Pos end = position.endpoint(zoomDistanceMeter / 10.f, angle); end.normalize(); // Calculate screen coordinates of endpoint Marble::GeoDataCoordinates endcoords(end.getLonX(), end.getLatY(), 0., GeoDataCoordinates::Degree); viewport->screenCoordinates(endcoords, xEnd, yEnd, globeHidesPointEnd); if(!globeHidesPointEnd) { QLineF line(x, y, xEnd, yEnd); // qDebug() << Q_FUNC_INFO << line.length(); if(line.length() > 5.) angle = atools::geo::normalizeCourse( static_cast<float>(atools::geo::angleFromQt(line.angle()))); else return map::INVALID_COURSE_VALUE; } else // Hide if endpoint is not visible return map::INVALID_COURSE_VALUE; } return angle; }