@digitransit-store/digitransit-store-future-route
extractRoute
Parameters
routeIn
Examples
const oldRouteCollection = {
[
{
type: 'FutureRoute',
properties: {
layer: 'futureRoute',
origin: {
name: 'Pasila',
locality: 'Helsinki',
coordinates: {
lat: 60.198828,
lon: 24.933514,
},
},
destination: {
name: 'Ilmala',
locality: 'Helsinki',
coordinates: {
lat: 60.208466,
lon: 24.919756,
},
},
arriveBy: 'true',
time: 1600866900,
url: '/reitti/Pasila%2C%20Helsinki%3A%3A60.198828%2C24.933514/Ilmala%2C%20Helsinki%3A%3A60.208466%2C24.919756?arriveBy=true&time=1600866900',
},
},
{
type: 'FutureRoute',
properties: {
layer: 'futureRoute',
origin: {
name: 'Ilmala',
locality: 'Helsinki',
coordinates: {
lat: 60.208466,
lon: 24.919756,
},
},
destination: {
name: 'Pasila',
locality: 'Helsinki',
coordinates: {
lat: 60.198828,
lon: 24.933514,
},
},
time: 1600877700,
url: '/reitti/Ilmala%2C%20Helsinki%3A%3A60.208466%2C24.919756/Pasila%2C%20Helsinki%3A%3A60.198828%2C24.933514?arriveBy=true&time=1600877700',
},
},
],
}
const newRoute = {
origin: {
address: 'Pasila, Helsinki',
coordinates: { lat: 60.198828, lon: 24.933514 },
},
destination: {
address: 'Myyrmäki, Vantaa',
coordinates: { lat: 60.261238, lon: 24.854782 },
},
arriveBy: false,
time: 1600888888,
};
//add newRoute to oldRouteCollection
const newRouteCollection = addFutureRoute(newRoute, oldRouteCollection, { prefixItinerarySummary: 'reitti' });
const url = createUrl(newRoute, { prefixItinerarySummary: 'reitti' });
//'/reitti/Pasila%2C%20Helsinki%3A%3A60.198828%2C24.933514/Myyrmäki%2C%20Vantaa%3A%3A60.261238%2C24.854782?time=1600888888'
This module is part of the Digitransit-ui project. It is maintained in the HSLdevcom/digitransit-ui repository, where you can create PRs and issues.
Installation
Install this module individually:
$ npm install @digitransit-store/digitransit-store-future-route
Or install the Digitransit-store module that includes it as a function:
$ npm install @digitransit-store/digitransit-store