Files
TREK/client/src/repo/windRepo.ts
T
Maurice 2c3b20bb57 feat(tours): paddle portages and locks, paddle time, wind at the start and obstacle data from OpenStreetMap
PAD-03 portages and locks on planned tours and recorded tracks, PAD-07 paddle time with portage and lock stops, PAD-08 wind forecast for the start, PAD-05A regional obstacle import from Geofabrik extracts with admin endpoints and a monthly refresh, PAD-05B first cut of the obstacle layer on Leaflet, GL and 3D. Work in progress: checklist (PAD-06), check bench (PAD-09), admin UI, translations and tests follow.
2026-10-16 23:44:58 +02:00

24 lines
909 B
TypeScript

import type { WindForecastResponse } from '@trek/shared';
import { windApi } from '../api/wind';
import { isEffectivelyOffline } from '../sync/networkMode';
/** Thrown instead of asking while the app is offline, so the view can say so rather than show a failure. */
export class WindOfflineError extends Error {
constructor() {
super('Wind forecast needs a connection');
this.name = 'WindOfflineError';
}
}
/**
* PAD-08: the wind forecast, online only on purpose. A forecast kept on the
* device would be read later as the current one; it is asked again every time
* and never cached here, and offline nothing is asked at all.
*/
export const windRepo = {
async forecast(lat: number, lng: number, date: string, signal?: AbortSignal): Promise<WindForecastResponse> {
if (isEffectivelyOffline()) throw new WindOfflineError();
return windApi.forecast(lat, lng, date, signal);
},
};