wxbox/wxbox-web/src/lib/map/layer.ts
2025-01-01 22:09:59 -05:00

32 lines
864 B
TypeScript

import { env } from '$env/dynamic/public';
export interface MutexLayerSet<ValidOpts> {
map1: ValidOpts;
map2: ValidOpts;
map3: ValidOpts;
map4: ValidOpts;
}
export interface OverlayLayerSet<ValidOpts> {
map1: ValidOpts[];
map2: ValidOpts[];
map3: ValidOpts[];
map4: ValidOpts[];
}
export type BaseLayers = 'osm';
export type DataLayers = 'grib2/noaa_mrms_merged_composite_reflectivity_qc';
export function tilerLayerUrl(id: DataLayers): string {
if (!env.PUBLIC_TILER_URL_BASE) {
throw new Error('PUBLIC_TILER_URL_BASE env var not set!');
}
const base = new URL(env.PUBLIC_TILER_URL_BASE);
return (base + `${id}/{z}/{x}/{y}.png`).toString();
}
export function tilerLayerAttribution(id: DataLayers): string {
let base;
if (id === 'grib2/noaa_mrms_merged_composite_reflectivity_qc') {
base = '&copy; NOAA';
}
return base + ', &copy; wxbox';
}