@@ -312,7 +308,7 @@
name="Show legend"
bind:checked={showLegend}
onCheckedChange={() => {
- $params.hourly = $params.hourly;
+ params.hourly = params.hourly;
}}
/>
@@ -323,7 +319,7 @@
name="Average only"
bind:checked={averageOnly}
onCheckedChange={() => {
- $params.hourly = $params.hourly;
+ params.hourly = params.hourly;
}}
/>
Models
- {#if $params.models && $params.models.length > 0}
+ {#if params.models && params.models.length > 0}
- {$params.models?.length} / {models.flat().length}
+ {params.models?.length || 0} / {models.length}
{/if}
- {#each models as group, i (i)}
-
- {#each group as { value, label } (value)}
-
- {
- if ($params.models?.includes(value)) {
- $params.models = $params.models.filter((item: string) => {
- return item !== value;
- });
- } else if ($params.models) {
- $params.models.push(value);
- $params.models = $params.models;
- }
- }}
- />
-
-
- {/each}
-
- {/each}
+
+ {#each models as { value, label } (value)}
+
+ {
+ if (params.models?.includes(value)) {
+ params.models = params.models.filter((item) => {
+ return item !== value;
+ });
+ } else if (params.models) {
+ params.models.push(value);
+ params.models = params.models;
+ }
+ }}
+ />
+
+
+ {/each}
+
@@ -386,12 +380,12 @@
Hourly Weather Variables
- {#if $params.hourly && $params.hourly.length > 0}
+ {#if params.hourly && params.hourly.length > 0}
- {$params.hourly?.length} / {hourly.flat().length}
+ {params.hourly?.length || 0} / {hourly.flat().length}
{/if}
@@ -408,16 +402,16 @@
id="{value}_hourly"
class="border-border-dark cursor-pointer bg-muted/50 duration-100 group-hover:border-[currentColor]"
{value}
- checked={$params.hourly?.includes(value)}
+ checked={params.hourly?.includes(value)}
aria-labelledby="{value}_label"
onCheckedChange={() => {
- if ($params.hourly?.includes(value)) {
- $params.hourly = $params.hourly.filter((item: string) => {
+ if (params.hourly?.includes(value)) {
+ params.hourly = params.hourly.filter((item) => {
return item !== value;
});
- } else if ($params.hourly) {
- $params.hourly.push(value);
- $params.hourly = $params.hourly;
+ } else if (params.hourly) {
+ params.hourly.push(value);
+ params.hourly = params.hourly;
}
}}
/>
diff --git a/src/routes/weather/compare/options.ts b/src/routes/weather/compare/options.ts
index a0a4378..463bab5 100644
--- a/src/routes/weather/compare/options.ts
+++ b/src/routes/weather/compare/options.ts
@@ -1,31 +1,5 @@
+// Default configuration for weather comparison charts
export const defaultParameters = {
- daily: [],
- hourly: [],
- models: [],
- current: [],
- minutely_15: [],
-
- timezone: 'UTC',
- location_mode: 'location_search',
- csv_coordinates: undefined,
-
- time_mode: 'forecast_days',
- past_days: '0',
- forecast_days: '7',
-
- end_date: undefined,
- start_date: undefined,
-
- past_hours: undefined,
- cell_selection: undefined,
- forecast_hours: undefined,
- past_minutely_15: undefined,
- temporal_resolution: undefined,
- forecast_minutely_15: undefined,
-
- tilt: '0',
- azimuth: '0',
-
timeformat: 'iso8601',
wind_speed_unit: 'kmh',
temperature_unit: 'celsius',
diff --git a/src/routes/weather/options.ts b/src/routes/weather/options.ts
index 7c2c742..a58f330 100644
--- a/src/routes/weather/options.ts
+++ b/src/routes/weather/options.ts
@@ -6,20 +6,18 @@ export const defaultParameters = {
};
export const models = [
- [{ value: 'best_match', label: 'Best match' }],
- [
- { value: 'gfs_seamless', label: 'NCEP GFS Seamless' },
- { value: 'jma_seamless', label: 'JMA Seamless' },
- { value: 'kma_seamless', label: 'KMA Seamless' },
- { value: 'icon_seamless', label: 'DWD ICON Seamless' },
- { value: 'gem_seamless', label: 'GEM Seamless' },
- { value: 'meteofrance_seamless', label: 'Météo-France Seamless' },
- { value: 'arpae_cosmo_seamless', label: 'ARPAE Seamless' },
- { value: 'metno_seamless', label: 'MET Norway Seamless (with ECMWF)' },
- { value: 'knmi_seamless', label: 'KNMI Seamless (with ECMWF)' },
- { value: 'dmi_seamless', label: 'DMI Seamless (with ECMWF)' },
- { value: 'ukmo_seamless', label: 'UK Met Office Seamless' }
- ]
+ { value: 'best_match', label: 'Best match' },
+ { value: 'gfs_seamless', label: 'NCEP GFS Seamless' },
+ { value: 'jma_seamless', label: 'JMA Seamless' },
+ { value: 'kma_seamless', label: 'KMA Seamless' },
+ { value: 'icon_seamless', label: 'DWD ICON Seamless' },
+ { value: 'gem_seamless', label: 'GEM Seamless' },
+ { value: 'meteofrance_seamless', label: 'Météo-France Seamless' },
+ { value: 'arpae_cosmo_seamless', label: 'ARPAE Seamless' },
+ { value: 'metno_seamless', label: 'MET Norway Seamless (with ECMWF)' },
+ { value: 'knmi_seamless', label: 'KNMI Seamless (with ECMWF)' },
+ { value: 'dmi_seamless', label: 'DMI Seamless (with ECMWF)' },
+ { value: 'ukmo_seamless', label: 'UK Met Office Seamless' }
];
export const hourly = [
diff --git a/src/routes/weather/utils/weather-codes.ts b/src/routes/weather/utils/weather-codes.ts
index c562ce1..9e7b191 100644
--- a/src/routes/weather/utils/weather-codes.ts
+++ b/src/routes/weather/utils/weather-codes.ts
@@ -1,4 +1,4 @@
-const map: Record
= {
+const weatherCodes: Record = {
0: 'clear',
1: 'clear',
2: 'cloudy',
@@ -79,4 +79,5 @@ const map: Record = {
96: 'thunderstorm',
99: 'tornado'
};
-export default map;
+
+export default weatherCodes;
diff --git a/src/routes/weather/week/+page.ts b/src/routes/weather/week/+page.ts
index e2a912f..b2c878b 100644
--- a/src/routes/weather/week/+page.ts
+++ b/src/routes/weather/week/+page.ts
@@ -6,7 +6,7 @@ import { storedLocation } from '$lib/stores/settings';
import { geoLocationNameToRoute } from '$lib/utils/meteo';
-import type { PageLoad } from '$types';
+import type { PageLoad } from './$types';
export const prerender = true;
diff --git a/src/routes/weather/week/[location]/+page.svelte b/src/routes/weather/week/[location]/+page.svelte
index 7ccefe4..7d20f68 100644
--- a/src/routes/weather/week/[location]/+page.svelte
+++ b/src/routes/weather/week/[location]/+page.svelte
@@ -1,12 +1,11 @@
@@ -363,10 +313,12 @@
style="min-height: 256px"
class="weather-week gap-md-2 mb-4 flex flex-col md:flex-row"
>
- {#if weatherDaily}
- {#each weatherDaily.time as time, index (index)}
+ {#await weatherDaily then wd}
+ {#each wd.daily.time as time, index (index)}
{@const selected = time.getDate() === selectedDay.getDate()}
- {#if !isNaN(weatherDaily.temperature_2m_max.values(index)!)}
+ {#if wd.daily.temperature_2m_max.values(index) != null && !isNaN(Number(wd.daily.temperature_2m_max
+ .values(index)!
+ .toFixed(1)))}
= ($params.temperature_unit === 'celsius' ? 30 : 104) ? 'white' : 'black'}`}
+ class="weather-temp-max flex min-w-[65px] justify-center rounded-t p-1 text-sm"
+ style={`background-color: ${getColor(Math.round(wd.daily.temperature_2m_max.values(index) ?? 0), params.temperature_unit)}; color: ${(wd.daily.temperature_2m_min.values(index) ?? 0) < (params.temperature_unit === 'celsius' ? 4 : 7) || (wd.daily.temperature_2m_min.values(index) ?? 0) >= (params.temperature_unit === 'celsius' ? 30 : 104) ? 'white' : 'black'}`}
>
- {weatherDaily.temperature_2m_max.values(index)!.toFixed(1)}
- {$params.temperature_unit === 'celsius' ? '°C' : '°F'}
+ {wd.daily.temperature_2m_max.values(index)?.toFixed(1)}
+ {params.temperature_unit === 'celsius' ? '°C' : '°F'}
= ($params.temperature_unit === 'celsius' ? 30 : 104) ? 'white' : 'black'}`}
+ class="weather-temp-min flex min-w-[65px] justify-center rounded-b p-1 text-sm"
+ style={`background: ${getColor(Math.round(wd.daily.temperature_2m_min.values(index) ?? 0), params.temperature_unit)}; color: ${(wd.daily.temperature_2m_min.values(index) ?? 0) < (params.temperature_unit === 'celsius' ? 4 : 7) || (wd.daily.temperature_2m_min.values(index) ?? 0) >= (params.temperature_unit === 'celsius' ? 30 : 104) ? 'white' : 'black'}`}
>
- {weatherDaily.temperature_2m_min.values(index)!.toFixed(1)}
- {$params.temperature_unit === 'celsius' ? '°C' : '°F'}
+ {wd.daily.temperature_2m_min.values(index)?.toFixed(1)}
+ {params.temperature_unit === 'celsius' ? '°C' : '°F'}
- {Number(weatherDaily.sunshine_duration.values(index)! / 3600).toFixed(0)}h
+ {Number((wd.daily.sunshine_duration.values(index) ?? 0) / 3600).toFixed(0)}h