[gnome-maps/wip/jonasdn/storedRoute: 4/13] routeService: Handle stored routes
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/jonasdn/storedRoute: 4/13] routeService: Handle stored routes
- Date: Thu, 12 Feb 2015 20:05:16 +0000 (UTC)
commit 1c0509466cc42114957d4b5841dc50ad7a42fe02
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Thu Feb 12 20:45:49 2015 +0100
routeService: Handle stored routes
https://bugzilla.gnome.org/show_bug.cgi?id=744425
src/routeService.js | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/src/routeService.js b/src/routeService.js
index 82aa727..769f9ef 100644
--- a/src/routeService.js
+++ b/src/routeService.js
@@ -23,6 +23,7 @@
const Champlain = imports.gi.Champlain;
const GLib = imports.gi.GLib;
const Lang = imports.lang;
+const Mainloop = imports.mainloop;
const Soup = imports.gi.Soup;
const Application = imports.application;
@@ -50,6 +51,7 @@ const GraphHopper = new Lang.Class({
this._locale = GLib.get_language_names()[0];
this._route = new Route.Route();
this._query = new RouteQuery.RouteQuery();
+ this.storedRoute = null;
this.query.connect('notify', (function() {
if (this.query.isValid())
@@ -60,7 +62,26 @@ const GraphHopper = new Lang.Class({
this.parent();
},
+ _updateFromStored: function() {
+ Mainloop.idle_add((function() {
+ if (!this.storedRoute)
+ return;
+
+ this.route.update({ path: this.storedRoute.path,
+ turnPoints: this.storedRoute.turnPoints,
+ distance: this.storedRoute.distance,
+ time: this.storedRoute.time,
+ bbox: this.storedRoute.bbox });
+ this.storedRoute = null;
+ }).bind(this));
+ },
+
fetchRoute: function(points, transportationType) {
+ if (this.storedRoute) {
+ this._updateFromStored();
+ return;
+ }
+
let url = this._buildURL(points, transportationType);
let msg = Soup.Message.new('GET', url);
this._session.queue_message(msg, (function(session, message) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]