[gnome-maps/wip/routing: 2/8] Add abstract RouteService class
- From: Mattias Bengtsson <mattiasb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/routing: 2/8] Add abstract RouteService class
- Date: Wed, 28 Aug 2013 01:09:19 +0000 (UTC)
commit 44a29c5ad8555ba9d123e02e175578d2b449394b
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/Makefile-js.am | 1 +
src/routeService.js | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 66 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile-js.am b/src/Makefile-js.am
index bd84957..6eff717 100644
--- a/src/Makefile-js.am
+++ b/src/Makefile-js.am
@@ -7,6 +7,7 @@ dist_js_DATA = \
mapView.js \
path.js \
route.js \
+ routeService.js \
sidebar.js \
utils.js \
userLocation.js \
diff --git a/src/routeService.js b/src/routeService.js
new file mode 100644
index 0000000..64caa63
--- /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() {},
+
+ request: function(viaPoints, transportationType, callback) {
+ let url = this._buildURL(viaPoints, transportationType),
+ request = new Soup.Message('GET', url);
+ this._session.queue_message(request, (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]