[gnome-maps/wip/routing2: 2/8] Add abstract RouteService class



commit a21601ddf844036c76f682dab4c76e7b1145ae2a
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date:   Fri Aug 23 06:15:55 2013 +0200

    Add abstract RouteService class
    
    The RouteService class is meant as a base class for
    route service classes.

 src/gnome-maps.js.gresource.xml |    1 +
 src/routeService.js             |   65 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 66 insertions(+), 0 deletions(-)
---
diff --git a/src/gnome-maps.js.gresource.xml b/src/gnome-maps.js.gresource.xml
index 5fbdbda..1770331 100644
--- a/src/gnome-maps.js.gresource.xml
+++ b/src/gnome-maps.js.gresource.xml
@@ -14,6 +14,7 @@
     <file>path.js</file>
     <file>placeStore.js</file>
     <file>route.js</file>
+    <file>routeService.js</file>
     <file>searchPopup.js</file>
     <file>settings.js</file>
     <file>sidebar.js</file>
diff --git a/src/routeService.js b/src/routeService.js
new file mode 100644
index 0000000..16e44c1
--- /dev/null
+++ b/src/routeService.js
@@ -0,0 +1,65 @@
+/* -*- Mode: JS2; indent-tabs-mode: nil; js2-basic-offset: 4 -*- */
+/* vim: set et ts=4 sw=4: */
+/*
+ * Copyright (c) 2013 Mattias Bengtsson.
+ *
+ * GNOME Maps is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * GNOME Maps is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with GNOME Maps; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
+ */
+
+const Soup = imports.gi.Soup;
+
+const Lang = imports.lang;
+
+const Route = imports.route;
+const Polyline = imports.polyline;
+const HTTP = imports.http;
+
+const Transportation = {
+    CAR:     0,
+    BIKE:    1,
+    FOOT:    2,
+    TRANSIT: 3
+};
+
+const RouteService = new Lang.Class({
+    Name: 'RouteService',
+    Abstract: true,
+
+    _init: function() {
+        this._session = new Soup.SessionAsync({ user_agent : "gnome-maps " });
+    },
+
+    _buildURL: function(viaPoints, transportation) {},
+
+    _parseResult: function(result) {},
+
+    _transportationToString: function() {},
+
+    getRoute: function(viaPoints, transportationType, callback) {
+        let url = this._buildURL(viaPoints, transportationType),
+            msg = Soup.Message.new('GET', url);
+        this._session.queue_message(msg, (function(session, message) {
+            if (message.status_code === 200) {
+                let result = message.response_body.data;
+                callback(this._parseResult(result));
+            } else {
+                log("Error: " + message.status_code);
+                callback(null);
+            }
+        }).bind(this));
+    }
+});


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