matcher/old/modules/geography/adapters/secondaries/postgres-direction-encoder.ts

12 lines
403 B
TypeScript
Raw Normal View History

2023-05-22 09:25:09 +00:00
import { Coordinate } from '../../domain/entities/coordinate';
2023-05-12 14:23:42 +00:00
import { IEncodeDirection } from '../../domain/interfaces/direction-encoder.interface';
export class PostgresDirectionEncoder implements IEncodeDirection {
2023-05-22 09:25:09 +00:00
encode = (coordinates: Coordinate[]): string =>
2023-05-12 14:23:42 +00:00
[
"'LINESTRING(",
coordinates.map((point) => [point.lon, point.lat].join(' ')).join(),
")'",
].join('');
}