Skip to content
Snippets Groups Projects
Commit 4403b7a9 authored by Mathias Nocet's avatar Mathias Nocet
Browse files

Correcting bug "findRoutesInArea"

parent 455a9558
No related branches found
No related tags found
1 merge request!4Bug, Preferred exercise, CI-CD
Pipeline #24524 passed
......@@ -38,11 +38,13 @@ export class RouteController {
description: 'Bounding coordinates for fetching steps',
})
async fetchRoutesInArea(@Body() boundsDto: GeographicBoundsDto) {
const { latMin, latMax, longMin, longMax } = boundsDto;
return await this.routeRepository.findRoutesInArea(
boundsDto.latMin,
boundsDto.latMax,
boundsDto.longMin,
boundsDto.longMax,
latMin,
latMax,
longMin,
longMax,
);
}
......
......@@ -30,15 +30,20 @@ export class RouteRepository extends BaseRepository<Route> {
return await this.route
.createQueryBuilder('route')
.where(
`route.Path LIKE :latMin
OR route.Path LIKE :latMax
OR route.Path LIKE :longMin
OR route.Path LIKE :longMax`,
`EXISTS (
SELECT 1
FROM json_each(json_extract(route.path, '$')) as point
WHERE (
CAST(json_extract(point.value, '$[0]') AS FLOAT) BETWEEN :longMin AND :longMax
AND
CAST(json_extract(point.value, '$[1]') AS FLOAT) BETWEEN :latMin AND :latMax
)
)`,
{
latMin: `%${latMin}%`,
latMax: `%${latMax}%`,
longMin: `%${longMin}%`,
longMax: `%${longMax}%`,
latMin,
latMax,
longMin,
longMax,
},
)
.leftJoinAndSelect('route.steps', 'routeStep')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment