diff --git a/assets/js/weather_map_hook.ts b/assets/js/weather_map_hook.ts index e8f46e97..ad238b08 100644 --- a/assets/js/weather_map_hook.ts +++ b/assets/js/weather_map_hook.ts @@ -475,7 +475,7 @@ function buildPaintScale(layerId: LayerId): PaintScale | BoolPaintScale | null { // SVG overlay — at low zoom (whole-CONUS, ~80k cells) SVG paint cost // dominated; canvas is one fillRect per cell with a precomputed LUT. const WeatherCanvasOverlayProto: L.LayerOptions & { - initialize: (this: WeatherCanvasOverlay, pack: CellPack | null, layerId: LayerId) => void + initialize: (this: WeatherCanvasOverlay, pack: CellPack | null, layerId: LayerId, halfStep: number) => void onAdd: (this: WeatherCanvasOverlay, map: L.Map) => WeatherCanvasOverlay onRemove: (this: WeatherCanvasOverlay, map: L.Map) => WeatherCanvasOverlay setPack: (this: WeatherCanvasOverlay, pack: CellPack | null) => void @@ -483,9 +483,10 @@ const WeatherCanvasOverlayProto: L.LayerOptions & { _reset: (this: WeatherCanvasOverlay) => void _draw: (this: WeatherCanvasOverlay) => void } = { - initialize(pack: CellPack | null, layerId: LayerId): void { + initialize(pack: CellPack | null, layerId: LayerId, halfStep: number): void { this.pack = pack this.layerId = layerId + this.halfStep = halfStep }, onAdd(map: L.Map): WeatherCanvasOverlay { this._map = map @@ -537,7 +538,7 @@ const WeatherCanvasOverlayProto: L.LayerOptions & { if (!paintScale) return const map = this._map - const halfStep = 0.0625 + const halfStep = this.halfStep const lats = this.pack.lats const lons = this.pack.lons const n = this.pack.cellCount @@ -578,6 +579,7 @@ const WeatherCanvasOverlayProto: L.LayerOptions & { interface WeatherCanvasOverlay extends L.Layer { pack: CellPack | null layerId: LayerId + halfStep: number _map: L.Map _canvas: HTMLCanvasElement setPack(pack: CellPack | null): void @@ -585,7 +587,7 @@ interface WeatherCanvasOverlay extends L.Layer { } // eslint-disable-next-line @typescript-eslint/no-explicit-any -const WeatherCanvasOverlayCtor: new (pack: CellPack | null, layerId: LayerId) => WeatherCanvasOverlay = (L.Layer as any).extend(WeatherCanvasOverlayProto) +const WeatherCanvasOverlayCtor: new (pack: CellPack | null, layerId: LayerId, halfStep: number) => WeatherCanvasOverlay = (L.Layer as any).extend(WeatherCanvasOverlayProto) function buildDetailHTML(point: WeatherPoint): string { if (!point) return "" @@ -1050,7 +1052,12 @@ export const WeatherMap: WeatherMapHook = { } if (!this.weatherOverlay) { - this.weatherOverlay = new WeatherCanvasOverlayCtor(this.pack, this.selectedLayer) + // HRRR is on a 0.125° native grid → 0.0625 half-step. + // HRDPS in this app is downsampled to 0.5° → 0.25 half-step. + // Without this, HRDPS cells were painted 1/16th their actual area + // and looked like a sparse pinstripe instead of an overlay. + const halfStep = this.source === "hrdps" ? 0.25 : 0.0625 + this.weatherOverlay = new WeatherCanvasOverlayCtor(this.pack, this.selectedLayer, halfStep) this.weatherOverlay.addTo(this.map) } else { this.weatherOverlay.pack = this.pack