nearby
This commit is contained in:
@@ -13,7 +13,14 @@ export const geoLocationNameToRoute = (name: string) => {
|
||||
// selections navigate here directly, no geocoding id involved
|
||||
const COORD_ROUTE = /^(-?\d+(?:\.\d+)?)N(-?\d+(?:\.\d+)?)E$/i;
|
||||
|
||||
export function buildLocationRoute(location: GeoLocation): string {
|
||||
/** Only the fields the route is built from, so callers holding a partial record
|
||||
* (the nearby-cities list, for one) don't have to fake a whole GeoLocation. */
|
||||
export type RoutableLocation = Pick<
|
||||
GeoLocation,
|
||||
'id' | 'name' | 'latitude' | 'longitude' | 'feature_code' | 'population'
|
||||
>;
|
||||
|
||||
export function buildLocationRoute(location: RoutableLocation): string {
|
||||
// coordinate-only locations (GPS) have no real geocoding id
|
||||
if (location.feature_code === 'COORD' || !location.id) {
|
||||
return `${location.latitude.toFixed(4)}N${location.longitude.toFixed(4)}E`;
|
||||
|
||||
Reference in New Issue
Block a user