[gnome-maps/wip/jonasdn/storedRoute: 111/118] routeService: Handle stored routes
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/jonasdn/storedRoute: 111/118] routeService: Handle stored routes
- Date: Sun, 16 Aug 2015 19:17:30 +0000 (UTC)
commit a9f150399efca76a27e6ed973977784a24092400
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Thu Feb 12 20:45:49 2015 +0100
routeService: Handle stored routes
src/routeService.js | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/src/routeService.js b/src/routeService.js
index 404be06..c1d2880 100644
--- a/src/routeService.js
+++ b/src/routeService.js
@@ -22,6 +22,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;
@@ -49,6 +50,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::points', (function() {
if (this.query.isValid())
@@ -59,7 +61,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]