[gnome-maps/wip/mlundblad/transit-routing: 7/25] 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: 7/25] routeService: WIP, Enable querying GraphHopper externally
- Date: Sun, 28 Aug 2016 21:11:35 +0000 (UTC)
commit 9102cdc43fa9a7eb693752b0bc12667c3ddf8a31
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 | 51 ++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 38 insertions(+), 13 deletions(-)
---
diff --git a/src/routeService.js b/src/routeService.js
index d887c31..b8808e0 100644
--- a/src/routeService.js
+++ b/src/routeService.js
@@ -79,35 +79,60 @@ 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,
+ (function(result, exception) {
+ if (result) {
+ let route = this._createRoute(result.paths[0]);
+ callback(route, exception);
+ } else {
+ callback(null, exception);
}
}).bind(this));
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]