feat(workbench): integrate operational workflows and map state

This commit is contained in:
2026-09-24 04:34:46 +08:00
parent 1752b9ef84
commit 436d5500f1
76 changed files with 5081 additions and 1937 deletions
@@ -1,6 +1,7 @@
import { describe, expect, it, vi } from "vitest";
import {
clearMapFeatureInteractionState,
isPointOccludedByCityBuilding,
setMapFeatureInteractionState,
toMapFeatureReference
} from "./use-map-interactions";
@@ -8,6 +9,7 @@ import { INTERACTIVE_HIT_LAYER_IDS } from "../map/layers";
describe("map feature interaction state", () => {
const feature = { source: "junctions", sourceLayer: "junctions", id: "junction-7" } as const;
type CityOcclusionMap = Parameters<typeof isPointOccludedByCityBuilding>[0];
it("maps selected business features to promoted vector feature references", () => {
expect(toMapFeatureReference({ id: "junction-7", layer: "junctions" })).toEqual(feature);
@@ -42,4 +44,30 @@ describe("map feature interaction state", () => {
"fx_20200423_pipes-hit"
]));
});
it("blocks pointer interactions where a 3D building is rendered", () => {
const queryRenderedFeatures = vi.fn(() => [{ id: "building-1" }]);
const map = {
getLayer: vi.fn(() => ({ id: "fengxian-city-buildings" })),
getPitch: vi.fn(() => 55),
queryRenderedFeatures
};
expect(isPointOccludedByCityBuilding(map as unknown as CityOcclusionMap, [120, 80])).toBe(true);
expect(queryRenderedFeatures).toHaveBeenCalledWith([120, 80], {
layers: ["fengxian-city-buildings"]
});
});
it("keeps 2D pointer interactions independent of the optional city scene", () => {
const queryRenderedFeatures = vi.fn();
const map = {
getLayer: vi.fn(() => ({ id: "fengxian-city-buildings" })),
getPitch: vi.fn(() => 0),
queryRenderedFeatures
};
expect(isPointOccludedByCityBuilding(map as unknown as CityOcclusionMap, [120, 80])).toBe(false);
expect(queryRenderedFeatures).not.toHaveBeenCalled();
});
});