[66] Präsentationsplan: Grundrisse ohne Umgebung; Kern: Ausmass ohne ausgeblendeten Kontext, Baurecht folgt Kategorie Vermessung

This commit is contained in:
Claude committed 2026-11-05 13:01:54 +00:00
1 parent 87bd6081b1
commit 6e97ee87e1
4 files changed
+90 -11

No files matched your search

+6 -4
View File
@@ -790,7 +790,7 @@ pub fn plan_domains_buf(p: &Project, a: &PlanArgs) -> Result<Vec<u8>, String> {
w.group(g);
}
w.group(&violations);
w.bounds = Some(super::extras::plan_bounds(&bounds, &super::extras::extra_bounds(p, &under)));
w.bounds = Some(super::extras::plan_bounds(&bounds, &super::extras::extra_bounds(p, &under, |k| c.shown(k))));
Ok(w.finish())
}
@@ -798,7 +798,9 @@ pub fn plan_domains_buf(p: &Project, a: &PlanArgs) -> Result<Vec<u8>, String> {
/// beim projektglobalen Aufruf (`global`).
fn extras_of(p: &Project, a: &PlanArgs) -> (Vec<(Primitive, u32)>, Vec<Primitive>) {
if a.global {
super::extras::site_and_shadow(p, &a.floor, a.sun_when)
// [66] Baurecht (Parzelle, Baubereich, Verstösse) gehört zur Vermessung: ausgeblendete Kategorie „01" ⇒ ohne.
let site = !(p.flat_categories().iter().any(|c| c.code == super::extras::SITE_CATEGORY) && !a.show.contains(super::extras::SITE_CATEGORY));
super::extras::site_and_shadow(p, &a.floor, a.sun_when, site)
} else {
(Vec::new(), Vec::new())
}
@@ -908,7 +910,7 @@ fn assemble_cached(c: &Ctx, revs: &crate::document::Revs, cc: &mut super::cache:
domains_before(c, &mut d, &mut b)?;
domains_after(c, &mut d);
let (under, violations) = extras_of(c.p, c.a);
let extra = super::extras::extra_bounds(c.p, &under);
let extra = super::extras::extra_bounds(c.p, &under, |k| c.shown(k));
apply_voids(c.p, c.a, &mut d);
let plain = |g: Vec<Primitive>| g.into_iter().map(|q| (q, 0)).collect::<Vec<_>>();
let mut lists = vec![under];
@@ -1247,7 +1249,7 @@ mod tests {
// Ausmass: Domänen und Kontext.
let mut db = Bounds::new();
db.merge(d.bounds.unwrap());
assert_eq!(bounds, Some(super::super::extras::plan_bounds(&db, &super::super::extras::extra_bounds(&p, &[]))));
assert_eq!(bounds, Some(super::super::extras::plan_bounds(&db, &super::super::extras::extra_bounds(&p, &[], |_| true))));
}
#[test]
+40 -4
View File
@@ -132,11 +132,18 @@ fn ring_lines(out: &mut Vec<(Primitive, u32)>, pts: &[Vec2], cls: &str, color: &
/// Unterste Gruppe: Schatten, dann Parzellengrenze (Strich-Punkt) und zulässige Fläche
/// (gestrichelt); mit Strichmuster-Kennung je Primitiv. Dazu die Verstösse (Gebäude-Grundfläche
/// ausserhalb der zulässigen Fläche) für die oberste Gruppe.
pub fn site_and_shadow(p: &Project, floor: &str, when_ms: Option<f64>) -> (Vec<(Primitive, u32)>, Vec<Primitive>) {
/// Kategorie der Vermessung; ist sie im Projekt und ausgeblendet, entfällt das Baurecht im Grundriss ([66]).
pub const SITE_CATEGORY: &str = "01";
/// `site = false`: nur der Schatten, ohne Baurecht.
pub fn site_and_shadow(p: &Project, floor: &str, when_ms: Option<f64>, site: bool) -> (Vec<(Primitive, u32)>, Vec<Primitive>) {
let mut shadow = Vec::new();
sun_shadow(p, floor, when_ms, &mut shadow);
let mut under: Vec<(Primitive, u32)> = shadow.into_iter().map(|q| (q, 0)).collect();
let mut violations = Vec::new();
if !site {
return (under, violations);
}
if let (Some(check), Some(rules)) = (site_check(p, floor), p.site_rules.as_ref()) {
let mut r = 1;
ring_lines(&mut under, &rules.parcel, SITE_PARCEL_CLS, PARCEL_COLOR, 0.35, &PARCEL_DASH, r);
@@ -448,7 +455,9 @@ pub fn sketch_post(on: Option<bool>, scale: f64) -> Option<Post> {
/// Ausmass der Zutaten, die „Einpassen" und Druck ganz zeigen sollen: Schatten und Baurechts-Linien
/// (`extra`) und die ganze Kontext-Schicht (Konturen, Netze, Luftbilder) — Rohwerte für
/// [`plan_bounds`].
pub fn extra_bounds(p: &Project, extra: &[(Primitive, u32)]) -> Bounds {
/// Kontext-Objekte zählen nur, wenn ihre Kategorie gezeigt wird (`shown`, wie `plan_context`; ohne Kategorie
/// immer) — sonst bestimmt ein ausgeblendetes Gelände Zoom und Viewport-Grösse ([66]).
pub fn extra_bounds(p: &Project, extra: &[(Primitive, u32)], shown: impl Fn(&str) -> bool) -> Bounds {
let mut b = Bounds::new();
for (e, _) in extra {
match e {
@@ -465,6 +474,16 @@ pub fn extra_bounds(p: &Project, extra: &[(Primitive, u32)]) -> Bounds {
}
}
for obj in p.context.as_deref().unwrap_or(&[]) {
let code = match obj {
ContextObject::ImportedMesh(m) => m.category_code.as_deref(),
ContextObject::ContourSet(s) => s.category_code.as_deref(),
ContextObject::TerrainMesh(t) => t.category_code.as_deref(),
ContextObject::Image(i) => i.category_code.as_deref(),
ContextObject::Excavation(e) => e.category_code.as_deref(),
};
if code.is_some_and(|k| !shown(k)) {
continue;
}
match obj {
ContextObject::ContourSet(cs) => {
for c in &cs.contours {
@@ -517,6 +536,20 @@ mod tests {
serde_json::from_str(include_str!("../../tests/fixtures/sample_project.json")).unwrap()
}
/// [66] Ausgeblendete Kontext-Kategorien (Höhenlinien) bestimmen das Ausmass nicht mit.
#[test]
fn ausmass_ohne_ausgeblendeten_kontext() {
let mut p = sample();
p.context = Some(vec![serde_json::from_value(serde_json::json!({
"type": "contourSet", "id": "hl", "name": "HL", "categoryCode": "14",
"contours": [{"z": 0.0, "pts": [{"x": -100.0, "y": -100.0}, {"x": 100.0, "y": 100.0}]}]
}))
.unwrap()]);
let on = extra_bounds(&p, &[], |_| true).get().unwrap();
assert_eq!(on, [-100.0, -100.0, 100.0, 100.0]);
assert!(extra_bounds(&p, &[], |k| k != "14").get().is_none());
}
/// [63] Profilverstösse erscheinen im Grundriss (schwächeres Rot); ohne Profil nichts.
#[test]
fn profilverstoesse_im_grundriss() {
@@ -528,12 +561,15 @@ mod tests {
serde_json::from_value(v).unwrap()
};
p.site_rules = Some(rules(serde_json::json!({})));
let n0 = site_and_shadow(&p, &floor, None).1.len();
let n0 = site_and_shadow(&p, &floor, None, true).1.len();
p.site_rules = Some(rules(serde_json::json!({"profileAngle": 10.0, "profileHeight": 0.01})));
let c = crate::site_rules::check_project(&p).unwrap();
assert!(c.profile_exceeded);
let n1 = site_and_shadow(&p, &floor, None).1.len();
let n1 = site_and_shadow(&p, &floor, None, true).1.len();
assert!(n1 > n0, "{n0} {n1}");
// [66] Ohne Vermessung (Kategorie aus) kein Baurecht.
let (under, viol) = site_and_shadow(&p, &floor, None, false);
assert!(under.is_empty() && viol.is_empty());
}
#[test]
+9 -1
View File
@@ -132,6 +132,8 @@ pub struct Request {
/// Gruppe je Ebene (0 Grundrisse, 1 Ansichten, 2 Schnitte), aufsteigend.
pub groups: Vec<u32>,
pub layer_visibility: BTreeMap<String, bool>,
/// Abweichende Sichtbarkeit je Ebene (über `layer_visibility` gelegt), z. B. ohne Gelände in den Obergeschossen.
pub level_visibility: BTreeMap<String, BTreeMap<String, bool>>,
pub detail: DetailLevel,
pub sheet_w: f64,
pub sheet_h: f64,
@@ -149,7 +151,13 @@ pub fn query(p: &Project, text: &str) -> Result<Value, String> {
}
let snap = |level: &str| ViewSnapshot {
active_level_id: level.to_string(),
layer_visibility: req.layer_visibility.clone(),
layer_visibility: {
let mut v = req.layer_visibility.clone();
if let Some(o) = req.level_visibility.get(level) {
v.extend(o.iter().map(|(k, b)| (k.clone(), *b)));
}
v
},
detail: req.detail,
scale_denominator: 100.0,
..Default::default()
+35 -2
View File
@@ -113,6 +113,37 @@ function templateVisibility(project: Project, t: ViewTemplate): Record<string, b
return { ...vis, ...(t.layerVisibility ?? {}) };
}
/** Vermessung und Umgebung im Standard-Ebenenbaum (`01`, `05` mit Unterkategorien Situation/Strasse/Bäume …). */
const SITE_ROOTS = ["01", "05"];
/** Codes der Umgebung: Vermessung/Umgebung samt Unterkategorien und die Kategorien der Kontext-Objekte (Gelände …). */
function siteCodes(project: Project): Set<string> {
const out = new Set<string>();
const walk = (cs: readonly LayerCategory[], inSite: boolean) => {
for (const c of cs) {
const site = inSite || SITE_ROOTS.includes(c.code);
if (site) out.add(c.code);
if (c.children) walk(c.children, site);
}
};
walk(project.layers, false);
for (const c of project.context ?? []) if (c.categoryCode) out.add(c.categoryCode);
return out;
}
/**
* Sichtbarkeit je Ebene: Grundrisse zeigen das Gebäude ohne Umgebung (Kataster, Strassen, Gelände, Höhenlinien —
* dafür gibt es den Situationsplan); sonst bestimmt die Parzelle Grösse und Massstab jedes Geschosses.
* Schnitte/Ansichten behalten das Gelände (Terrainlinie).
*/
function levelVisibility(project: Project, base: Record<string, boolean>, levelId: string): Record<string, boolean> {
const level = project.drawingLevels.find((l) => l.id === levelId);
if (!level || !isFloor(level)) return base;
const out = { ...base };
for (const c of siteCodes(project)) out[c] = false;
return out;
}
/** Die gewählten Ebenen in Blattreihenfolge mit Gruppe (0 Grundrisse, 1 Ansichten, 2 Schnitt). */
function chosenLevels(project: Project, o: PresentationOptions): { id: string; group: number }[] {
const byId = new Map(project.drawingLevels.map((l) => [l.id, l]));
@@ -135,10 +166,12 @@ export function planPresentationSheet(project: Project, o: PresentationOptions):
const { template } = presentationTemplate(project);
const size = sheetSizeMm(o.paper, o.orientation);
const levels = chosenLevels(project, o);
const vis = templateVisibility(project, template);
const text = JSON.stringify({
levels: levels.map((l) => l.id),
groups: levels.map((l) => l.group),
layerVisibility: templateVisibility(project, template),
layerVisibility: vis,
levelVisibility: Object.fromEntries(levels.map((l) => [l.id, levelVisibility(project, vis, l.id)])),
detail: (template.detail ?? "mittel") satisfies DetailLevel,
sheetW: size.w,
sheetH: size.h,
@@ -253,7 +286,7 @@ export function presentationSheetOps(
scaleDenominator: plan.scale,
detail: template.detail ?? "mittel",
activeLevelId: level.id,
layerVisibility: vis,
layerVisibility: levelVisibility(project, vis, level.id),
drawingVisibility: {},
...(template.enabledOverrideRuleIds ? { enabledOverrideRuleIds: [...template.enabledOverrideRuleIds] } : {}),
templateId: template.id,