1
0
forked from Cutlery/immich
Russell Tan f1b8a7ab54
fix(server): Does not assign lat/lon if they are at 0,0 #2991 (#3669)
* fix(server): Does not assign lat/lon if they are at 0,0 #2991

* Adds migration file to fix null island rows

* Removed down migration

* Leave empty down function
2023-08-14 20:37:17 -05:00

27 lines
637 B
TypeScript

import { isNumberInRange } from '../numbers';
export function parseLatitude(input: string | number | null): number | null {
if (input === null) {
return null;
}
const latitude = typeof input === 'string' ? Number.parseFloat(input) : input;
if (isNumberInRange(latitude, -90, 90)) {
return latitude;
}
return null;
}
export function parseLongitude(input: string | number | null): number | null {
if (input === null) {
return null;
}
const longitude = typeof input === 'string' ? Number.parseFloat(input) : input;
if (isNumberInRange(longitude, -180, 180)) {
return longitude;
}
return null;
}