mirror of
https://github.com/MeshCore-Beacon/beacon-web.git
synced 2026-10-22 17:41:23 +00:00
Add a toggleable IATA border layer to the map
Draw each active IATA's GeoJSON region border as an outline over a faint fill beneath the node markers, behind a Map Settings toggle that's off by default and shareable via a URL param. IATAs with no border answer 204 and are skipped.
This commit is contained in:
1 parent
8baa562794
commit
464e701f76
10 files changed
+305
-4
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { mergeBorders } from "../../../src/features/map/useMapBordersData";
|
||||
import type { Feature, Polygon } from "geojson";
|
||||
|
||||
const poly = (id: number): Feature<Polygon> => ({
|
||||
type: "Feature",
|
||||
properties: { name: `p${id}` },
|
||||
geometry: { type: "Polygon", coordinates: [[[id, 0], [id + 1, 0], [id + 1, 1], [id, 0]]] },
|
||||
});
|
||||
|
||||
describe("mergeBorders", () => {
|
||||
it("drops IATAs with no border and stamps the iata onto each feature's properties", () => {
|
||||
const fc = mergeBorders([
|
||||
{ iata: "YOW", border: poly(0) },
|
||||
{ iata: "YYZ", border: null },
|
||||
{ iata: "YUL", border: poly(5) },
|
||||
]);
|
||||
|
||||
expect(fc.type).toBe("FeatureCollection");
|
||||
expect(fc.features).toHaveLength(2);
|
||||
expect(fc.features.map((f) => f.properties.iata)).toEqual(["YOW", "YUL"]);
|
||||
// existing properties and geometry survive the merge
|
||||
expect(fc.features[0]!.properties.name).toBe("p0");
|
||||
expect(fc.features[0]!.geometry).toEqual(poly(0).geometry);
|
||||
});
|
||||
|
||||
it("returns an empty FeatureCollection when nothing has a border", () => {
|
||||
const fc = mergeBorders([{ iata: "YOW", border: null }]);
|
||||
expect(fc.features).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user