[gnome-maps/wip/osrm-routing: 6/21] Add basic status code handling to routing



commit 38b5d90ded3bc01adcb7df68702ce59eae4fee7e
Author: Jussi Kukkonen <jku goto fi>
Date:   Mon Apr 22 16:31:44 2013 +0300

    Add basic status code handling to routing

 src/mapView.js |    9 +++++++--
 src/osrm.js    |   20 ++++++++++++++++++--
 2 files changed, 25 insertions(+), 4 deletions(-)
---
diff --git a/src/mapView.js b/src/mapView.js
index 102030d..835336d 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -106,8 +106,13 @@ const MapView = new Lang.Class({
 
         router.calculateRoute(Lang.bind(this, function(route) {
             if (!route) {
-                log("No route found");
-                /* TODO: ? */
+                log("Routing not succesful");
+                // TODO ?
+                return;
+            }
+            if (route.status != osrm.Status.SUCCESSFUL) {
+                log("Routing not succesful, status " + route.status);
+                // TODO ?
                 return;
             }
             log("Got a " +route.length+ "m route with " + route.points.length + " nodes and " +
diff --git a/src/osrm.js b/src/osrm.js
index aaa8052..762ca86 100644
--- a/src/osrm.js
+++ b/src/osrm.js
@@ -45,6 +45,22 @@ const TurnInstruction = {
     "17":   "Leave against allowed direction" // ?
 }
 
+const Status = {
+    SUCCESSFUL: 0,
+    UNKNOWN_SERVER_ERROR: 1,
+    INVALID_PARAMETER: 2,
+    PARAMETER_OUT_OF_RANGE: 3,
+    REQUIRED_PARAMETER_MISSING: 4,
+    SERVICE_UNAVAILABLE: 5,
+    ROUTE_IS_BLOCKED: 202,
+    DB_CORRUPTED: 205,
+    DB_IS_NOT_OPEN: 206,
+    NO_ROUTE: 207,
+    INVALID_START_POINT: 208,
+    INVALID_END_POINT: 209,
+    START_AND_END_POINTS_ARE_EQUAL: 210,
+}
+
 const RoutePoint = new Lang.Class({
     Name: 'RoutePoint',
 
@@ -86,8 +102,8 @@ const Route = new Lang.Class({
             return;
         }
 
-        if (osrm_json.status != "0") {
-            log("Route has status " + osrm_json.status)
+        this.status = osrm_json.status;
+        if (this.status != 0) {
             return;
         }
 


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