build: switch from yarn to npm to manage js dependencies and move js contents to root

yarn v1 is being deprecated and starts to have some issues

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2023-11-14 17:24:42 +01:00
parent 32055122c3
commit 2e72f6faf4
595 changed files with 12078 additions and 7843 deletions

22
src/utils/location.ts Normal file
View File

@@ -0,0 +1,22 @@
import ngeohash from "ngeohash";
const GEOHASH_DEPTH = 9; // put enough accuracy, radius will be used anyway
export const coordsToGeoHash = (
lat: number | undefined,
lon: number | undefined,
depth = GEOHASH_DEPTH
): string | undefined => {
if (lat && lon && depth) {
return ngeohash.encode(lat, lon, GEOHASH_DEPTH);
}
return undefined;
};
export const geoHashToCoords = (
geohash: string | undefined
): { latitude: number; longitude: number } | undefined => {
if (!geohash) return undefined;
const { latitude, longitude } = ngeohash.decode(geohash);
return latitude && longitude ? { latitude, longitude } : undefined;
};