[gnome-maps] routingDelegator: Revert to fallback transportation when needed



commit bfb40c937bd9434bf361e6e58c359a12d7b2de31
Author: Marcus Lundblad <ml update uu se>
Date:   Sun May 28 23:38:34 2017 +0200

    routingDelegator: Revert to fallback transportation when needed
    
    When OpenTripPlanner is not available and the initial mode of the
    route query object is set to transit, revert back a fallback mode.
    This is done here as the route query object must be constructed before
    this.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=783089

 src/routingDelegator.js |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/src/routingDelegator.js b/src/routingDelegator.js
index 0032da7..d3896de 100644
--- a/src/routingDelegator.js
+++ b/src/routingDelegator.js
@@ -23,6 +23,9 @@
 
  const GraphHopper = imports.graphHopper;
  const OpenTripPlanner = imports.openTripPlanner;
+ const RouteQuery = imports.routeQuery;
+
+ const _FALLBACK_TRANSPORTATION = RouteQuery.Transportation.PEDESTRIAN;
 
  const RoutingDelegator = new Lang.Class({
     Name: 'RoutingDelegator',
@@ -39,6 +42,14 @@
             new OpenTripPlanner.OpenTripPlanner({ query: this._query,
                                                   graphHopper: this._graphHopper });
         this._query.connect('notify::points', this._onQueryChanged.bind(this));
+
+        /* if the query is set to transit mode when it's not available, revert
+         * to a fallback mode
+         */
+        if (this._query.transportation === RouteQuery.Transportation.TRANSIT &&
+            !this._openTripPlanner.enabled) {
+            this._query.transportation = _FALLBACK_TRANSPORTATION;
+        }
     },
 
     get graphHopper() {


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