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

12 lines
406 B
TypeScript
Raw Normal View History

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