Correct for distortion of globe.
In the timezone widget, locations in the far north -- Inuvik, Thule, Longyearbyen -- were displayed too far south, because the map location calculation assumes a linear gradient, which places 90 degrees north at about 70 degrees. Change calculation to pretend the world is flat south of 62 degrees north, and then 'bend' the remaining 28 degrees of latitude to the top of the image. This puts most places in the right spot, although Yellowknife is now on the south shore of Great Slave. Fort Nelson should be north of Dawson Creek, too -- the math still needs a little work. While here, put Antarctica in the south, otherwise Rothera keeps showing up in Greenland.
This commit is contained in:
parent
b1bae4152a
commit
78031636af
@ -20,8 +20,12 @@
|
|||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
#include "timezonewidget.h"
|
#include "timezonewidget.h"
|
||||||
|
|
||||||
|
constexpr double MATH_PI = 3.14159265;
|
||||||
|
|
||||||
TimeZoneWidget::TimeZoneWidget(QWidget* parent) :
|
TimeZoneWidget::TimeZoneWidget(QWidget* parent) :
|
||||||
QWidget(parent)
|
QWidget(parent)
|
||||||
{
|
{
|
||||||
@ -98,6 +102,17 @@ QPoint TimeZoneWidget::getLocationPosition(double longitude, double latitude) {
|
|||||||
double x = (width / 2.0 + (width / 2.0) * longitude / 180.0) + MAP_X_OFFSET * width;
|
double x = (width / 2.0 + (width / 2.0) * longitude / 180.0) + MAP_X_OFFSET * width;
|
||||||
double y = (height / 2.0 - (height / 2.0) * latitude / 90.0) + MAP_Y_OFFSET * height;
|
double y = (height / 2.0 - (height / 2.0) * latitude / 90.0) + MAP_Y_OFFSET * height;
|
||||||
|
|
||||||
|
//Far north, the MAP_Y_OFFSET no longer holds, cancel the Y offset; it's noticeable
|
||||||
|
// from 62 degrees north, so scale those 28 degrees as if the world is flat south
|
||||||
|
// of there, and we have a funny "rounded" top of the world. In practice the locations
|
||||||
|
// of the different cities / regions looks ok -- at least Thule ends up in the right
|
||||||
|
// country, and Inuvik isn't in the ocean.
|
||||||
|
if (latitude > 62.0)
|
||||||
|
y -= sin(MATH_PI * (latitude - 62.0) / 56.0) * MAP_Y_OFFSET * height;
|
||||||
|
// Antarctica isn't shown on the map, but you could try clicking there
|
||||||
|
if (latitude < -60)
|
||||||
|
y = height - 1;
|
||||||
|
|
||||||
if (x < 0)
|
if (x < 0)
|
||||||
x = width+x;
|
x = width+x;
|
||||||
if (x >= width)
|
if (x >= width)
|
||||||
|
Loading…
Reference in New Issue
Block a user