Skip to content

Commit 8e56e5b

Browse files
committed
DBC22-5462: cleanups, bugfixes for location and route search
1 parent 23ce594 commit 8e56e5b

4 files changed

Lines changed: 12 additions & 6 deletions

File tree

.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ VITE_BASE_MAP=<base map wms url>
5151
VITE_MAP_STYLE=<map styling url>
5252
VITE_REPLAY_THE_DAY=<replay the day url>
5353
VITE_ROUTE_PLANNER=<route planner url>
54-
VITE_ROUTE_PLANNER_KEY=<route planner auth key>
54+
VITE_ROUTE_PLANNER_CLIENT_ID=<route planner auth key>
5555
VITE_GEOCODER_HOST=<geocoder url>
56-
VITE_GEOCODER_API_AUTH_KEY=<api auth key>
56+
VITE_GEOCODER_API_CLIENT_ID=<api auth key>
5757
VITE_ROUTABLE_LOCATIONS_HOST=<routable locations api url>
5858
VITE_RECAPTCHA_CLIENT_ID=<reCAPTCHA client ID>
5959
VITE_SURVEY_LINK=<exit survey link>

src/frontend/src/Components/data/locations.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export function getExtraLocations(addressInput) {
4747
}
4848

4949
export function getLocations(addressInput) {
50-
const geocoderPromise = get(`${GEOCODER_HOST}/addresseson`, {
50+
const geocoderPromise = get(`${GEOCODER_HOST}/addresses.json`, {
5151
minScore: 50,
5252
maxResults: 7,
5353
echo: "false",

src/frontend/src/Components/data/routes.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,22 @@ const compareCoordinates = (coord1, coord2) => {
197197
}
198198

199199
export const shortenToOneDecimal = (num) => {
200-
const str = num.toFixed(2); // Convert to string with two decimals
200+
if (num == null || Number.isNaN(Number(num))) {
201+
return null;
202+
}
203+
const str = Number(num).toFixed(2); // Convert to string with two decimals
201204
return str.slice(0, str.indexOf('.') + 2); // Keep only one decimal place
202205
}
203206

204207
export const compareRoutes = (route1, route2) => {
205208
if (!route1 && !route2) return true; // Return true if both routes are null
206209
if (!route1 || !route2) return false; // Return false if only one route is null
207210

208-
return shortenToOneDecimal(route1.distance) === shortenToOneDecimal(route2.distance)
211+
const distance1 = shortenToOneDecimal(route1.distance);
212+
const distance2 = shortenToOneDecimal(route2.distance);
213+
if (distance1 == null || distance2 == null) return false;
214+
215+
return distance1 === distance2;
209216
}
210217

211218
export const linkRoute = (route, favRoutes) => {

src/frontend/src/pages/MapPage.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616

1717
// Internal imports
1818
// import { HeaderHeightContext } from '../App';
19-
import EmergencyAlert from "../Components/shared/EmergencyAlert";
2019

2120
// External Imports
2221
import { DndProvider } from 'react-dnd-multi-backend';

0 commit comments

Comments
 (0)