- 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
45 lines
2.2 KiB
TypeScript
45 lines
2.2 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 { 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);
|
|
});
|
|
});
|