[gnome-maps/wip/mlundblad/lht-roundabouts] route: Use mirrored roundabout icons for LHT



commit 7e1cf34a90c10f3ad583dd46cefd8a62910ee4e9
Author: Marcus Lundblad <ml update uu se>
Date:   Mon Jun 10 23:26:51 2019 +0200

    route: Use mirrored roundabout icons for LHT
    
    Use the mirrored roundabout icons for
    left-hand traffic countries/territories.

 src/route.js | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
---
diff --git a/src/route.js b/src/route.js
index 9777d67..f729ae0 100644
--- a/src/route.js
+++ b/src/route.js
@@ -41,6 +41,18 @@ var TurnPointType = {
     START:         10000
 };
 
+/* countries/terrotories driving on the left
+ * source: https://en.wikipedia.org/wiki/Left-_and_right-hand_traffic
+ */
+const LHT_COUNTRIES = new Set(['AG', 'AU', 'BB', 'BD', 'BN', 'BS', 'BT', 'BW',
+                               'CY', 'DO', 'FJ', 'GB', 'GD', 'GY', 'HK', 'ID',
+                               'IE', 'IN', 'JM', 'JP', 'KE', 'KI', 'KN', 'LC',
+                               'LK', 'LS', 'MO', 'MT', 'MU', 'MV', 'MW', 'MY',
+                               'MZ', 'NA', 'NP', 'NR', 'NZ', 'PG', 'PK', 'SB',
+                               'SC', 'SG', 'SR', 'SZ', 'TH', 'TL', 'TO', 'TT',
+                               'TV', 'TZ', 'UG', 'VC', 'VI', 'WS', 'ZA', 'ZM',
+                               'ZW']);
+
 var Route = GObject.registerClass({
     Signals: {
         'update': {},
@@ -145,6 +157,16 @@ var TurnPoint = class TurnPoint {
                 angle = x;
             }
         }
-        return 'maps-direction-roundabout-' + angle + '-symbolic';
+        return 'maps-direction-roundabout-' + angle +
+               (angle !== 0 && this._isLefthandTraffic() ? '-lht' : '') +
+               '-symbolic';
+    }
+
+    _isLefthandTraffic() {
+        let country =
+            Utils.getCountryCodeForCoordinates(this.coordinate.latitude,
+                                               this.coordinate.longitude);
+
+        return LHT_COUNTRIES.has(country);
     }
 };


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]