mirror of
https://gitlab.com/mobicoop/v3/service/matcher.git
synced 2026-01-01 08:12:40 +00:00
simpler route provider in ad module
This commit is contained in:
@@ -27,7 +27,7 @@ export type Route = {
|
||||
backAzimuth: number;
|
||||
distanceAzimuth: number;
|
||||
points: Point[];
|
||||
steps: Step[];
|
||||
steps?: Step[];
|
||||
};
|
||||
|
||||
export type Point = {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { Point, Step } from '@modules/geography/core/domain/route.types';
|
||||
|
||||
export class RouteResponseDto {
|
||||
distance?: number;
|
||||
duration?: number;
|
||||
distance: number;
|
||||
duration: number;
|
||||
fwdAzimuth: number;
|
||||
backAzimuth: number;
|
||||
distanceAzimuth: number;
|
||||
points: Step[] | Point[];
|
||||
points: Point[];
|
||||
steps?: Step[];
|
||||
}
|
||||
|
||||
@@ -16,12 +16,8 @@ export class RouteMapper
|
||||
{
|
||||
toResponse = (entity: RouteEntity): RouteResponseDto => {
|
||||
const response = new RouteResponseDto();
|
||||
response.distance = entity.getProps().distance
|
||||
? Math.round(entity.getProps().distance as number)
|
||||
: undefined;
|
||||
response.duration = entity.getProps().duration
|
||||
? Math.round(entity.getProps().duration as number)
|
||||
: undefined;
|
||||
response.distance = Math.round(entity.getProps().distance);
|
||||
response.duration = Math.round(entity.getProps().duration);
|
||||
response.fwdAzimuth = Math.round(entity.getProps().fwdAzimuth);
|
||||
response.backAzimuth = Math.round(entity.getProps().backAzimuth);
|
||||
response.distanceAzimuth = Math.round(entity.getProps().distanceAzimuth);
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
GeorouterUnavailableException,
|
||||
RouteNotFoundException,
|
||||
} from '@modules/geography/core/domain/route.errors';
|
||||
import { Route } from '@modules/geography/core/domain/route.types';
|
||||
import { Route, Step } from '@modules/geography/core/domain/route.types';
|
||||
import {
|
||||
GEODESIC,
|
||||
PARAMS_PROVIDER,
|
||||
@@ -411,8 +411,8 @@ describe('Graphhopper Georouter', () => {
|
||||
},
|
||||
);
|
||||
expect(route.steps).toHaveLength(2);
|
||||
expect(route.steps[1].duration).toBe(1800);
|
||||
expect(route.steps[1].distance).toBeUndefined();
|
||||
expect((route.steps as Step[])[1].duration).toBe(1800);
|
||||
expect((route.steps as Step[])[1].distance).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should create one route with points and missed waypoints extrapolations', async () => {
|
||||
@@ -468,8 +468,8 @@ describe('Graphhopper Georouter', () => {
|
||||
points: true,
|
||||
},
|
||||
);
|
||||
expect(route.steps.length).toBe(3);
|
||||
expect(route.steps[1].duration).toBe(990);
|
||||
expect(route.steps[1].distance).toBe(25000);
|
||||
expect(route.steps).toHaveLength(3);
|
||||
expect((route.steps as Step[])[1].duration).toBe(990);
|
||||
expect((route.steps as Step[])[1].distance).toBe(25000);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user