[gnome-maps/wip/mlundblad/transit-routing: 4/9] routeService: WIP, Enable querying GraphHopper externally
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/transit-routing: 4/9] routeService: WIP, Enable querying GraphHopper externally
- Date: Sun, 22 May 2016 20:54:09 +0000 (UTC)
commit 523480b39bca354ab5878a51957e1fc9065f65d0
Author: Marcus Lundblad <ml update uu se>
Date: Tue Apr 5 22:00:38 2016 +0200
routeService: WIP, Enable querying GraphHopper externally
Add a way to do a route query without triggering route signals.
This will be used by the OpenTripPlanner module to use the existing
GraphHopper services to calculate walking (and maybe
pontentially in the future car and bike park-and-ride) segments
in an intinerary.
src/routeService.js | 43 ++++++++++++++++++++++++++++++-------------
1 files changed, 30 insertions(+), 13 deletions(-)
---
diff --git a/src/routeService.js b/src/routeService.js
index d887c31..385c9c9 100644
--- a/src/routeService.js
+++ b/src/routeService.js
@@ -79,39 +79,56 @@ const GraphHopper = new Lang.Class({
}).bind(this));
},
+ _queryGraphHopper: function(points, transportationType, callback) {
+ let url = this._buildURL(points, transportationType);
+ let msg = Soup.Message.new('GET', url);
+ this._session.queue_message(msg, (function(session, message) {
+ try {
+ let result = this._parseMessage(message);
+ if (!result)
+ callback(null, null);
+ else
+ callback(result, null);
+ } catch (e) {
+ callback(null, e);
+ }
+ }).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) {
- try {
- let result = this._parseMessage(message);
+ this._queryGraphHopper(points, transportationType,
+ (function(result, exception) {
+ if (exception) {
+ Application.notificationManager.showMessage(_("Route request failed."));
+ Utils.debug(e);
+ if (this._query.latest)
+ this._query.latest.place = null;
+ else
+ this.route.reset();
+ } else {
if (!result) {
Application.notificationManager.showMessage(_("No route found."));
if (this._query.latest)
this._query.latest.place = null;
else
this.route.reset();
-
} else {
let route = this._createRoute(result.paths[0]);
this.route.update(route);
}
- } catch(e) {
- Application.notificationManager.showMessage(_("Route request failed."));
- Utils.debug(e);
- if (this._query.latest)
- this._query.latest.place = null;
- else
- this.route.reset();
}
}).bind(this));
},
+ fetchRouteAsync: function(points, transportationType, callback) {
+ this._queryGraphHopper(points, transportationType, callback);
+ },
+
_buildURL: function(points, transportation) {
let locations = points.map(function(point) {
return [point.place.location.latitude, point.place.location.longitude].join(',');
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]