Skip to content

Commit 200ad7b

Browse files
authored
Sync airspaces (#353)
1 parent 1d15fc7 commit 200ad7b

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

apps/fxc-tiles/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Install [tippecanoe](https://github.com/felt/tippecanoe) - note that the the map
1616
- Create the tiles - See above,
1717
- Create the tile info with `node dist/apps/fxc-tiles/airspaces/create-tiles-info.js`
1818
- Create the info diff with `node dist/apps/fxc-tiles/airspaces/create-tiles-info-diff.js`
19+
- Run tests `nx check`
1920
- Sync the diff with `node dist/apps/fxc-tiles/airspaces/upload-tiles-diff.js`
2021

2122
### ZIP update (outdated, probably not needed with the diff update)

apps/fxc-tiles/src/assets/airspaces/tiles-info.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

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

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
14
import { TZDate } from '@date-fns/tz';
25
import { VectorTile } from 'mapbox-vector-tile';
36

@@ -13,12 +16,20 @@ import { fetchResponse } from './fetch-timeout';
1316

1417
async function getTile(x: number, y: number, z: number): Promise<Map<string, AirspaceTyped>> {
1518
const airspaces = new Map<string, AirspaceTyped>();
16-
const url = getAirspaceTileUrl(x, y, z, 'cloud');
17-
const response = await fetchResponse(url);
18-
if (!response.ok) {
19-
throw new Error(`Error reading the tile ${url}`);
19+
let buffer: ArrayBuffer;
20+
21+
const filename = path.join(__dirname, '../../../..', `apps/fxc-tiles/src/assets/airspaces/tiles/${z}/${x}/${y}.pbf`);
22+
if (fs.existsSync(filename)) {
23+
buffer = fs.readFileSync(filename);
24+
} else {
25+
const url = getAirspaceTileUrl(x, y, z, 'cloud');
26+
const response = await fetchResponse(url);
27+
if (!response.ok) {
28+
throw new Error(`Error reading the tile ${url}`);
29+
}
30+
buffer = await response.arrayBuffer();
2031
}
21-
const buffer = await response.arrayBuffer();
32+
2233
const aspLayer = new VectorTile(new Uint8Array(buffer)).layers.asp;
2334
for (let i = 0; i < aspLayer.length; i++) {
2435
const feature = aspLayer.feature(i);
@@ -48,7 +59,7 @@ describe('Time dependent Airspace', () => {
4859
"topLabel": "3281ft GND",
4960
"topM": 1000,
5061
"topRefGnd": true,
51-
"type": 3,
62+
"type": 29,
5263
}
5364
`);
5465
expect(airspaces.get('TMA CLERMONT 2.1 (VOL LIBRE)')).toMatchInlineSnapshot(`

0 commit comments

Comments
 (0)