graphhopper georouter tests
This commit is contained in:
parent
0dec130396
commit
ed99b442eb
|
@ -82,9 +82,7 @@ export class GraphhopperGeorouter implements IGeorouter {
|
||||||
].join('');
|
].join('');
|
||||||
const route = await lastValueFrom(
|
const route = await lastValueFrom(
|
||||||
this._httpService.get(url).pipe(
|
this._httpService.get(url).pipe(
|
||||||
map((res) =>
|
map((res) => (res.data ? this._createRoute(res) : undefined)),
|
||||||
res.data ? this._createRoute(path.key, res) : undefined,
|
|
||||||
),
|
|
||||||
catchError((error: AxiosError) => {
|
catchError((error: AxiosError) => {
|
||||||
throw new Error('Georouter unavailable : ' + error.message);
|
throw new Error('Georouter unavailable : ' + error.message);
|
||||||
}),
|
}),
|
||||||
|
@ -103,10 +101,7 @@ export class GraphhopperGeorouter implements IGeorouter {
|
||||||
return [this._url, this._urlArgs.join('&')].join('');
|
return [this._url, this._urlArgs.join('&')].join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
_createRoute(
|
_createRoute(response: AxiosResponse<GraphhopperResponse>): Route {
|
||||||
key: string,
|
|
||||||
response: AxiosResponse<GraphhopperResponse>,
|
|
||||||
): Route {
|
|
||||||
const route = new Route(this._geodesic);
|
const route = new Route(this._geodesic);
|
||||||
if (response.data.paths && response.data.paths[0]) {
|
if (response.data.paths && response.data.paths[0]) {
|
||||||
const shortestPath = response.data.paths[0];
|
const shortestPath = response.data.paths[0];
|
||||||
|
|
|
@ -447,7 +447,6 @@ describe('Graphhopper Georouter', () => {
|
||||||
withTime: true,
|
withTime: true,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
console.log(routes[0].route.spacetimePoints);
|
|
||||||
expect(routes).toHaveLength(1);
|
expect(routes).toHaveLength(1);
|
||||||
expect(routes[0].route.spacetimePoints.length).toBe(3);
|
expect(routes[0].route.spacetimePoints.length).toBe(3);
|
||||||
expect(routes[0].route.spacetimePoints[1].duration).toBe(990);
|
expect(routes[0].route.spacetimePoints[1].duration).toBe(990);
|
||||||
|
|
Loading…
Reference in New Issue