[255] Baurecht-Nachweis: Ausnützung (GFZ/AZ/BMZ/ÜZ/GZ), Höhen und Grenzabstand gegen das Modell als Tabelle (Panel, CSV/PDF, Blatt-Tabelle, CLI)
This commit is contained in:
21 files changed
+690
-15
No files matched your search
@@ -572,7 +572,7 @@ pub fn ivhb(p: &Project, opt: &IvhbOptions) -> Ivhb {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
pub(crate) mod tests {
|
||||
use super::*;
|
||||
|
||||
fn close(a: f64, b: f64) -> bool {
|
||||
@@ -582,7 +582,7 @@ mod tests {
|
||||
/// Einfaches Haus: Achsen 10 × 8 m, Wände 0.3 m, Räume innen 9.7 × 7.7 m.
|
||||
/// EG (HNF 9.7×4 = 38.8, NNF 9.7×1.7 = 16.49, VF 9.7×2 = 19.4), OG (HNF 74.69),
|
||||
/// UG (FF 74.69) unter ±0.00. Geschosshöhe 2.6 m.
|
||||
fn house() -> Project {
|
||||
pub(crate) fn house() -> Project {
|
||||
let json = r#"{
|
||||
"drawingLevels":[
|
||||
{"id":"ug","name":"UG","kind":"floor","visible":true,"locked":false,"baseElevation":-2.6,"floorHeight":2.6},
|
||||
|
||||
@@ -23,6 +23,7 @@ pub mod sun;
|
||||
pub mod tree;
|
||||
pub mod camera;
|
||||
pub mod site_rules;
|
||||
pub mod site_proof;
|
||||
pub mod auto_dimensions;
|
||||
pub mod kennzahlen;
|
||||
pub mod flaechen;
|
||||
|
||||
@@ -2733,6 +2733,30 @@ pub struct SiteRules {
|
||||
#[serde(rename = "maxHeight", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub max_height: Option<f64>,
|
||||
/// Zulässige Fassadenhöhe (m, höchste Wandoberkante über ±0.00) für den Baurecht-Nachweis.
|
||||
#[serde(rename = "maxFacadeHeight", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub max_facade_height: Option<f64>,
|
||||
/// Zulässige Geschossflächenziffer GFZ (IVHB) für den Baurecht-Nachweis.
|
||||
#[serde(rename = "maxGfz", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub max_gfz: Option<f64>,
|
||||
/// Zulässige Ausnützungsziffer AZ (aGF / aGSF) für den Baurecht-Nachweis.
|
||||
#[serde(rename = "maxAz", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub max_az: Option<f64>,
|
||||
/// Zulässige Baumassenziffer BMZ (m³/m²) für den Baurecht-Nachweis.
|
||||
#[serde(rename = "maxBmz", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub max_bmz: Option<f64>,
|
||||
/// Zulässige Überbauungsziffer ÜZ (aGbF / aGSF) für den Baurecht-Nachweis.
|
||||
#[serde(rename = "maxUz", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub max_uz: Option<f64>,
|
||||
/// Mindest-Grünflächenziffer GZ für den Baurecht-Nachweis.
|
||||
#[serde(rename = "minGz", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub min_gz: Option<f64>,
|
||||
/// Parzelle, zulässige Fläche und Verstösse im Grundriss zeigen (Default: ja).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
@@ -5570,6 +5594,9 @@ pub enum LayoutTableSource {
|
||||
/// [209] Kostenschätzung grob (eBKP-H-Hauptgruppen, Zuschläge, Total).
|
||||
#[serde(rename = "costs")]
|
||||
Costs,
|
||||
/// [255] Baurecht-Nachweis (AZ/ÜZ/Höhen: zulässig, Projekt, Reserve, erfüllt).
|
||||
#[serde(rename = "siteProof")]
|
||||
SiteProof,
|
||||
#[serde(other)]
|
||||
#[ts(skip)]
|
||||
Unknown,
|
||||
|
||||
@@ -80,6 +80,11 @@ pub fn run(p: &Project, name: &str, args: &[f64], text: &str) -> Result<String,
|
||||
let opt: flaechen::IvhbOptions = if text.trim().is_empty() { Default::default() } else { serde_json::from_str(text).map_err(|e| format!("ivhb: {e}"))? };
|
||||
json(&flaechen::ivhb(p, &opt))
|
||||
}
|
||||
// [255] Baurecht-Nachweis (Vorgaben der Parzelle gegen Kennzahlen); Text = `IvhbOptions` als JSON.
|
||||
("siteProof", _) => {
|
||||
let opt: flaechen::IvhbOptions = if text.trim().is_empty() { Default::default() } else { serde_json::from_str(text).map_err(|e| format!("siteProof: {e}"))? };
|
||||
json(&crate::site_proof::site_proof(p, &opt))
|
||||
}
|
||||
("programCompare", _) => json(&room_program::compare(p)),
|
||||
("programLayout", _) => {
|
||||
let opt: room_program::LayoutOptions = if text.trim().is_empty() { Default::default() } else { serde_json::from_str(text).map_err(|e| format!("programLayout: {e}"))? };
|
||||
|
||||
@@ -128,6 +128,15 @@ const COSTS: &[Col] = &[
|
||||
c("amount", "sheetTable.col.amount", 1.8, true, true),
|
||||
];
|
||||
|
||||
/// [255] Baurecht-Nachweis.
|
||||
const SITE_PROOF: &[Col] = &[
|
||||
c("item", "siteProof.col.item", 4.6, false, true),
|
||||
c("allowed", "siteProof.col.allowed", 1.4, true, true),
|
||||
c("actual", "siteProof.col.actual", 1.4, true, true),
|
||||
c("reserve", "siteProof.col.reserve", 1.8, true, true),
|
||||
c("ok", "siteProof.col.ok", 1.0, false, true),
|
||||
];
|
||||
|
||||
/// [158] Raumbuch-Spalten, die nur erscheinen, wenn ein Raum eine Dachschräge hat.
|
||||
const SLOPE_COLS: &[&str] = &["heightMin", "heightMean", "areaUnder1", "area1To15"];
|
||||
|
||||
@@ -178,6 +187,18 @@ pub const VALUE_KEYS: &[&str] = &[
|
||||
"costs.row.vat",
|
||||
"costs.row.gross",
|
||||
"costs.lump",
|
||||
"siteProof.ok.yes",
|
||||
"siteProof.ok.no",
|
||||
"siteProof.none",
|
||||
"siteProof.row.gfz",
|
||||
"siteProof.row.az",
|
||||
"siteProof.row.bmz",
|
||||
"siteProof.row.uz",
|
||||
"siteProof.row.gz",
|
||||
"siteProof.row.totalHeight",
|
||||
"siteProof.row.facadeHeight",
|
||||
"siteProof.row.setback",
|
||||
"siteProof.row.profile",
|
||||
];
|
||||
|
||||
pub fn catalog(source: LayoutTableSource) -> &'static [Col] {
|
||||
@@ -189,6 +210,7 @@ pub fn catalog(source: LayoutTableSource) -> &'static [Col] {
|
||||
LayoutTableSource::Earthworks => EARTHWORKS,
|
||||
LayoutTableSource::RoomBook => ROOM_BOOK,
|
||||
LayoutTableSource::Costs => COSTS,
|
||||
LayoutTableSource::SiteProof => SITE_PROOF,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +218,7 @@ pub fn catalog(source: LayoutTableSource) -> &'static [Col] {
|
||||
pub fn catalog_json() -> Value {
|
||||
let one = |s: &[Col]| s.iter().map(|k| json!({"id": k.id, "key": k.key, "numeric": k.numeric, "default": k.default})).collect::<Vec<_>>();
|
||||
json!({
|
||||
"sources": {"openings": one(OPENINGS), "areas": one(AREAS), "rooms": one(ROOMS), "elements": one(ELEMENTS), "earthworks": one(EARTHWORKS), "roomBook": one(ROOM_BOOK), "costs": one(COSTS)},
|
||||
"sources": {"openings": one(OPENINGS), "areas": one(AREAS), "rooms": one(ROOMS), "elements": one(ELEMENTS), "earthworks": one(EARTHWORKS), "roomBook": one(ROOM_BOOK), "costs": one(COSTS), "siteProof": one(SITE_PROOF)},
|
||||
"valueKeys": VALUE_KEYS,
|
||||
})
|
||||
}
|
||||
@@ -333,6 +355,7 @@ fn data_of(p: &Project, t: &LayoutTable, lb: &Labels) -> Data {
|
||||
LayoutTableSource::Earthworks => earthworks_data(p, lb),
|
||||
LayoutTableSource::RoomBook => room_book_data(p, lb),
|
||||
LayoutTableSource::Costs => costs_data(p, lb),
|
||||
LayoutTableSource::SiteProof => site_proof_data(p, lb),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -395,6 +418,27 @@ fn costs_data(p: &Project, lb: &Labels) -> Data {
|
||||
Data { rows, sloped: false, total_last: true }
|
||||
}
|
||||
|
||||
/// [255] Baurecht-Nachweis: eine Zeile je Prüfgrösse; fehlende Vorgabe/Projektwert als „—“. Ohne Angaben aus dem
|
||||
/// Dokument (IVHB-Optionen) rechnet der Nachweis mit Parzellenfläche bzw. Parzellengrenze.
|
||||
fn site_proof_data(p: &Project, lb: &Labels) -> Data {
|
||||
let pr = crate::site_proof::site_proof(p, &Default::default());
|
||||
let dash = || txt(lb.get("siteProof.none"));
|
||||
let val = |v: Option<f64>, d: usize| v.filter(|x| x.is_finite()).map_or_else(dash, |x| num(x, d));
|
||||
let rows = pr
|
||||
.rows
|
||||
.iter()
|
||||
.map(|r| {
|
||||
let ok = match r.ok {
|
||||
Some(true) => txt(lb.get("siteProof.ok.yes")),
|
||||
Some(false) => txt(lb.get("siteProof.ok.no")),
|
||||
None => dash(),
|
||||
};
|
||||
vec![txt(lb.get(&format!("siteProof.row.{}", r.key))), val(r.allowed, r.decimals), val(r.actual, r.decimals), val(r.reserve, r.decimals), ok]
|
||||
})
|
||||
.collect();
|
||||
Data { rows, sloped: false, total_last: false }
|
||||
}
|
||||
|
||||
/// [68] Erdarbeiten je Baugrube (m³ gegen das gewachsene Terrain) mit Summenzeile.
|
||||
fn earthworks_data(p: &Project, lb: &Labels) -> Data {
|
||||
let q = crate::excavation::quantities(p);
|
||||
@@ -830,4 +874,26 @@ mod tests {
|
||||
assert_eq!(crate::area_report::fmt_num(-999.0, 0, true), "-999");
|
||||
assert_eq!(crate::area_report::fmt_num(-1000.0, 0, true), "-1'000");
|
||||
}
|
||||
/// [255] Baurecht-Nachweis als Blatt-Tabelle: ohne Vorgaben überall „—“, mit Vorgabe zulässig/Projekt/Reserve/ja-nein.
|
||||
#[test]
|
||||
fn baurecht_nachweis_tabelle() {
|
||||
let mut t = table("n", None);
|
||||
t.source = LayoutTableSource::SiteProof;
|
||||
let mut p = project(0, vec![t]);
|
||||
p.parcel_area = Some(400.0);
|
||||
let lb = Labels::parse(&json!({"siteProof.none": "—", "siteProof.ok.yes": "ja", "siteProof.ok.no": "nein", "siteProof.row.az": "AZ", "siteProof.row.totalHeight": "Gesamthöhe"}));
|
||||
let r = render(&p, &p.layouts.as_ref().unwrap()[0], &lb);
|
||||
assert_eq!(r[0].total, 8, "7 Ziffern/Höhen + Grenzabstand");
|
||||
let tx = texts(&r[0]);
|
||||
assert!(tx.contains(&"AZ".to_string()) && tx.contains(&"—".to_string()), "{tx:?}");
|
||||
assert!(!tx.contains(&"ja".to_string()) && !tx.contains(&"nein".to_string()), "ohne Vorgaben nichts erfüllt/verletzt: {tx:?}");
|
||||
// Mit Vorgabe AZ 0.001 (überschritten, falls das Projekt Flächen hat) bzw. Höhe 100 m.
|
||||
let mut rules = crate::model::SiteRules::default();
|
||||
rules.max_height = Some(100.0);
|
||||
p.site_rules = Some(rules);
|
||||
let tx = texts(&render(&p, &p.layouts.as_ref().unwrap()[0], &lb)[0]);
|
||||
assert!(tx.contains(&"100.00".to_string()), "{tx:?}");
|
||||
assert_eq!(serde_json::to_value(LayoutTableSource::SiteProof).unwrap(), "siteProof");
|
||||
assert!(catalog_json()["sources"]["siteProof"].as_array().unwrap().len() == 5);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,255 @@
|
||||
//! Baurecht-Nachweis ([255]): die Vorgaben der Parzelle (`Project.siteRules`) gegen die Kennzahlen des Modells
|
||||
//! (IVHB-Ziffern, Höhen, Grundfläche gegen Grenzabstand/Baulinie). Eine Zeile je Prüfgrösse: zulässig · Projekt ·
|
||||
//! Reserve (positiv) bzw. Überschreitung (negativ) · erfüllt. Fehlt die Vorgabe, bleibt `allowed`/`ok` leer (die UI
|
||||
//! zeigt „—“) — nichts wird erfunden. Dazu die Grundlagen (aGSF, GF, aGF, aGbF, Baumasse, Grünfläche) mit Quelle.
|
||||
//! Die Ziffern kommen aus `flaechen::ivhb`, die Prüfung der Grundfläche aus `site_rules::check_project`:
|
||||
//! eine Quelle mit Flächentabelle und Lage-Panel.
|
||||
|
||||
use crate::flaechen::{self, AgfBasis, AgsfSource, IvhbOptions};
|
||||
use crate::model::Project;
|
||||
use crate::site_rules;
|
||||
use serde::Serialize;
|
||||
|
||||
/// Obergrenze (`Max`: Projekt ≤ zulässig) oder Untergrenze (`Min`: Projekt ≥ zulässig).
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum Limit {
|
||||
Max,
|
||||
Min,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ProofRow {
|
||||
/// gfz, az, bmz, uz, gz, totalHeight, facadeHeight, setback, profile.
|
||||
pub key: &'static str,
|
||||
pub limit: Limit,
|
||||
pub allowed: Option<f64>,
|
||||
pub actual: Option<f64>,
|
||||
/// Max: zulässig − Projekt; Min: Projekt − zulässig (negativ = Überschreitung bzw. Unterschreitung).
|
||||
pub reserve: Option<f64>,
|
||||
/// `None`, wenn Vorgabe oder Projektwert fehlt.
|
||||
pub ok: Option<bool>,
|
||||
pub decimals: usize,
|
||||
pub unit: &'static str,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ProofBasis {
|
||||
/// agsf, allowedArea, gf, agf, agbf, baumasse, greenArea.
|
||||
pub key: &'static str,
|
||||
pub value: Option<f64>,
|
||||
pub decimals: usize,
|
||||
pub unit: &'static str,
|
||||
/// Schlüssel der Quelle (UI: `siteProof.src.<source>`).
|
||||
pub source: &'static str,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SiteProof {
|
||||
pub rows: Vec<ProofRow>,
|
||||
pub basis: Vec<ProofBasis>,
|
||||
/// Hinweis-Schlüssel (UI: `siteProof.note.<key>`).
|
||||
pub notes: Vec<&'static str>,
|
||||
/// Mindestens eine Vorgabe ist gesetzt.
|
||||
pub has_limits: bool,
|
||||
/// Alle gesetzten Vorgaben mit Projektwert sind erfüllt; `None` ohne prüfbare Vorgabe.
|
||||
pub all_ok: Option<bool>,
|
||||
}
|
||||
|
||||
/// Vorgabe nur, wenn endlich und > 0 (0/negativ/NaN = nicht gesetzt).
|
||||
fn limit(v: Option<f64>) -> Option<f64> {
|
||||
v.filter(|x| x.is_finite() && *x > 0.0)
|
||||
}
|
||||
|
||||
fn row(key: &'static str, limit: Limit, allowed: Option<f64>, actual: Option<f64>, decimals: usize, unit: &'static str, tol: f64) -> ProofRow {
|
||||
let actual = actual.filter(|a| a.is_finite());
|
||||
let reserve = allowed.zip(actual).map(|(a, x)| if limit == Limit::Max { a - x } else { x - a });
|
||||
let ok = reserve.map(|r| r >= -tol);
|
||||
ProofRow { key, limit, allowed, actual, reserve, ok, decimals, unit }
|
||||
}
|
||||
|
||||
/// Nachweis des Projekts; `opt` wie bei `flaechen::ivhb` (aGSF-Eingabe, Grünfläche, Basis der aGF).
|
||||
pub fn site_proof(p: &Project, opt: &IvhbOptions) -> SiteProof {
|
||||
let v = flaechen::ivhb(p, opt);
|
||||
let rules = p.site_rules.as_ref();
|
||||
let check = site_rules::check_project(p);
|
||||
let mut notes: Vec<&'static str> = vec![];
|
||||
if rules.is_none() {
|
||||
notes.push("noRules");
|
||||
}
|
||||
|
||||
// Gesamthöhe: mit Gelände über dem massgebenden Terrain, sonst über ±0.00 (wie das Lage-Panel).
|
||||
let (top, above_terrain) = match &check {
|
||||
Some(c) => (c.height_above_terrain.or(c.max_top), c.height_above_terrain.is_some()),
|
||||
None => (v.total_height, false),
|
||||
};
|
||||
notes.push(if above_terrain { "heightTerrain" } else { "heightZero" });
|
||||
notes.push("facadeApprox");
|
||||
|
||||
let l = |f: fn(&crate::model::SiteRules) -> Option<f64>| limit(rules.and_then(f));
|
||||
let mut rows = vec![
|
||||
row("gfz", Limit::Max, l(|r| r.max_gfz), v.gfz, 2, "", 1e-6),
|
||||
row("az", Limit::Max, l(|r| r.max_az), v.az, 2, "", 1e-6),
|
||||
row("bmz", Limit::Max, l(|r| r.max_bmz), v.bmz, 2, "m", 1e-6),
|
||||
row("uz", Limit::Max, l(|r| r.max_uz), v.uz, 2, "", 1e-6),
|
||||
row("gz", Limit::Min, l(|r| r.min_gz), v.gz, 2, "", 1e-6),
|
||||
row("totalHeight", Limit::Max, l(|r| r.max_height), top, 2, "m", 1e-6),
|
||||
row("facadeHeight", Limit::Max, l(|r| r.max_facade_height), v.facade_height, 2, "m", 1e-6),
|
||||
];
|
||||
let numeric_limits = rows.iter().any(|r| r.allowed.is_some());
|
||||
// Grenzabstände und Baulinien: erlaubt ist keine Grundfläche ausserhalb der zulässigen Fläche (Splitter < 0.01 m² zählen nicht).
|
||||
rows.push(row("setback", Limit::Max, check.as_ref().map(|_| 0.0), check.as_ref().map(|c| c.violation_area), 2, "m²", 0.01));
|
||||
if rules.is_some_and(|r| r.profile_angle.is_some()) {
|
||||
// Gebäudeprofil: Anzahl Bauteile über dem Profil.
|
||||
rows.push(row("profile", Limit::Max, check.as_ref().map(|_| 0.0), check.as_ref().map(|c| c.profile_violations.len() as f64), 0, "", 0.0));
|
||||
}
|
||||
if !numeric_limits {
|
||||
notes.push("noLimits");
|
||||
}
|
||||
let checked: Vec<bool> = rows.iter().filter_map(|r| r.ok).collect();
|
||||
let all_ok = if checked.is_empty() { None } else { Some(checked.iter().all(|b| *b)) };
|
||||
let has_limits = rows.iter().any(|r| r.allowed.is_some());
|
||||
|
||||
let agsf_src = match v.agsf_source {
|
||||
AgsfSource::Input => "agsfInput",
|
||||
AgsfSource::ParcelArea => "parcelArea",
|
||||
AgsfSource::ParcelRing => "parcelRing",
|
||||
AgsfSource::None => "none",
|
||||
};
|
||||
let agf_src = match v.agf_basis {
|
||||
AgfBasis::Gf => "agfGf",
|
||||
AgfBasis::Ngf => "agfNgf",
|
||||
AgfBasis::Nf => "agfNf",
|
||||
};
|
||||
let basis = vec![
|
||||
ProofBasis { key: "agsf", value: v.agsf, decimals: 2, unit: "m²", source: agsf_src },
|
||||
ProofBasis { key: "allowedArea", value: check.as_ref().map(|c| c.allowed_area), decimals: 2, unit: "m²", source: "setbacks" },
|
||||
ProofBasis { key: "gf", value: Some(v.gf_sum), decimals: 2, unit: "m²", source: "sia416" },
|
||||
ProofBasis { key: "agf", value: Some(v.agf), decimals: 2, unit: "m²", source: agf_src },
|
||||
ProofBasis { key: "agbf", value: Some(v.agbf), decimals: 2, unit: "m²", source: "footprint" },
|
||||
ProofBasis { key: "baumasse", value: Some(v.baumasse), decimals: 1, unit: "m³", source: "volumeAbove" },
|
||||
ProofBasis { key: "greenArea", value: v.green_area, decimals: 2, unit: "m²", source: "greenInput" },
|
||||
];
|
||||
SiteProof { rows, basis, notes, has_limits, all_ok }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::model::SiteRules;
|
||||
use crate::model::Vec2;
|
||||
|
||||
fn v2(x: f64, y: f64) -> Vec2 {
|
||||
Vec2 { x, y }
|
||||
}
|
||||
|
||||
/// Einfaches Haus (siehe `flaechen::tests::house`): 10.3 × 8.3 m Grundfläche, EG + OG oberirdisch.
|
||||
fn project(rules: Option<SiteRules>) -> Project {
|
||||
let mut p = flaechen::tests::house();
|
||||
p.site_rules = rules;
|
||||
p
|
||||
}
|
||||
|
||||
fn rules() -> SiteRules {
|
||||
// Parzelle 20 × 20 m = 400 m² um das Haus (Achsen 0..10 × 0..8), Grenzabstand 1 m.
|
||||
SiteRules { parcel: vec![v2(-5.0, -5.0), v2(15.0, -5.0), v2(15.0, 15.0), v2(-5.0, 15.0)], default_setback: 1.0, ..Default::default() }
|
||||
}
|
||||
|
||||
fn get<'a>(p: &'a SiteProof, k: &str) -> &'a ProofRow {
|
||||
p.rows.iter().find(|r| r.key == k).unwrap()
|
||||
}
|
||||
|
||||
fn close(a: f64, b: f64) -> bool {
|
||||
(a - b).abs() < 1e-4
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ohne_baurecht_keine_vorgaben_keine_erfindung() {
|
||||
let pr = site_proof(&project(None), &IvhbOptions::default());
|
||||
assert!(!pr.has_limits && pr.all_ok.is_none());
|
||||
assert!(pr.rows.iter().all(|r| r.allowed.is_none() && r.ok.is_none() && r.reserve.is_none()));
|
||||
assert!(pr.notes.contains(&"noRules") && pr.notes.contains(&"noLimits"));
|
||||
// Projektwerte der Höhen gibt es trotzdem (kein Gelände → über ±0.00).
|
||||
assert!(close(get(&pr, "totalHeight").actual.unwrap(), 5.2));
|
||||
// Ziffern ohne Parzellenfläche: nicht berechenbar.
|
||||
assert!(get(&pr, "az").actual.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ziffern_reserve_und_ueberschreitung() {
|
||||
let mut r = rules();
|
||||
r.max_az = Some(0.5); // Ist: 2·74.69/400 = 0.373
|
||||
r.max_gfz = Some(0.4); // Ist: 2·85.49/400 = 0.427 → überschritten
|
||||
r.max_uz = Some(0.3); // Ist: 85.49/400 = 0.214
|
||||
r.min_gz = Some(0.5); // keine Grünfläche eingegeben → nicht prüfbar
|
||||
r.max_height = Some(6.0);
|
||||
r.max_facade_height = Some(5.0); // Ist 5.2 → überschritten
|
||||
let o = IvhbOptions { agsf: Some(400.0), ..Default::default() };
|
||||
let pr = site_proof(&project(Some(r)), &o);
|
||||
let az = get(&pr, "az");
|
||||
assert!(close(az.actual.unwrap(), 2.0 * 74.69 / 400.0) && close(az.reserve.unwrap(), 0.5 - 2.0 * 74.69 / 400.0));
|
||||
assert_eq!(az.ok, Some(true));
|
||||
let gfz = get(&pr, "gfz");
|
||||
assert_eq!(gfz.ok, Some(false));
|
||||
assert!(close(gfz.reserve.unwrap(), 0.4 - 2.0 * 85.49 / 400.0));
|
||||
assert_eq!(get(&pr, "uz").ok, Some(true));
|
||||
assert_eq!(get(&pr, "gz").ok, None, "Untergrenze ohne Grünfläche ist nicht prüfbar");
|
||||
assert_eq!(get(&pr, "bmz").allowed, None);
|
||||
assert_eq!(get(&pr, "totalHeight").ok, Some(true));
|
||||
let fh = get(&pr, "facadeHeight");
|
||||
assert_eq!(fh.ok, Some(false));
|
||||
assert!(close(fh.reserve.unwrap(), -0.2));
|
||||
assert_eq!(pr.all_ok, Some(false));
|
||||
assert!(pr.has_limits && !pr.notes.contains(&"noLimits"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn untergrenze_gruenflaeche_und_grundlagen() {
|
||||
let mut r = rules();
|
||||
r.min_gz = Some(0.3);
|
||||
let o = IvhbOptions { agsf: Some(400.0), green_area: Some(160.0), ..Default::default() };
|
||||
let pr = site_proof(&project(Some(r)), &o);
|
||||
let gz = get(&pr, "gz");
|
||||
assert!(close(gz.actual.unwrap(), 0.4) && close(gz.reserve.unwrap(), 0.1));
|
||||
assert_eq!(gz.ok, Some(true));
|
||||
let b = |k: &str| pr.basis.iter().find(|b| b.key == k).unwrap();
|
||||
assert!(close(b("agsf").value.unwrap(), 400.0) && b("agsf").source == "agsfInput");
|
||||
assert!(close(b("gf").value.unwrap(), 2.0 * 85.49) && b("gf").source == "sia416");
|
||||
assert!(close(b("agf").value.unwrap(), 2.0 * 74.69) && b("agf").source == "agfNgf");
|
||||
assert!(close(b("agbf").value.unwrap(), 85.49));
|
||||
assert!(close(b("greenArea").value.unwrap(), 160.0));
|
||||
// Zulässige Fläche: 18 × 18 m nach 1 m Grenzabstand.
|
||||
assert!(close(b("allowedArea").value.unwrap(), 18.0 * 18.0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn grenzabstand_wird_geprueft() {
|
||||
// Abstand 6 m: zulässig ist nur noch 8 × 8 m, das Haus (10.3 × 8.3) ragt hinaus.
|
||||
let mut r = rules();
|
||||
r.default_setback = 6.0;
|
||||
let pr = site_proof(&project(Some(r)), &IvhbOptions::default());
|
||||
let s = get(&pr, "setback");
|
||||
assert_eq!(s.ok, Some(false));
|
||||
assert!(s.actual.unwrap() > 1.0 && s.reserve.unwrap() < 0.0);
|
||||
// Abstand 1 m: alles innerhalb.
|
||||
let pr = site_proof(&project(Some(rules())), &IvhbOptions::default());
|
||||
assert_eq!(get(&pr, "setback").ok, Some(true));
|
||||
assert_eq!(get(&pr, "setback").allowed, Some(0.0));
|
||||
assert_eq!(pr.all_ok, Some(true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unsinn_wird_nicht_zur_vorgabe() {
|
||||
let mut r = rules();
|
||||
r.max_az = Some(f64::NAN);
|
||||
r.max_gfz = Some(-1.0);
|
||||
r.max_uz = Some(0.0);
|
||||
let pr = site_proof(&project(Some(r)), &IvhbOptions { agsf: Some(400.0), ..Default::default() });
|
||||
for k in ["az", "gfz", "uz"] {
|
||||
assert!(get(&pr, k).allowed.is_none(), "{k}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user