[64][59][62][61] Schattenstudie im Grundriss mit Zeitregler, Kennzahlenleiste mit Parzelle und Raumprogramm-Editor
- Project.sunStudy (Zeitpunkt UTC, Schalter): Boden-Schatten zuunterst im Geschoss naechst +-0.00 (plan/generatePlan/sunShadow.ts), Hoefe als Loecher (shadowPolygons liefert Ringe, withoutHoles zerlegt) - Lage-Panel: Schalter, Datum, Merkdaten 21.3./21.6./21.12., Zeitregler in Ortszeit, Sonnenstand - Flaechenbilanz-Panel: Kennzahlenleiste GF/aGF/GV/AZ/UeZ, Parzellenflaeche, Raumprogramm bearbeiten mit Status - checkRoomProgram: leerer Name trifft keine Raeume mehr; Status im Toast uebersetzt - Doc-Kommentar von DrawingLevel wieder am richtigen Interface Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
19 files changed
+702
-18
No files matched your search
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* `generatePlan` — Schattenstudie (`Project.sunStudy`): Boden-Schatten als halbtransparente
|
||||
* Flächen ZUUNTERST im Grundriss des Geschosses nächst ±0.00, sonst nirgends.
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { generatePlan } from "./generatePlan";
|
||||
import { SUN_SHADOW_FILL } from "./generatePlan/sunShadow";
|
||||
import { sampleProject } from "../model/sampleProject";
|
||||
import { flattenCategories } from "../model/types";
|
||||
import type { Project } from "../model/types";
|
||||
|
||||
const ALL = new Set(flattenCategories(sampleProject.layers).map((c) => c.code));
|
||||
|
||||
const withStudy = (when: string, show = true): Project => ({ ...sampleProject, sunStudy: { when, show } });
|
||||
const shadows = (p: Project, floorId: string) =>
|
||||
generatePlan(p, floorId, ALL).primitives.filter((q) => q.kind === "polygon" && q.fill === SUN_SHADOW_FILL);
|
||||
|
||||
describe("Schattenstudie im Grundriss", () => {
|
||||
it("Wintermittag: Schatten im EG, zuunterst gezeichnet", () => {
|
||||
const p = withStudy("2026-12-21T11:00:00Z");
|
||||
expect(shadows(p, "eg").length).toBeGreaterThan(0);
|
||||
const first = generatePlan(p, "eg", ALL).primitives[0];
|
||||
expect(first.kind === "polygon" && first.fill === SUN_SHADOW_FILL).toBe(true);
|
||||
});
|
||||
it("nicht im OG, nicht ausgeschaltet, nicht nachts, nicht ohne Studie", () => {
|
||||
expect(shadows(withStudy("2026-12-21T11:00:00Z"), "og")).toEqual([]);
|
||||
expect(shadows(withStudy("2026-12-21T11:00:00Z", false), "eg")).toEqual([]);
|
||||
expect(shadows(withStudy("2026-12-21T22:00:00Z"), "eg")).toEqual([]);
|
||||
expect(shadows(sampleProject, "eg")).toEqual([]);
|
||||
});
|
||||
it("ungültiges Datum → kein Schatten, kein Absturz", () => {
|
||||
expect(shadows(withStudy("kein Datum"), "eg")).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -72,6 +72,7 @@ import {
|
||||
import { addCeilingPoche } from "./generatePlan/ceilings";
|
||||
import { subtractVoidsInPlan } from "./voids";
|
||||
import { addContextContours } from "./generatePlan/context";
|
||||
import { addSunShadow } from "./generatePlan/sunShadow";
|
||||
import { DEFAULT_SCALE_DENOMINATOR } from "../model/dimension";
|
||||
import {
|
||||
addDrawing2D,
|
||||
@@ -349,6 +350,8 @@ export function generatePlan(
|
||||
compactUnderlay = false,
|
||||
): Plan {
|
||||
const primitives: Primitive[] = [];
|
||||
// Schattenstudie zuunterst (projektglobal, nur im Geschoss nächst ±0.00).
|
||||
if (includeGlobal) addSunShadow(primitives, project, floorId);
|
||||
// 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
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
// Schattenstudie im Grundriss ([64]/[59]): Boden-Schatten zum Zeitpunkt `Project.sunStudy.when`
|
||||
// als halbtransparente Flächen ZUUNTERST, nur im Geschoss nächst ±0.00 (der Schatten liegt auf
|
||||
// z = 0). Rechnung in `analysis/sun.ts`; Löcher (Höfe) werden für das Plan-Primitiv zerlegt.
|
||||
|
||||
import type { Project } from "../../model/types";
|
||||
import { projectLatLon, shadowPolygons, sunPosition, withoutHoles } from "../../analysis/sun";
|
||||
import { NO_HATCH, type Primitive } from "./shared";
|
||||
|
||||
/** Füllfarbe der Schattenflächen (Erkennungsmerkmal in Tests). */
|
||||
export const SUN_SHADOW_FILL = "#3a4a66";
|
||||
const SUN_SHADOW_OPACITY = 0.28;
|
||||
|
||||
/** Geschoss, auf dem der Boden-Schatten erscheint: Basishöhe am nächsten bei 0. */
|
||||
export function groundFloorId(project: Project): string | null {
|
||||
let best: { id: string; d: number } | null = null;
|
||||
for (const l of project.drawingLevels) {
|
||||
if (l.kind !== "floor") continue;
|
||||
const d = Math.abs(l.baseElevation ?? 0);
|
||||
if (!best || d < best.d) best = { id: l.id, d };
|
||||
}
|
||||
return best?.id ?? null;
|
||||
}
|
||||
|
||||
/** Hängt die Schattenflächen an `out` an (nichts ohne aktive Studie, nachts oder auf anderen Geschossen). */
|
||||
export function addSunShadow(out: Primitive[], project: Project, floorId: string): void {
|
||||
const study = project.sunStudy;
|
||||
if (!study?.show || groundFloorId(project) !== floorId) return;
|
||||
const when = new Date(study.when);
|
||||
if (Number.isNaN(when.getTime())) return;
|
||||
const { lat, lon } = projectLatLon(project);
|
||||
for (const poly of shadowPolygons(project, sunPosition(lat, lon, when))) {
|
||||
for (const pts of withoutHoles(poly)) {
|
||||
out.push({
|
||||
kind: "polygon",
|
||||
pts,
|
||||
fill: SUN_SHADOW_FILL,
|
||||
stroke: "none",
|
||||
strokeWidthMm: 0,
|
||||
hatch: NO_HATCH,
|
||||
opacity: SUN_SHADOW_OPACITY,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user