Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@
"@vitest/coverage-v8": "^4.0.17",
"bits-ui": "^2.15.2",
"clsx": "^2.1.1",
"crepuscule": "file:../../forks/crepuscule",
Comment thread
vincentvdwal marked this conversation as resolved.
"eslint": "^9.39.0",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-svelte": "^3.13.0",
"globals": "^17.0.0",
"mapbox-gl-shadow-simulator": "^0.67.0",
"maplibre-gl": "^5.15.0",
"mdsvex": "^0.12.3",
"mode-watcher": "^1.1.0",
Expand All @@ -71,4 +73,4 @@
"vitest": "^4.0.4",
"vitest-browser-svelte": "^2.0.1"
}
}
}
2 changes: 2 additions & 0 deletions src/lib/components/time/time-selector.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
modelRun,
modelRunLocked,
preferences,
shadeMap,
time
} from '$lib/stores/preferences';
import { inProgress, latest, metaJson } from '$lib/stores/preferences';
Expand Down Expand Up @@ -289,6 +290,7 @@
}

$time = new SvelteDate(date);
$shadeMap?.setDate($time);
currentDate = date;
updateUrl('time', formatISOWithoutTimezone($time));
await checkClosestModelRun();
Expand Down
45 changes: 23 additions & 22 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@ export const DEFAULT_VARIABLE = 'temperature_2m';

// Vector options defaults
export const DEFAULT_VECTOR_OPTIONS = {
grid: false,
arrows: true,
contours: false,
breakpoints: true,
contourInterval: 2
grid: false,
arrows: true,
contours: false,
breakpoints: true,
contourInterval: 2
};

// Preferences defaults
export const DEFAULT_PREFERENCES = {
globe: false,
terrain: false,
hillshade: false,
clipWater: false,
showScale: true,
timeSelector: true
globe: false,
terrain: false,
hillshade: false,
clipWater: false,
showScale: true,
crepuscule: false,
Comment thread
vincentvdwal marked this conversation as resolved.
Outdated
timeSelector: true
};

// Color hash default
Expand All @@ -36,10 +37,10 @@ export const DEFAULT_OPACITY = 75;

// Complete default values for URL parameter checking
export const COMPLETE_DEFAULT_VALUES: { [key: string]: boolean | string | number } = {
domain: DEFAULT_DOMAIN,
variable: DEFAULT_VARIABLE,
...DEFAULT_PREFERENCES,
...DEFAULT_VECTOR_OPTIONS
domain: DEFAULT_DOMAIN,
variable: DEFAULT_VARIABLE,
...DEFAULT_PREFERENCES,
...DEFAULT_VECTOR_OPTIONS
Comment thread
vincentvdwal marked this conversation as resolved.
Outdated
};

// Time constants
Expand All @@ -54,11 +55,11 @@ export const METADATA_REFRESH_INTERVAL = 5 * MILLISECONDS_PER_MINUTE; // 5 minut

// Calendar display constants
export const DAY_NAMES = [
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday'
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday'
];
5 changes: 5 additions & 0 deletions src/lib/stores/preferences.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { MediaQuery } from 'svelte/reactivity';
import { type Writable, writable } from 'svelte/store';

import type ShadeMap from 'mapbox-gl-shadow-simulator';


Comment thread
vincentvdwal marked this conversation as resolved.
Outdated
import { setMode } from 'mode-watcher';
import { type Persisted, persisted } from 'svelte-persisted-store';

Expand Down Expand Up @@ -61,6 +64,8 @@ export const helpOpen = writable(false);
export const metaJson: Writable<DomainMetaDataJson | undefined> = writable(undefined);
export const modelRunLocked = writable(false);

export const shadeMap = writable<ShadeMap | null>(null);
Comment thread
vincentvdwal marked this conversation as resolved.

export const resetStates = async () => {
modelRunLocked.set(false);

Expand Down
24 changes: 24 additions & 0 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
omProtocol,
updateCurrentBounds
} from '@openmeteo/mapbox-layer';
import ShadeMap from 'mapbox-gl-shadow-simulator';
import { type RequestParameters } from 'maplibre-gl';
import * as maplibregl from 'maplibre-gl';
import 'maplibre-gl/dist/maplibre-gl.css';
Expand All @@ -28,6 +29,7 @@
resetStates,
resolution,
resolutionSet,
shadeMap,
time,
url
} from '$lib/stores/preferences';
Expand Down Expand Up @@ -142,9 +144,31 @@
if (getInitialMetaDataPromise) await getInitialMetaDataPromise;

addOmFileLayers();

addHillshadeSources();
$map.addControl(new HillshadeButton());

$shadeMap = new ShadeMap({
date: $time, // display shadows for current date
color: '#01112f', // shade color
opacity: 0.7, // opacity of shade color
apiKey: '', // obtain from https://shademap.app/about/,
Comment thread
vincentvdwal marked this conversation as resolved.
terrainSource: {
tileSize: 256,
maxZoom: 15,

getSourceUrl: ({ x, y, z }) => {
return `https://tiles.mapterhorn.com/${z}/${x}/${y}.webp`;
},
getElevation: ({ r, g, b, a }) => {
return r * 256 + g + b / 256 - 32768;
}
},
debug: (msg) => {
console.log(new Date().toISOString(), msg);
}
}).addTo($map);
Comment thread
vincentvdwal marked this conversation as resolved.

addPopup();
changeOMfileURL();
});
Expand Down
Loading