core/src/plan/extras.rs rechnet Schattenstudie und Baurecht (unterste
Gruppe, Verstösse zuoberst), zieht Abzugskörper von Wand-/Stützen-/
Decken-Poché ab, setzt Schwarz-Weiss und Strichstärken nach Massstab
beim Schreiben (Writer::post, auch drawingLines) und das Ausmass samt
Kontext. planDomains liefert 12 Gruppen; generatePlan reicht nur noch
Sichtbarkeit und Optionen weiter, der Plan bleibt immer lazy aus
Kern-Puffern. Gelöscht: generatePlan/{sunShadow,siteRules}.ts,
lineWeightScale.ts, subtractVoidsInPlan/segmentOutside (samt Bindung),
toMono, computeBounds, realignRuns.
Gleichheit: temporärer Test (gelöscht) 481 000 Primitive Feld für Feld
gegen die alte TS-Fassung (Beispiel alle Ebenen, bigSample, 120
Zufallsprojekte mit Schatten/Baurecht/Abzugskörpern/Mono/Massstab,
Kataster); CLI byte-gleich zum Stand vor beiden Schritten (96 Ausgaben).
generatePlan unverändert mit Studie/Baurecht/40 Abzugskörpern 237 ->
2,3 ms. geomTransform bleibt in TS (Begründung in TODO.md). Nicht in der
Tauri-App angesehen.
Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
46 lines
2.3 KiB
TypeScript
46 lines
2.3 KiB
TypeScript
/**
|
|
* `generatePlan` — Baurecht (`Project.siteRules`): Parzellengrenze, zulässige Fläche und
|
|
* Verstösse im Geschoss nächst ±0.00.
|
|
*/
|
|
|
|
import { describe, it, expect } from "vitest";
|
|
import { generatePlan } from "./generatePlan";
|
|
import { sampleProject } from "../model/sampleProject";
|
|
import { flattenCategories } from "../model/types";
|
|
import type { Project, SiteRules } from "../model/types";
|
|
|
|
const ALL = new Set(flattenCategories(sampleProject.layers).map((c) => c.code));
|
|
/** Erkennungsmerkmale des Baurechts (`core/src/plan/extras.rs`). */
|
|
const SITE_CLS = { parcel: "site-parcel", allowed: "site-allowed", violationFill: "#d0342c" } as const;
|
|
const site: SiteRules = {
|
|
parcel: [{ x: -10, y: -10 }, { x: 20, y: -10 }, { x: 20, y: 20 }, { x: -10, y: 20 }],
|
|
defaultSetback: 4,
|
|
};
|
|
const withSite = (s: SiteRules | undefined): Project => ({ ...sampleProject, siteRules: s });
|
|
const prims = (p: Project, floorId: string) => generatePlan(p, floorId, ALL).primitives;
|
|
|
|
describe("Baurecht im Grundriss", () => {
|
|
it("Parzellengrenze und zulässige Fläche als Linien im EG", () => {
|
|
const ps = prims(withSite(site), "eg");
|
|
expect(ps.filter((q) => q.kind === "line" && q.cls === SITE_CLS.parcel).length).toBe(4);
|
|
expect(ps.filter((q) => q.kind === "line" && q.cls === SITE_CLS.allowed).length).toBe(4);
|
|
expect(ps.some((q) => q.kind === "polygon" && q.fill === SITE_CLS.violationFill)).toBe(false);
|
|
});
|
|
it("Gebäude über dem Grenzabstand → rote Fläche, zuoberst gezeichnet", () => {
|
|
const ps = prims(withSite({ ...site, defaultSetback: 12 }), "eg");
|
|
const last = ps[ps.length - 1];
|
|
expect(last.kind === "polygon" && last.fill === SITE_CLS.violationFill).toBe(true);
|
|
});
|
|
it("nicht im OG, nicht ausgeblendet, nicht ohne Baurecht", () => {
|
|
const has = (ps: ReturnType<typeof prims>) => ps.some((q) => q.kind === "line" && q.cls === SITE_CLS.parcel);
|
|
expect(has(prims(withSite(site), "og"))).toBe(false);
|
|
expect(has(prims(withSite({ ...site, show: false }), "eg"))).toBe(false);
|
|
expect(has(prims(withSite(undefined), "eg"))).toBe(false);
|
|
});
|
|
it("Planbegrenzung umfasst die Parzelle", () => {
|
|
const b = generatePlan(withSite(site), "eg", ALL).bounds;
|
|
expect(b.minX).toBeLessThanOrEqual(-10);
|
|
expect(b.maxY).toBeGreaterThanOrEqual(20);
|
|
});
|
|
});
|