Skip to content

Commit

Permalink
Merge pull request #9 from inelo/feature/departure-time-original-resp…
Browse files Browse the repository at this point in the history
…onse-object

Feature/departure time original response object
  • Loading branch information
Daredzik authored Oct 17, 2022
2 parents 0f56cd0 + 124bd18 commit 2a5a4b1
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ Note that you will need to pass a valid Here apiKey to the constructor.
| avoidTolls | boolean | false | |
| avoidFerries | boolean | false | |
| avoidDirtRoad | boolean | false | |
| trafficMode | boolean | false | |
| departureTime | string | any | [Available options](https://developer.here.com/documentation/routing-api/api-reference-swagger.html) |
| transportMode | string | car | [Available options](https://developer.here.com/documentation/routing-api/api-reference-swagger.html) |
| routingMode | string | fast | [Available options](https://developer.here.com/documentation/routing-api/api-reference-swagger.html) |

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "leaflet-routing-machine-here",
"version": "2.0.0",
"version": "2.1.0",
"description": "Support for here in Leaflet Routing Machine, including route restrictions",
"main": "dist/lrm-here.js",
"scripts": {
17 changes: 10 additions & 7 deletions src/L.Routing.Here.js
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
serviceUrl: 'https://router.hereapi.com/v8/routes',
timeout: 30 * 1000,
noticesTypeAsRouteError: ['critical'],
alternatives: 0,
urlParameters: {},
routeRestriction: {
transportMode: 'car',
@@ -81,14 +82,14 @@
const routeCriticalNotices = [];

response.routes.forEach((route) =>
route.sections.forEach((section) =>
(section.notices || []).forEach((notice) => {
if (this.options.noticesTypeAsRouteError.includes(notice.severity)) {
route.sections.forEach((section) =>
(section.notices || []).forEach((notice) => {
if (this.options.noticesTypeAsRouteError.includes(notice.severity)) {
routeCriticalNotices.push(notice);
}
})
)
);
)
);

if (routeCriticalNotices.length > 0) {
callback.call(context, {
@@ -113,7 +114,8 @@
totalTime: 0,
},
inputWaypoints,
waypoints: []
waypoints: [],
originalRouteObject: route,
};

return route.sections.reduce((acc, section, index) => {
@@ -154,10 +156,11 @@
apiKey: this._apiKey,
transportMode: mode,
routingMode: this.options.routeRestriction.routeMode || 'fast',
departureTime: this.options.routeRestriction.trafficMode === false ? 'any' : null,
departureTime: this.options.routeRestriction.hasOwnProperty('departureTime') ? this.options.routeRestriction.departureTime : 'any',
avoid: {
features: this._buildAvoidFeatures(this.options)
},
alternatives: this.options.alternatives,
vehicle: vehicleRestrictions
}, this.options.urlParameters);

0 comments on commit 2a5a4b1

Please sign in to comment.