Skip to content

Commit a877b11

Browse files
author
Vincent van der Wal
committed
add jma and ukmo2km with LambertEQArea
1 parent 36d6f5f commit a877b11

File tree

4 files changed

+130
-17
lines changed

4 files changed

+130
-17
lines changed

public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
5-
<link rel="icon" href="./public/favicon.ico" />
5+
<link rel="icon" href="favicon.ico" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>OMaps</title>
88
<style>

public/index_pages.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
5-
<link rel="icon" href="./public/favicon.ico" />
5+
<link rel="icon" href="favicon.ico" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>OMaps</title>
88
<script src="https://unpkg.com/maplibre-gl@^5.6.0/dist/maplibre-gl.js"></script>

src/utils/domains.ts

Lines changed: 65 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const domainGroups = [
55
'ncep',
66
'ecmwf',
77
'italia_meteo',
8+
'jma',
89
'meteofrance',
910
'ukmo',
1011
//'kma',
@@ -254,6 +255,49 @@ export const domains: Array<Domain> = [
254255
}
255256
}
256257
},
258+
259+
// JMA
260+
{
261+
value: 'jma_gsm',
262+
label: 'JMA GSM',
263+
grid: {
264+
nx: 720,
265+
ny: 361,
266+
latMin: -90,
267+
lonMin: -180,
268+
dx: 0.5,
269+
dy: 0.5,
270+
zoom: 1,
271+
center: function () {
272+
this.center = {
273+
lng: this.lonMin + this.dx * (this.nx * 0.5),
274+
lat: this.latMin + this.dy * (this.ny * 0.5)
275+
};
276+
return this;
277+
}
278+
}
279+
},
280+
{
281+
value: 'jma_msm',
282+
label: 'JMA MSM',
283+
grid: {
284+
nx: 481,
285+
ny: 505,
286+
latMin: 22.4,
287+
lonMin: 120,
288+
dx: 0.0625,
289+
dy: 0.05,
290+
zoom: 1,
291+
center: function () {
292+
this.center = {
293+
lng: this.lonMin + this.dx * (this.nx * 0.5),
294+
lat: this.latMin + this.dy * (this.ny * 0.5)
295+
};
296+
return this;
297+
}
298+
}
299+
},
300+
257301
// MeteoFrance
258302
{
259303
value: 'meteofrance_arpege_world025',
@@ -359,20 +403,27 @@ export const domains: Array<Domain> = [
359403
}
360404
},
361405
// Needs reprojection
362-
// {
363-
// value: 'ukmo_uk_deterministic_2km',
364-
// label: 'UK Met Office 2km',
365-
// grid: {
366-
// nx: 1042,
367-
// ny: 970,
368-
// latMin: -1036000,
369-
// lonMin: -1158000,
370-
// dx: 2000,
371-
// dy: 2000,
372-
// zoom: 1,
373-
// projection: LambertAzimuthalEqualAreaProjection(λ0: -2.5, ϕ1: 54.9, radius: 6371229)
374-
// }
375-
// }
406+
{
407+
value: 'ukmo_uk_deterministic_2km',
408+
label: 'UK Met Office 2km',
409+
grid: {
410+
nx: 1042,
411+
ny: 970,
412+
latMin: 0, //-1036000
413+
lonMin: 0, //-1158000
414+
dx: 2000,
415+
dy: 2000,
416+
zoom: 1,
417+
projection: {
418+
λ0: -2.5,
419+
ϕ1: 54.9,
420+
// latitude: -1036000,
421+
// longitude: -1158000,
422+
radius: 6371229,
423+
name: 'LambertAzimuthalEqualAreaProjection'
424+
}
425+
}
426+
},
376427

377428
// KNMI
378429
{

src/utils/projection.ts

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,71 @@ export class LambertConformalConicProjection implements Projection {
132132
}
133133
}
134134

135+
export class LambertAzimuthalEqualAreaProjection implements Projection {
136+
λ0;
137+
ϕ1;
138+
R = 6371229; // Radius of the Earth
139+
constructor(projectionData: Domain['grid']['projection']) {
140+
if (projectionData) {
141+
const λ0_dec = projectionData.λ0;
142+
const ϕ1_dec = projectionData.ϕ1;
143+
const radius = projectionData.radius;
144+
this.λ0 = degreesToRadians(λ0_dec);
145+
this.ϕ1 = degreesToRadians(ϕ1_dec);
146+
if (radius) {
147+
this.R = radius;
148+
}
149+
}
150+
}
151+
152+
forward(latitude: number, longitude: number): [x: number, y: number] {
153+
let ϕ = degreesToRadians(latitude);
154+
let λ = degreesToRadians(longitude);
155+
156+
let k = Math.sqrt(
157+
2 /
158+
(1 +
159+
Math.sin(this.ϕ1) * Math.sin(ϕ) +
160+
Math.cos(this.ϕ1) * Math.cos(ϕ) * Math.cos(λ - this.λ0))
161+
);
162+
163+
let x = this.R * k * Math.cos(ϕ) * Math.sin(λ - this.λ0);
164+
let y =
165+
this.R *
166+
k *
167+
(Math.cos(this.ϕ1) * Math.sin(ϕ) -
168+
Math.sin(this.ϕ1) * Math.cos(ϕ) * Math.cos(λ - this.λ0));
169+
170+
return [x, y];
171+
}
172+
173+
reverse(x: number, y: number): [latitude: number, longitude: number] {
174+
x = x / this.R;
175+
y = y / this.R;
176+
let p = Math.sqrt(x * x + y * y);
177+
let c = 2 * Math.asin(0.5 * p);
178+
let ϕ = Math.asin(
179+
Math.cos(c) * Math.sin(this.ϕ1) + (y * Math.sin(c) * Math.cos(this.ϕ1)) / p
180+
);
181+
let λ =
182+
this.λ0 +
183+
Math.atan(
184+
(x * Math.sin(c)) /
185+
(p * Math.cos(this.ϕ1) * Math.cos(c) -
186+
y * Math.sin(this.ϕ1) * Math.sin(c))
187+
);
188+
189+
ϕ = radiansToDegrees(ϕ);
190+
λ = radiansToDegrees(λ);
191+
192+
return [ϕ, λ];
193+
}
194+
}
195+
135196
const projections = {
136197
RotatedLatLonProjection,
137-
LambertConformalConicProjection
198+
LambertConformalConicProjection,
199+
LambertAzimuthalEqualAreaProjection
138200
};
139201

140202
export class DynamicProjection {

0 commit comments

Comments
 (0)