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('');
|
|
|
|
}
|