Files
DOSSIER-STANDALONE/src/commands/cmds/georef.test.ts
T
karim e61634c3b9 Neuer Bezugspunkt: Projekt nach Kataster-/3D-Import auf praktischen Ursprung verschieben
Nach einem Standort-Import landet die Kontext-Geometrie dort, wo der gesuchte
Ort war — das kann weit vom bisherigen Modell-Ursprung liegen. Neuer Befehl
"georef" (Button in SitePanel) verschiebt das GESAMTE Projekt per Klick so,
dass der gewählte Punkt zum neuen Ursprung wird; geoAnchor wandert automatisch
mit, der reale LV95-Bezug bleibt exakt erhalten (rekonstruierbar, auch beim
späteren Export). Bewusst nur Translation, keine Rotation — mehrere Felder
(Roof.ridgeAxis, Column.rotation, Text-/Bild-Rotation) sind achsen-/winkel-
gebunden und bräuchten bei einer Drehung eigene Sorgfalt.
2026-07-12 20:13:22 +02:00

59 lines
1.9 KiB
TypeScript

import { describe, it, expect } from "vitest";
import { georefCommand } from "./georef";
import type { CommandContext, Project, Vec2 } from "../types";
const ctx = {} as CommandContext;
const P = (x: number, y: number): Vec2 => ({ x, y });
function projectWith(wallStart: Vec2): Project {
return {
id: "p",
name: "T",
layers: [],
drawingLevels: [],
walls: [
{
id: "W1",
type: "wall",
floorId: "eg",
categoryCode: "20",
start: wallStart,
end: { x: wallStart.x + 5, y: wallStart.y },
wallTypeId: "aw",
height: 2.6,
},
],
drawings2d: [],
} as unknown as Project;
}
describe("georefCommand", () => {
it("Hover zeigt die resultierende Verschiebung im HUD (negativer Klickpunkt)", () => {
const s0 = georefCommand.init();
const [, r] = georefCommand.onMove(s0, P(120, 45), null, ctx);
expect(r.draft?.hud).toEqual({ at: P(120, 45), dx: -120, dy: -45 });
});
it("Klick committet sofort: der geklickte Punkt wird zum neuen Ursprung", () => {
const s0 = georefCommand.init();
const [ns, r] = georefCommand.onInput(s0, { kind: "point", point: P(120, 45) }, ctx);
expect(r.done).toBe(true);
expect((ns as { phase: string }).phase).toBe("start");
const p = projectWith({ x: 120, y: 45 });
const out = r.commit!(p);
// Die Wand begann exakt am geklickten Punkt -> liegt danach auf (0,0).
expect(out.walls[0].start).toEqual({ x: 0, y: 0 });
expect(out.walls[0].end).toEqual({ x: 5, y: 0 });
});
it("Esc/Rechtsklick auf leerem Zustand beendet ohne Commit", () => {
const s0 = georefCommand.init();
const [, r1] = georefCommand.onCancel(s0);
expect(r1.done).toBe(true);
expect(r1.commit).toBeUndefined();
const [, r2] = georefCommand.onConfirm(s0, ctx);
expect(r2.done).toBe(true);
expect(r2.commit).toBeUndefined();
});
});