[gnome-maps/wip/mlundblad/otp-router-url-param: 2/2] openTripPlanner: Support custom router URL
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/otp-router-url-param: 2/2] openTripPlanner: Support custom router URL
- Date: Wed, 2 Oct 2019 20:19:53 +0000 (UTC)
commit a1330ea03d0fae947f76f75e1e793b86a7ebbb44
Author: Marcus Lundblad <ml update uu se>
Date: Wed Oct 2 22:18:02 2019 +0200
openTripPlanner: Support custom router URL
Add support for setting the router URL directly
for case where <base URL>/routers/<id> doesn't
fit, such as for TriMet.
src/transitplugins/openTripPlanner.js | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/src/transitplugins/openTripPlanner.js b/src/transitplugins/openTripPlanner.js
index 6b942bd..d11b67f 100644
--- a/src/transitplugins/openTripPlanner.js
+++ b/src/transitplugins/openTripPlanner.js
@@ -117,10 +117,17 @@ var OpenTripPlanner = class OpenTripPlanner {
this._query = Application.routeQuery;
this._baseUrl = params.baseUrl;
this._router = params.router || 'default';
+ this._routerUrl = params.routerUrl || null;
this._onlyTransitData = params.onlyTransitData || false;
this._walkingRoutes = [];
this._extendPrevious = false;
this._language = Utils.getLanguage();
+
+ if (!this._baseUrl && !this._routerUrl)
+ throw new Error('must specify either baseUrl or routerUrl as an argument');
+
+ if (this._baseUrl && this._routerUrl)
+ throw new Error('can not specify both baseUrl and routerUrl as arguments');
}
get plan() {
@@ -142,7 +149,8 @@ var OpenTripPlanner = class OpenTripPlanner {
}
_getRouterUrl() {
- return this._baseUrl + '/routers/' + this._router;
+ return this._routerUrl ? this._routerUrl :
+ this._baseUrl + '/routers/' + this._router;
}
_getMode(routeType) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]