[gnome-maps/wip/routing2] fixup 2 routeservice



commit a509e6bf67aa1568a152810b27b9b83bc626009c
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date:   Sat May 24 00:29:53 2014 +0100

    fixup 2 routeservice

 src/routeService.js |   45 ++++++++++++++++++++++-----------------------
 1 files changed, 22 insertions(+), 23 deletions(-)
---
diff --git a/src/routeService.js b/src/routeService.js
index a562d0b..c0e2103 100644
--- a/src/routeService.js
+++ b/src/routeService.js
@@ -34,8 +34,6 @@ const Route = imports.route;
 const RouteQuery = imports.routeQuery;
 const Utils = imports.utils;
 
-const NoRouteFoundMessage = "No route found from %s to %s";
-
 const GraphHopper = new Lang.Class({
     Name: 'GraphHopper',
 
@@ -74,12 +72,18 @@ const GraphHopper = new Lang.Class({
                 let result = this._parseMessage(message);
                 if(result.info && result.info.errors) {
                     Application.notificationManager.showMessage(_("No route found."));
+                    Utils.debug("No route found:");
+                    result.info.errors.forEach(function({ message, details }) {
+                        Utils.debug("Message: " + message);
+                        Utils.debug("Details: " + details);
+                    });
                 } else {
                     let route = this._createRoute(result.paths[0]);
                     this.route.update(route);
                 }
             } catch(e) {
                 Application.notificationManager.showMessage(_("Route request failed."));
+                log(e);
             }
         }).bind(this));
     },
@@ -101,39 +105,34 @@ const GraphHopper = new Lang.Class({
         return url;
     },
 
-    _parseMessage: function({ status_code, response_body }) {
+    _parseMessage: function({ status_code, response_body, uri }) {
+        log("TEST: " + uri.to_string());
         if (status_code === 200)
             return JSON.parse(response_body.data);
 
-        if(status_code === 500)
-            this._logInternalServerError(response_body);
-
+        if(status_code === 500) {
+            log("Internal server error.\n"
+                + "This is most likely a bug in GraphHopper");
+            log("Please file a bug at https://github.com/graphhopper/graphhopper/issues\n";
+                + "with the the following Graphopper request URL included:\n");
+            log("");
+        }
         return null;
     },
-    
-    _logInternalServerError: function(body) {
-        // TODO: log
-        /*
-
-         Internal server error. It is strongely 
-         recommended to send us the message and the link 
-         to it, as it is very likely a bug in our system.
-         */
-    },
 
-    _createRoute: function(result) {
-        let path       = EPAF.decode(result.points);
-        let turnPoints = this._createTurnPoints(path, result.instructions);
+    _createRoute: function(route) {
+        let path       = EPAF.decode(route.points);
+        let turnPoints = this._createTurnPoints(path, route.instructions);
         let bbox       = new Champlain.BoundingBox();
 
         // GH does lonlat-order and Champlain latlon-order
-        bbox.extend(result.bbox[1], result.bbox[0]);
-        bbox.extend(result.bbox[3], result.bbox[2]);
+        bbox.extend(route.bbox[1], route.bbox[0]);
+        bbox.extend(route.bbox[3], route.bbox[2]);
 
         return { path:       path,
                  turnPoints: turnPoints,
-                 distance:   result.distance,
-                 time:       result.time,
+                 distance:   route.distance,
+                 time:       route.time,
                  bbox:       bbox };
     },
 


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