Skip to content

Commit c8f311e

Browse files
committed
fixes timed airspaces
1 parent 200ad7b commit c8f311e

File tree

2 files changed

+154
-113
lines changed

2 files changed

+154
-113
lines changed

libs/common/src/lib/airspaces.test.ts

Lines changed: 108 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
Class,
1212
getAirspaceTileUrl,
1313
toTypedAirspace,
14+
Type,
1415
} from './airspaces';
1516
import { fetchResponse } from './fetch-timeout';
1617

@@ -167,6 +168,36 @@ describe('Time dependent Airspace', () => {
167168
"type": 7,
168169
}
169170
`);
171+
expect(airspaces.get('TMA CHAMBERY 2')).toMatchInlineSnapshot(`
172+
{
173+
"activity": 0,
174+
"country": "FR",
175+
"floorLabel": "5500ft MSL",
176+
"floorM": 1676,
177+
"floorRefGnd": false,
178+
"icaoClass": 4,
179+
"name": "TMA CHAMBERY 2",
180+
"topLabel": "FL 95",
181+
"topM": 2896,
182+
"topRefGnd": false,
183+
"type": 7,
184+
}
185+
`);
186+
expect(airspaces.get('TMA CHAMBERY 3')).toMatchInlineSnapshot(`
187+
{
188+
"activity": 0,
189+
"country": "FR",
190+
"floorLabel": "FL 95",
191+
"floorM": 2896,
192+
"floorRefGnd": false,
193+
"icaoClass": 4,
194+
"name": "TMA CHAMBERY 3",
195+
"topLabel": "FL 115",
196+
"topM": 3505,
197+
"topRefGnd": false,
198+
"type": 7,
199+
}
200+
`);
170201
expect(airspaces.get('CTR CHAMBERY 2 (ACTIVE MID DEC -> MID AVRIL)')).toMatchInlineSnapshot(`
171202
{
172203
"activity": 0,
@@ -207,82 +238,82 @@ describe('Time dependent Airspace', () => {
207238
expect(applyTimeRule(ecrins, new TZDate('2024-11-01', 'Europe/Paris'))).toEqual(ecrins);
208239
expect(applyTimeRule(ecrins, new TZDate('2024-12-31', 'Europe/Paris'))).toEqual(ecrins);
209240

210-
expect(applyTimeRule(ecrins, new TZDate('2024-07-01', 'Europe/Paris'))).not.toEqual(ecrins);
211-
expect(applyTimeRule(ecrins, new TZDate('2024-10-31', 'Europe/Paris'))).not.toEqual(ecrins);
241+
expect(applyTimeRule(ecrins, new TZDate('2024-07-01', 'Europe/Paris')).type).toEqual(Type.Other);
242+
expect(applyTimeRule(ecrins, new TZDate('2024-10-31', 'Europe/Paris')).type).toEqual(Type.Other);
212243
});
213244

214245
test('TMA CLERMONT 2.1 (VOL LIBRE)', () => {
215246
const clermont21 = airspaces.get('TMA CLERMONT 2.1 (VOL LIBRE)')!;
216247

217-
expect(applyTimeRule(clermont21, new TZDate('2024-01-01', 'Europe/Paris'))).not.toEqual(clermont21);
218-
expect(applyTimeRule(clermont21, new TZDate('2024-03-14', 'Europe/Paris'))).not.toEqual(clermont21);
219-
expect(applyTimeRule(clermont21, new TZDate('2024-10-16', 'Europe/Paris'))).not.toEqual(clermont21);
220-
expect(applyTimeRule(clermont21, new TZDate('2024-12-31', 'Europe/Paris'))).not.toEqual(clermont21);
248+
expect(applyTimeRule(clermont21, new TZDate('2024-01-01', 'Europe/Paris')).topM).toEqual(1680);
249+
expect(applyTimeRule(clermont21, new TZDate('2024-03-14', 'Europe/Paris')).topM).toEqual(1680);
250+
expect(applyTimeRule(clermont21, new TZDate('2024-10-16', 'Europe/Paris')).topM).toEqual(1680);
251+
expect(applyTimeRule(clermont21, new TZDate('2024-12-31', 'Europe/Paris')).topM).toEqual(1680);
221252

222-
expect(applyTimeRule(clermont21, new TZDate('2024-03-15', 'Europe/Paris'))).toEqual(clermont21);
223-
expect(applyTimeRule(clermont21, new TZDate('2024-10-15', 'Europe/Paris'))).toEqual(clermont21);
253+
expect(applyTimeRule(clermont21, new TZDate('2024-03-15', 'Europe/Paris')).topM).toEqual(1981);
254+
expect(applyTimeRule(clermont21, new TZDate('2024-10-15', 'Europe/Paris')).topM).toEqual(1981);
224255
});
225256

226257
test('TMA CLERMONT 2.2 CHAMPEIX (VOL LIBRE)', () => {
227258
const clermont22 = airspaces.get('TMA CLERMONT 2.2 CHAMPEIX (VOL LIBRE)')!;
228259

229-
expect(applyTimeRule(clermont22, new TZDate('2024-01-01', 'Europe/Paris'))).not.toEqual(clermont22);
230-
expect(applyTimeRule(clermont22, new TZDate('2024-03-14', 'Europe/Paris'))).not.toEqual(clermont22);
231-
expect(applyTimeRule(clermont22, new TZDate('2024-10-16', 'Europe/Paris'))).not.toEqual(clermont22);
232-
expect(applyTimeRule(clermont22, new TZDate('2024-12-31', 'Europe/Paris'))).not.toEqual(clermont22);
260+
expect(applyTimeRule(clermont22, new TZDate('2024-01-01', 'Europe/Paris')).topM).toEqual(1680);
261+
expect(applyTimeRule(clermont22, new TZDate('2024-03-14', 'Europe/Paris')).topM).toEqual(1680);
262+
expect(applyTimeRule(clermont22, new TZDate('2024-10-16', 'Europe/Paris')).topM).toEqual(1680);
263+
expect(applyTimeRule(clermont22, new TZDate('2024-12-31', 'Europe/Paris')).topM).toEqual(1680);
233264

234-
expect(applyTimeRule(clermont22, new TZDate('2024-03-15', 'Europe/Paris'))).toEqual(clermont22);
235-
expect(applyTimeRule(clermont22, new TZDate('2024-10-15', 'Europe/Paris'))).toEqual(clermont22);
265+
expect(applyTimeRule(clermont22, new TZDate('2024-03-15', 'Europe/Paris')).topM).toEqual(1980);
266+
expect(applyTimeRule(clermont22, new TZDate('2024-10-15', 'Europe/Paris')).topM).toEqual(1980);
236267
});
237268

238269
test('TMA CLERMONT 2.3 ORCINES (VOL LIBRE)', () => {
239270
const clermont23 = airspaces.get('TMA CLERMONT 2.3 ORCINES (VOL LIBRE)')!;
240271

241-
expect(applyTimeRule(clermont23, new TZDate('2024-01-01', 'Europe/Paris'))).not.toEqual(clermont23);
242-
expect(applyTimeRule(clermont23, new TZDate('2024-03-14', 'Europe/Paris'))).not.toEqual(clermont23);
243-
expect(applyTimeRule(clermont23, new TZDate('2024-10-16', 'Europe/Paris'))).not.toEqual(clermont23);
244-
expect(applyTimeRule(clermont23, new TZDate('2024-12-31', 'Europe/Paris'))).not.toEqual(clermont23);
272+
expect(applyTimeRule(clermont23, new TZDate('2024-01-01', 'Europe/Paris')).topM).toEqual(1680);
273+
expect(applyTimeRule(clermont23, new TZDate('2024-03-14', 'Europe/Paris')).topM).toEqual(1680);
274+
expect(applyTimeRule(clermont23, new TZDate('2024-10-16', 'Europe/Paris')).topM).toEqual(1680);
275+
expect(applyTimeRule(clermont23, new TZDate('2024-12-31', 'Europe/Paris')).topM).toEqual(1680);
245276

246277
// 2024-03-15 is a Friday
247-
expect(applyTimeRule(clermont23, new TZDate('2024-03-15', 'Europe/Paris'))).not.toEqual(clermont23);
248-
expect(applyTimeRule(clermont23, new TZDate('2024-03-16', 'Europe/Paris'))).toEqual(clermont23);
249-
expect(applyTimeRule(clermont23, new TZDate('2024-03-17', 'Europe/Paris'))).toEqual(clermont23);
278+
expect(applyTimeRule(clermont23, new TZDate('2024-03-15', 'Europe/Paris')).topM).toEqual(1980);
279+
expect(applyTimeRule(clermont23, new TZDate('2024-03-16', 'Europe/Paris')).topM).toEqual(2591);
280+
expect(applyTimeRule(clermont23, new TZDate('2024-03-17', 'Europe/Paris')).topM).toEqual(2591);
250281

251282
// 2024-10-15 is a Tuesday
252-
expect(applyTimeRule(clermont23, new TZDate('2024-10-15', 'Europe/Paris'))).not.toEqual(clermont23);
253-
expect(applyTimeRule(clermont23, new TZDate('2024-10-13', 'Europe/Paris'))).toEqual(clermont23);
254-
expect(applyTimeRule(clermont23, new TZDate('2024-10-12', 'Europe/Paris'))).toEqual(clermont23);
283+
expect(applyTimeRule(clermont23, new TZDate('2024-10-15', 'Europe/Paris')).topM).toEqual(1980);
284+
expect(applyTimeRule(clermont23, new TZDate('2024-10-13', 'Europe/Paris')).topM).toEqual(2591);
285+
expect(applyTimeRule(clermont23, new TZDate('2024-10-12', 'Europe/Paris')).topM).toEqual(2591);
255286
});
256287

257288
test('TMA CLERMONT 4.1 JOB (VOL LIBRE)', () => {
258289
const clermont41 = airspaces.get('TMA CLERMONT 4.1 JOB (VOL LIBRE)')!;
259290

260-
expect(applyTimeRule(clermont41, new TZDate('2024-01-01', 'Europe/Paris'))).not.toEqual(clermont41);
261-
expect(applyTimeRule(clermont41, new TZDate('2024-03-14', 'Europe/Paris'))).not.toEqual(clermont41);
262-
expect(applyTimeRule(clermont41, new TZDate('2024-10-16', 'Europe/Paris'))).not.toEqual(clermont41);
263-
expect(applyTimeRule(clermont41, new TZDate('2024-12-31', 'Europe/Paris'))).not.toEqual(clermont41);
291+
expect(applyTimeRule(clermont41, new TZDate('2024-01-01', 'Europe/Paris')).topM).toEqual(2590);
292+
expect(applyTimeRule(clermont41, new TZDate('2024-03-14', 'Europe/Paris')).topM).toEqual(2590);
293+
expect(applyTimeRule(clermont41, new TZDate('2024-10-16', 'Europe/Paris')).topM).toEqual(2590);
294+
expect(applyTimeRule(clermont41, new TZDate('2024-12-31', 'Europe/Paris')).topM).toEqual(2590);
264295

265296
// 2024-03-15 is a Friday
266-
expect(applyTimeRule(clermont41, new TZDate('2024-03-15', 'Europe/Paris'))).not.toEqual(clermont41);
267-
expect(applyTimeRule(clermont41, new TZDate('2024-03-16', 'Europe/Paris'))).toEqual(clermont41);
268-
expect(applyTimeRule(clermont41, new TZDate('2024-03-17', 'Europe/Paris'))).toEqual(clermont41);
297+
expect(applyTimeRule(clermont41, new TZDate('2024-03-15', 'Europe/Paris')).topM).toEqual(2590);
298+
expect(applyTimeRule(clermont41, new TZDate('2024-03-16', 'Europe/Paris')).topM).toEqual(2896);
299+
expect(applyTimeRule(clermont41, new TZDate('2024-03-17', 'Europe/Paris')).topM).toEqual(2896);
269300

270301
// 2024-10-15 is a Tuesday
271-
expect(applyTimeRule(clermont41, new TZDate('2024-10-15', 'Europe/Paris'))).not.toEqual(clermont41);
272-
expect(applyTimeRule(clermont41, new TZDate('2024-10-13', 'Europe/Paris'))).toEqual(clermont41);
273-
expect(applyTimeRule(clermont41, new TZDate('2024-10-12', 'Europe/Paris'))).toEqual(clermont41);
302+
expect(applyTimeRule(clermont41, new TZDate('2024-10-15', 'Europe/Paris')).topM).toEqual(2590);
303+
expect(applyTimeRule(clermont41, new TZDate('2024-10-13', 'Europe/Paris')).topM).toEqual(2896);
304+
expect(applyTimeRule(clermont41, new TZDate('2024-10-12', 'Europe/Paris')).topM).toEqual(2896);
274305
});
275306

276307
test('TMA CLERMONT5.1 PUY DE DOME (VOL LIBRE)', () => {
277308
const clermont51 = airspaces.get('TMA CLERMONT5.1 PUY DE DOME (VOL LIBRE)')!;
278309

279-
expect(applyTimeRule(clermont51, new TZDate('2024-01-01', 'Europe/Paris'))).not.toEqual(clermont51);
280-
expect(applyTimeRule(clermont51, new TZDate('2024-03-14', 'Europe/Paris'))).not.toEqual(clermont51);
281-
expect(applyTimeRule(clermont51, new TZDate('2024-10-16', 'Europe/Paris'))).not.toEqual(clermont51);
282-
expect(applyTimeRule(clermont51, new TZDate('2024-12-31', 'Europe/Paris'))).not.toEqual(clermont51);
310+
expect(applyTimeRule(clermont51, new TZDate('2024-01-01', 'Europe/Paris')).topM).toEqual(2590);
311+
expect(applyTimeRule(clermont51, new TZDate('2024-03-14', 'Europe/Paris')).topM).toEqual(2590);
312+
expect(applyTimeRule(clermont51, new TZDate('2024-10-16', 'Europe/Paris')).topM).toEqual(2590);
313+
expect(applyTimeRule(clermont51, new TZDate('2024-12-31', 'Europe/Paris')).topM).toEqual(2590);
283314

284-
expect(applyTimeRule(clermont51, new TZDate('2024-03-15', 'Europe/Paris'))).toEqual(clermont51);
285-
expect(applyTimeRule(clermont51, new TZDate('2024-10-15', 'Europe/Paris'))).toEqual(clermont51);
315+
expect(applyTimeRule(clermont51, new TZDate('2024-03-15', 'Europe/Paris')).topM).toEqual(3505);
316+
expect(applyTimeRule(clermont51, new TZDate('2024-10-15', 'Europe/Paris')).topM).toEqual(3505);
286317
});
287318

288319
test('LF-R30B MONT BLANC (JULY+AUGUST)', () => {
@@ -297,53 +328,44 @@ describe('Time dependent Airspace', () => {
297328
expect(applyTimeRule(r30b, new TZDate('2024-08-31', 'Europe/Paris'))).toEqual(r30b);
298329
});
299330

300-
test('TMA CHAMBERY 1', () => {
301-
const chamberyTMA1 = airspaces.get('TMA CHAMBERY 1')!;
302-
// TODO: remove when openaip is fixed
303-
chamberyTMA1.icaoClass = Class.D;
304-
305-
// E from 2nd Monday of April to 2nd Friday of December
306-
expect(applyTimeRule(chamberyTMA1, new TZDate('2025-04-14', 'Europe/Paris'))).not.toEqual(chamberyTMA1);
307-
expect(applyTimeRule(chamberyTMA1, new TZDate('2025-12-12', 'Europe/Paris'))).not.toEqual(chamberyTMA1);
308-
309-
// E from from Monday 11UTC to Thursday 23:59UTC
310-
expect(applyTimeRule(chamberyTMA1, new TZDate('2025-04-13', 'Europe/Paris'))).toEqual(chamberyTMA1);
311-
expect(applyTimeRule(chamberyTMA1, new TZDate('2025-12-13', 'Europe/Paris'))).toEqual(chamberyTMA1);
312-
// Tuesday -> Thursday
313-
expect(applyTimeRule(chamberyTMA1, new TZDate('2025-04-08', 'Europe/Paris'))).not.toEqual(chamberyTMA1);
314-
expect(applyTimeRule(chamberyTMA1, new TZDate('2025-04-09', 'Europe/Paris'))).not.toEqual(chamberyTMA1);
315-
expect(applyTimeRule(chamberyTMA1, new TZDate('2025-04-10', 'Europe/Paris'))).not.toEqual(chamberyTMA1);
316-
});
317-
318-
test('CTR CHAMBERY 2 (ACTIVE MID DEC -> MID AVRIL)', () => {
319-
const chamberyCTR2 = airspaces.get('CTR CHAMBERY 2 (ACTIVE MID DEC -> MID AVRIL)')!;
320-
321-
// E from 2nd Monday of April to 2nd Friday of December
322-
expect(applyTimeRule(chamberyCTR2, new TZDate('2025-04-14', 'Europe/Paris'))).not.toEqual(chamberyCTR2);
323-
expect(applyTimeRule(chamberyCTR2, new TZDate('2025-12-12', 'Europe/Paris'))).not.toEqual(chamberyCTR2);
324-
325-
// E from from Monday 11UTC to Thursday 23:59UTC
326-
expect(applyTimeRule(chamberyCTR2, new TZDate('2025-04-13', 'Europe/Paris'))).toEqual(chamberyCTR2);
327-
expect(applyTimeRule(chamberyCTR2, new TZDate('2025-12-13', 'Europe/Paris'))).toEqual(chamberyCTR2);
328-
// Tuesday -> Thursday
329-
expect(applyTimeRule(chamberyCTR2, new TZDate('2025-04-08', 'Europe/Paris'))).not.toEqual(chamberyCTR2);
330-
expect(applyTimeRule(chamberyCTR2, new TZDate('2025-04-09', 'Europe/Paris'))).not.toEqual(chamberyCTR2);
331-
expect(applyTimeRule(chamberyCTR2, new TZDate('2025-04-10', 'Europe/Paris'))).not.toEqual(chamberyCTR2);
331+
test('TMA CHAMBERY', () => {
332+
for (const tmaName of ['TMA CHAMBERY 1', 'TMA CHAMBERY 2', 'TMA CHAMBERY 3']) {
333+
const tma = airspaces.get(tmaName)!;
334+
// openaip has class E
335+
tma.icaoClass = Class.D;
336+
337+
// E from 2nd Monday of April to 2nd Friday of December
338+
expect(applyTimeRule(tma, new TZDate('2025-04-14', 'Europe/Paris'))).not.toEqual(tma);
339+
expect(applyTimeRule(tma, new TZDate('2025-12-12', 'Europe/Paris'))).not.toEqual(tma);
340+
341+
// E from from Monday 11UTC to Thursday 23:59UTC
342+
expect(applyTimeRule(tma, new TZDate('2025-04-13', 'Europe/Paris'))).toEqual(tma);
343+
expect(applyTimeRule(tma, new TZDate('2025-12-13', 'Europe/Paris'))).toEqual(tma);
344+
// Tuesday -> Thursday
345+
expect(applyTimeRule(tma, new TZDate('2025-04-08', 'Europe/Paris'))).not.toEqual(tma);
346+
expect(applyTimeRule(tma, new TZDate('2025-04-09', 'Europe/Paris'))).not.toEqual(tma);
347+
expect(applyTimeRule(tma, new TZDate('2025-04-10', 'Europe/Paris'))).not.toEqual(tma);
348+
}
332349
});
333350

334-
test('CTR CHAMBERY 3 (ACTIVE MID DEC -> MID AVRIL)', () => {
335-
const chamberyCTR3 = airspaces.get('CTR CHAMBERY 3 (ACTIVE MID DEC -> MID AVRIL)')!;
336-
337-
// E from 2nd Monday of April to 2nd Friday of December
338-
expect(applyTimeRule(chamberyCTR3, new TZDate('2025-04-14', 'Europe/Paris'))).not.toEqual(chamberyCTR3);
339-
expect(applyTimeRule(chamberyCTR3, new TZDate('2025-12-12', 'Europe/Paris'))).not.toEqual(chamberyCTR3);
340-
341-
// E from from Monday 11UTC to Thursday 23:59UTC
342-
expect(applyTimeRule(chamberyCTR3, new TZDate('2025-04-13', 'Europe/Paris'))).toEqual(chamberyCTR3);
343-
expect(applyTimeRule(chamberyCTR3, new TZDate('2025-12-13', 'Europe/Paris'))).toEqual(chamberyCTR3);
344-
// Tuesday -> Thursday
345-
expect(applyTimeRule(chamberyCTR3, new TZDate('2025-04-08', 'Europe/Paris'))).not.toEqual(chamberyCTR3);
346-
expect(applyTimeRule(chamberyCTR3, new TZDate('2025-04-09', 'Europe/Paris'))).not.toEqual(chamberyCTR3);
347-
expect(applyTimeRule(chamberyCTR3, new TZDate('2025-04-10', 'Europe/Paris'))).not.toEqual(chamberyCTR3);
351+
test('CTR CHAMBERY', () => {
352+
for (const ctrName of [
353+
'CTR CHAMBERY 2 (ACTIVE MID DEC -> MID AVRIL)',
354+
'CTR CHAMBERY 3 (ACTIVE MID DEC -> MID AVRIL)',
355+
]) {
356+
const ctr = airspaces.get(ctrName)!;
357+
358+
// E from 2nd Monday of April to 2nd Friday of December
359+
expect(applyTimeRule(ctr, new TZDate('2025-04-14', 'Europe/Paris'))).not.toEqual(ctr);
360+
expect(applyTimeRule(ctr, new TZDate('2025-12-12', 'Europe/Paris'))).not.toEqual(ctr);
361+
362+
// E from from Monday 11UTC to Thursday 23:59UTC
363+
expect(applyTimeRule(ctr, new TZDate('2025-04-13', 'Europe/Paris'))).toEqual(ctr);
364+
expect(applyTimeRule(ctr, new TZDate('2025-12-13', 'Europe/Paris'))).toEqual(ctr);
365+
// Tuesday -> Thursday
366+
expect(applyTimeRule(ctr, new TZDate('2025-04-08', 'Europe/Paris'))).not.toEqual(ctr);
367+
expect(applyTimeRule(ctr, new TZDate('2025-04-09', 'Europe/Paris'))).not.toEqual(ctr);
368+
expect(applyTimeRule(ctr, new TZDate('2025-04-10', 'Europe/Paris'))).not.toEqual(ctr);
369+
}
348370
});
349371
});

0 commit comments

Comments
 (0)