[63] Baurecht: Parzelle, Grenzabstaende je Kante, Baulinien, Gesamthoehe; zulaessige Flaeche, Pruefung und Darstellung im Grundriss
- analysis/siteRules.ts: zulaessige Flaeche = Parzelle minus Abstandsstreifen je Kante (auch konkav), begrenzt durch Baulinien (Seite des Parzellen-Schwerpunkts); Pruefung von Grundflaeche (Waende aller Geschosse, freie Koerper) und Gesamthoehe - Grundriss (Geschoss naechst +-0.00): Parzellengrenze strichpunktiert, zulaessige Flaeche gestrichelt, Verstoesse rot ueber dem Gebaeude; Planbegrenzung umfasst die Parzelle - Lage-Panel: Parzelle und Baulinien aus der Auswahl, Grenzabstand pauschal und je Kante, Gesamthoehe, Ergebnis - Kennzahlen: Parzellenflaeche aus der Grenze, wenn keine Zahl gesetzt ist; CLI kennzahlen liefert baurecht - Tests Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
18 files changed
+728
-11
No files matched your search
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* `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 { SITE_CLS } from "./generatePlan/siteRules";
|
||||
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));
|
||||
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);
|
||||
});
|
||||
});
|
||||
@@ -73,6 +73,7 @@ import { addCeilingPoche } from "./generatePlan/ceilings";
|
||||
import { subtractVoidsInPlan } from "./voids";
|
||||
import { addContextContours } from "./generatePlan/context";
|
||||
import { addSunShadow } from "./generatePlan/sunShadow";
|
||||
import { addSiteRules, addSiteViolations } from "./generatePlan/siteRules";
|
||||
import { DEFAULT_SCALE_DENOMINATOR } from "../model/dimension";
|
||||
import {
|
||||
addDrawing2D,
|
||||
@@ -352,7 +353,9 @@ export function generatePlan(
|
||||
const primitives: Primitive[] = [];
|
||||
// Schattenstudie zuunterst (projektglobal, nur im Geschoss nächst ±0.00).
|
||||
if (includeGlobal) addSunShadow(primitives, project, floorId);
|
||||
const shadowCount = primitives.length;
|
||||
// Baurecht (Parzelle, zulässige Fläche, Verstösse), ebenfalls zuunterst.
|
||||
if (includeGlobal) addSiteRules(primitives, project, floorId);
|
||||
const underlayCount = primitives.length;
|
||||
// Aktives Geschoss (für die Grundriss-Schnitthöhe der Treppen).
|
||||
const floor = project.drawingLevels.find((z) => z.id === floorId);
|
||||
// Code → Kategorie-Strichstärke (mm), damit die Wand-Umrisslinie aus dem
|
||||
@@ -659,6 +662,9 @@ export function generatePlan(
|
||||
// Abzugskörper (Aussparungen/Durchbrüche): von Wand-/Stützen-/Decken-Poché abziehen.
|
||||
subtractVoidsInPlan(primitives, project, (floor?.baseElevation ?? 0) + (floor?.cutHeight ?? 1.0));
|
||||
|
||||
// Baurechts-Verstösse über allem (Signal, soll nicht unter der Wand-Poché verschwinden).
|
||||
if (includeGlobal) addSiteViolations(primitives, project, floorId);
|
||||
|
||||
if (mono) toMono(primitives);
|
||||
|
||||
// Georeferenzierte Luftbilder als Hintergrund-Ebenen (nur interaktive Ansicht,
|
||||
@@ -679,7 +685,7 @@ export function generatePlan(
|
||||
|
||||
return {
|
||||
primitives,
|
||||
bounds: computeBounds(project, walls, drawings, ceilings, stairs, rooms, roofs, primitives.slice(0, shadowCount)),
|
||||
bounds: computeBounds(project, walls, drawings, ceilings, stairs, rooms, roofs, primitives.slice(0, underlayCount)),
|
||||
backgroundImages,
|
||||
...(underlay.length ? { underlay } : {}),
|
||||
};
|
||||
@@ -1060,7 +1066,7 @@ function computeBounds(
|
||||
stairs: Stair[] = [],
|
||||
rooms: Room[] = [],
|
||||
roofs: Roof[] = [],
|
||||
/** Zusätzlich einzurahmende Flächen (Schattenstudie), damit Druck/Einpassen den ganzen Schatten zeigen. */
|
||||
/** Zusätzlich einzurahmende Primitive (Schatten, Parzelle), damit Druck/Einpassen sie ganz zeigen. */
|
||||
extra: Primitive[] = [],
|
||||
) {
|
||||
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
||||
@@ -1074,7 +1080,10 @@ function computeBounds(
|
||||
}
|
||||
for (const c of ceilings) for (const p of c.outline) acc(p);
|
||||
for (const r of rooms) for (const p of r.boundary) acc(p);
|
||||
for (const e of extra) if (e.kind === "polygon") e.pts.forEach(acc);
|
||||
for (const e of extra) {
|
||||
if (e.kind === "polygon") e.pts.forEach(acc);
|
||||
else if (e.kind === "line") { acc(e.a); acc(e.b); }
|
||||
}
|
||||
// Traufe (inkl. Überstand) statt reinem Umriss, damit ein weit auskragendes
|
||||
// Dach das „Einpassen" korrekt mit einrahmt.
|
||||
for (const roof of roofs) for (const p of roofGeometry(roof, 0).eaves) acc(p);
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
// Baurecht im Grundriss ([63]): Parzellengrenze (strichpunktiert), zulässige Grundfläche
|
||||
// (gestrichelt), beides zuunterst, und Gebäude-Grundfläche ausserhalb davon (rot, halbtransparent,
|
||||
// zuoberst). Nur im Geschoss
|
||||
// nächst ±0.00, wie die Schattenstudie. Rechnung in `analysis/siteRules.ts`.
|
||||
|
||||
import type { Project, Vec2 } from "../../model/types";
|
||||
import { checkSiteRules } from "../../analysis/siteRules";
|
||||
import { withoutHoles } from "../../analysis/sun";
|
||||
import { NO_HATCH, type Primitive } from "./shared";
|
||||
import { groundFloorId } from "./sunShadow";
|
||||
|
||||
/** Erkennungsmerkmale (Linien-Klassen, Füllfarbe) — auch für Tests. */
|
||||
export const SITE_CLS = {
|
||||
parcel: "site-parcel",
|
||||
allowed: "site-allowed",
|
||||
violationFill: "#d0342c",
|
||||
} as const;
|
||||
|
||||
const PARCEL_COLOR = "#1f6f3f";
|
||||
const ALLOWED_COLOR = "#2b5fae";
|
||||
|
||||
function ringLines(out: Primitive[], pts: Vec2[], cls: string, color: string, weightMm: number, dash: number[]): void {
|
||||
for (let i = 0; i < pts.length; i++) {
|
||||
out.push({ kind: "line", a: pts[i], b: pts[(i + 1) % pts.length], cls, weightMm, dash, color });
|
||||
}
|
||||
}
|
||||
|
||||
/** Parzellengrenze und zulässige Fläche (zuunterst gezeichnet). */
|
||||
export function addSiteRules(out: Primitive[], project: Project, floorId: string): void {
|
||||
const rules = project.siteRules;
|
||||
if (!rules || rules.show === false || groundFloorId(project) !== floorId) return;
|
||||
const check = checkSiteRules(project);
|
||||
if (!check) return;
|
||||
// Parzellengrenze: Strich-Punkt; zulässige Fläche: gestrichelt (Papier-mm).
|
||||
ringLines(out, rules.parcel, SITE_CLS.parcel, PARCEL_COLOR, 0.35, [6, 1.5, 0.5, 1.5]);
|
||||
for (const poly of check.allowed) for (const r of poly) ringLines(out, r, SITE_CLS.allowed, ALLOWED_COLOR, 0.25, [2, 1]);
|
||||
}
|
||||
|
||||
/** Gebäude-Grundfläche ausserhalb der zulässigen Fläche (zuoberst, damit sie über der Wand liegt). */
|
||||
export function addSiteViolations(out: Primitive[], project: Project, floorId: string): void {
|
||||
const rules = project.siteRules;
|
||||
if (!rules || rules.show === false || groundFloorId(project) !== floorId) return;
|
||||
for (const poly of checkSiteRules(project)?.violations ?? []) {
|
||||
for (const pts of withoutHoles(poly)) {
|
||||
out.push({ kind: "polygon", pts, fill: SITE_CLS.violationFill, stroke: "none", strokeWidthMm: 0, hatch: NO_HATCH, opacity: 0.45 });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user