From 2c18ba6ddb37a9d220b86c1cbc5b7cc1ac63ec54 Mon Sep 17 00:00:00 2001
From: Adriaan de Groot <groot@kde.org>
Date: Tue, 29 May 2018 05:52:07 -0400
Subject: [PATCH] [locale] Adjust latitude calculation in the southern
 hemisphere

The scaling on the map was a little off; the degrees of latitude
are a little wider there than around the equator and Europe.

 - Johannesburg is in the right spot
 - Hobart is no longer a suburb of Melbourne
 - Punta Arenas is in Chile
---
 src/modules/locale/timezonewidget/timezonewidget.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/modules/locale/timezonewidget/timezonewidget.cpp b/src/modules/locale/timezonewidget/timezonewidget.cpp
index a06d3169d..ae048ab6f 100644
--- a/src/modules/locale/timezonewidget/timezonewidget.cpp
+++ b/src/modules/locale/timezonewidget/timezonewidget.cpp
@@ -131,13 +131,17 @@ QPoint TimeZoneWidget::getLocationPosition( double longitude, double latitude )
     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;
 
-    //Far north, the MAP_Y_OFFSET no longer holds, cancel the Y offset; it's noticeable
+    // 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;
+    // Far south, some stretching occurs as well, but it is less pronounced.
+    // Move down by 1 pixel per 5 degrees past 10 south
+    if ( latitude < - 14 )
+        y += int( (-latitude) / 5.0 );
     // Antarctica isn't shown on the map, but you could try clicking there
     if ( latitude < -60 )
         y = height - 1;