e61634c3b9
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.
65 lines
2.2 KiB
TypeScript
65 lines
2.2 KiB
TypeScript
// Neuer Bezugspunkt — verschiebt das GESAMTE Projekt (Wände, Decken, Dächer,
|
|
// Treppen, Räume, Stützen, Extrusionen, freie 2D-Geometrie, Kontext-Schicht,
|
|
// Schnittlinien) so, dass der geklickte Punkt zum neuen Modell-Ursprung (0,0)
|
|
// wird. Praktisch nach einem Kataster-/3D-Import (Kontext-Geometrie landet
|
|
// dort, wo der gesuchte Standort war — kann weit vom bisherigen Ursprung
|
|
// liegen, s. `Project.geoAnchor`): man klickt den gewünschten Bezugspunkt
|
|
// (z. B. eine Parzellenecke aus dem Import) und zeichnet danach mit kleinen,
|
|
// bequemen Koordinaten weiter. `geoAnchor` wandert automatisch mit (reine
|
|
// Translation, s. `model/geoRebase.ts`), der reale LV95-Bezug bleibt exakt
|
|
// erhalten — beim Export ist die Verschiebung jederzeit rekonstruierbar.
|
|
//
|
|
// Ein-Klick-Befehl: der erste (einzige) Punkt committet sofort.
|
|
|
|
import { translateProject } from "../../model/geoRebase";
|
|
import type {
|
|
Command,
|
|
CommandResult,
|
|
CommandState,
|
|
Project,
|
|
ToolDraft,
|
|
Vec2,
|
|
} from "../types";
|
|
|
|
interface GeorefStart extends CommandState {
|
|
phase: "start";
|
|
}
|
|
|
|
const IDLE: GeorefStart = { phase: "start", lastPoint: null };
|
|
const idle = (): [CommandState, CommandResult] => [{ ...IDLE }, { draft: null, done: true }];
|
|
|
|
/** HUD am Cursor: zeigt die resultierende Verschiebung, bevor geklickt wird. */
|
|
function draft(point: Vec2): ToolDraft {
|
|
return {
|
|
preview: [],
|
|
vertices: [],
|
|
hud: { at: point, dx: -point.x, dy: -point.y },
|
|
};
|
|
}
|
|
|
|
export const georefCommand: Command = {
|
|
name: "georef",
|
|
labelKey: "cmd.georef.label",
|
|
prompt: () => "cmd.georef.prompt",
|
|
accepts: () => ["point"],
|
|
options: () => [],
|
|
init: (): GeorefStart => ({ ...IDLE }),
|
|
|
|
onInput: (state, input): [CommandState, CommandResult] => {
|
|
if (input.kind !== "point") return [state, { draft: null }];
|
|
const { x, y } = input.point;
|
|
return [
|
|
{ ...IDLE },
|
|
{
|
|
draft: null,
|
|
done: true,
|
|
commit: (p: Project) => translateProject(p, -x, -y),
|
|
},
|
|
];
|
|
},
|
|
|
|
onMove: (state, point): [CommandState, CommandResult] => [state, { draft: draft(point) }],
|
|
onConfirm: (): [CommandState, CommandResult] => idle(),
|
|
onCancel: (): [CommandState, CommandResult] => idle(),
|
|
};
|