[gnome-maps/wip/mlundblad/resrobot-tourist-trains] resrobot: Use tourist railway for selected operators




commit e712a0355f86561354b4974fb70b5b967c393607
Author: Marcus Lundblad <ml dfupdate se>
Date:   Wed Jun 22 22:02:24 2022 +0200

    resrobot: Use tourist railway for selected operators
    
    Override the route type for selected
    heritage railway operators to show
    the tourist train icon on journey legs.

 src/transitplugins/resrobot.js | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
---
diff --git a/src/transitplugins/resrobot.js b/src/transitplugins/resrobot.js
index 29a84a92..d019640e 100644
--- a/src/transitplugins/resrobot.js
+++ b/src/transitplugins/resrobot.js
@@ -88,6 +88,13 @@ const WALK_SEARCH_RADIUS = 2000;
 // maximum distance for walk-only journey
 const MAX_WALK_ONLY_DISTANCE = 2500;
 
+/* set of transit agencies where "regional rail" is interpreted as
+ * HVT.TOURIST_RAILWAY_SERVICE, e.g. heritage rail
+ */
+const TOURIST_TRAIN_AGENCIES = new Set(['Engelsberg-Norbergs Jä',
+                                        'Lennakatten',
+                                        'TJF Smalspåret']);
+
 export class Resrobot {
     constructor(params) {
         this._session = new Soup.Session({ user_agent : 'gnome-maps/' + pkg.version });
@@ -438,6 +445,16 @@ export class Resrobot {
         let polyline = this._createPolylineForLeg(leg);
         let duration = leg.duration ? this._parseDuration(leg.duration) : null;
 
+        /* if the route leg is classified as regional rail and the agency
+         * is one of the heritage railways, use tourist rail to get the
+         * steam train icon
+         */
+        if ((routeType === HVT.REGIONAL_RAIL_SERVICE ||
+             routeType === HVT.SUBURBAN_RAILWAY_SERVICE ) &&
+            TOURIST_TRAIN_AGENCIES.has(agencyName)) {
+            routeType = HVT.TOURIST_RAILWAY_SERVICE;
+        }
+
         let result = new Leg({ departure:            departure,
                                arrival:              arrival,
                                from:                 from,


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