feat: add StopsMap and WalkingDirections components for enhanced map functionality
- Implemented StopsMap component to display bus stops on a map using MapLibre GL. - Integrated walking directions feature in WalkingDirections component to calculate routes from user location to selected bus stop. - Added geo utility functions for coordinate validation and distance calculation. - Created route grouping and stop filtering logic in routeGroups module. - Developed custom hooks for managing stop routes with React Query. - Added tests for routing and stop functionalities to ensure reliability.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { ApiError } from './errors.mjs';
|
||||
import { coordinates } from './coordinates.mjs';
|
||||
|
||||
const routeNumber = value => typeof value === 'string' ? value.replace(/[\s№]/g, '').toLocaleUpperCase('ru') : '';
|
||||
const positive = value => Number.isSafeInteger(Number(value)) && Number(value) > 0;
|
||||
@@ -32,6 +33,6 @@ export function normalizeNearby(raw) {
|
||||
const distance = Number(stop?.distance_meters);
|
||||
if (!stop || !positive(stop.id) || typeof stop.name !== 'string' || !stop.name.trim() || stop.distance_meters == null || !Number.isFinite(distance) || distance < 0) throw new ApiError(502);
|
||||
return { id: Number(stop.id), name: stop.name.trim(), direction: typeof stop.description === 'string' ? stop.description.trim() : '',
|
||||
routesCount: Number(stop.routes_count) || 0, distance: Math.round(distance) };
|
||||
routesCount: Number(stop.routes_count) || 0, distance: Math.round(distance), ...coordinates(stop.latitude, stop.longitude) };
|
||||
}).sort((a, b) => a.distance - b.distance);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user