feat: initialize drainage network frontend

This commit is contained in:
2026-07-10 16:16:17 +08:00
commit 66de96d9e4
133 changed files with 33057 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
import type { Map as MapLibreMap } from "maplibre-gl";
import { describe, expect, it, vi } from "vitest";
import { fitNetworkBounds } from "./camera";
import { WATER_NETWORK_GLOBAL_VIEW } from "./sources";
describe("fitNetworkBounds", () => {
it("fits the global WebMercator bbox through MapLibre lng/lat bounds", () => {
const fitBounds = vi.fn();
const map = {
fitBounds,
getCanvas: () => ({
clientWidth: 1280,
clientHeight: 720,
width: 1280,
height: 720
})
} as unknown as MapLibreMap;
fitNetworkBounds(map, WATER_NETWORK_GLOBAL_VIEW);
expect(fitBounds).toHaveBeenCalledTimes(1);
const [bounds, options] = fitBounds.mock.calls[0] ?? [];
expect(bounds[0][0]).toBeCloseTo(121.351633, 6);
expect(bounds[0][1]).toBeCloseTo(30.810505, 6);
expect(bounds[1][0]).toBeCloseTo(121.772485, 6);
expect(bounds[1][1]).toBeCloseTo(31.007214, 6);
expect(options).toMatchObject({
duration: 600,
padding: { top: 0, right: 0, bottom: 0, left: 0 }
});
expect(options).not.toHaveProperty("zoom");
expect(options).not.toHaveProperty("maxZoom");
});
});