12 lines
406 B
TypeScript
12 lines
406 B
TypeScript
|
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('');
|
||
|
}
|