2D: Höhenkoten-Werkzeug + Masskette bleibt gerade + Punkt-Notation
Neues Werkzeug "Höhenkote" (SIA 400 B.5.4, Figur 18): Dreieck-Symbol +
Höhenwert an einem Punkt. Vier Varianten (OK/UK × fertig/roh) bestimmen
Dreieck-Richtung und Füllung, per Option umschaltbar. Die Norm ordnet
Zahlen UNTERHALB einer Masslinie explizit Höhenmassen zu — das war der
eigentliche Grund, warum ein separater Typ statt einer Bemassungs-Variante
nötig war.
Bemassungs-Korrektur: eine Masskette bleibt beim Zeichnen immer eine
GERADE Linie (Klicks ab dem dritten Punkt werden auf die durch Punkt 1/2
festgelegte Gerade projiziert), auch wenn die Bedienung wie eine Polylinie
funktioniert — vorher konnte man versehentlich einen Zickzack-Pfad
erzeugen.
Ausserdem: Masszahlen nutzen jetzt Punkt- statt Komma-Notation ("3.96"
statt "3,96") — die tatsächlich gezeichneten Beispiele in der Norm
(Figur 13/14/18) verwenden durchgängig den Punkt, nicht das Komma aus der
abstrakten B.5.2-Beispielliste.
This commit is contained in:
1 parent
4c7fc99eb8
commit
2dc57d01a5
21 files changed
+433
-19
No files matched your search
@@ -732,7 +732,8 @@ function computeBounds(
|
||||
} else if (g.shape === "dimension") {
|
||||
acc(g.a);
|
||||
acc(g.b);
|
||||
} else if (g.shape === "text") acc(g.at);
|
||||
} else if (g.shape === "kote") acc(g.at);
|
||||
else if (g.shape === "text") acc(g.at);
|
||||
else if (g.shape === "image") { acc(g.min); acc(g.max); }
|
||||
}
|
||||
// GESAMTE Kontext-Schicht (Konturen, importierte Gebäude/Terrain, Luftbild)
|
||||
|
||||
@@ -146,7 +146,7 @@ describe("addDrawing2D — dimension (SIA 400 B.5.3)", () => {
|
||||
expect(thick).toBeCloseTo(thin * 2, 6);
|
||||
});
|
||||
|
||||
it("Masszahl entspricht dist(a,b) mit Komma-Dezimaltrennzeichen (SIA 400 B.5.2)", () => {
|
||||
it("Masszahl entspricht dist(a,b), 2 Dezimalstellen (SIA 400 Figur 13/14: Punkt-Notation)", () => {
|
||||
const d: Drawing2D = {
|
||||
id: "dim2",
|
||||
type: "drawing2d",
|
||||
@@ -158,7 +158,7 @@ describe("addDrawing2D — dimension (SIA 400 B.5.3)", () => {
|
||||
addDrawing2D(out, project(), d, false, lwByCode, colorByCode, catByCode);
|
||||
const text = out.find((p) => p.kind === "drawingText");
|
||||
expect(text).toBeDefined();
|
||||
if (text?.kind === "drawingText") expect(text.text).toBe("5,00");
|
||||
if (text?.kind === "drawingText") expect(text.text).toBe("5.00");
|
||||
});
|
||||
|
||||
it("entartete Strecke (a===b) erzeugt keine Primitive", () => {
|
||||
@@ -174,3 +174,60 @@ describe("addDrawing2D — dimension (SIA 400 B.5.3)", () => {
|
||||
expect(out.length).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("addDrawing2D — kote (SIA 400 B.5.4)", () => {
|
||||
it("OK fertig: hohles Dreieck (Spitze nach unten) + formatierte Zahl mit +", () => {
|
||||
const d: Drawing2D = {
|
||||
id: "k1",
|
||||
type: "drawing2d",
|
||||
levelId: "eg",
|
||||
categoryCode: "20",
|
||||
geom: { shape: "kote", at: { x: 0, y: 0 }, value: 3.25, kind: "okFertig", rotation: 0 },
|
||||
};
|
||||
const out: Primitive[] = [];
|
||||
addDrawing2D(out, project(), d, false, lwByCode, colorByCode, catByCode);
|
||||
const poly = out.find((p) => p.kind === "polygon");
|
||||
const text = out.find((p) => p.kind === "drawingText");
|
||||
expect(poly).toBeDefined();
|
||||
expect(text).toBeDefined();
|
||||
if (poly?.kind === "polygon") {
|
||||
expect(poly.fill).toBe("none"); // fertig = hohl
|
||||
expect(poly.pts[0]).toEqual({ x: 0, y: 0 }); // Spitze = at
|
||||
expect(poly.pts[1].y).toBeGreaterThan(0); // OK: Basis oberhalb der Spitze
|
||||
}
|
||||
if (text?.kind === "drawingText") expect(text.text).toBe("+3.25");
|
||||
});
|
||||
|
||||
it("UK roh: gefülltes Dreieck (Spitze nach oben), Basis unterhalb", () => {
|
||||
const d: Drawing2D = {
|
||||
id: "k2",
|
||||
type: "drawing2d",
|
||||
levelId: "eg",
|
||||
categoryCode: "20",
|
||||
geom: { shape: "kote", at: { x: 0, y: 0 }, value: -0.1, kind: "ukRoh", rotation: 0 },
|
||||
};
|
||||
const out: Primitive[] = [];
|
||||
addDrawing2D(out, project(), d, false, lwByCode, colorByCode, catByCode);
|
||||
const poly = out.find((p) => p.kind === "polygon");
|
||||
const text = out.find((p) => p.kind === "drawingText");
|
||||
if (poly?.kind === "polygon") {
|
||||
expect(poly.fill).not.toBe("none"); // roh = gefüllt
|
||||
expect(poly.pts[1].y).toBeLessThan(0); // UK: Basis unterhalb der Spitze
|
||||
}
|
||||
if (text?.kind === "drawingText") expect(text.text).toBe("-0.10");
|
||||
});
|
||||
|
||||
it("Wert 0 wird als ±0.00 formatiert", () => {
|
||||
const d: Drawing2D = {
|
||||
id: "k3",
|
||||
type: "drawing2d",
|
||||
levelId: "eg",
|
||||
categoryCode: "20",
|
||||
geom: { shape: "kote", at: { x: 0, y: 0 }, value: 0, kind: "okFertig", rotation: 0 },
|
||||
};
|
||||
const out: Primitive[] = [];
|
||||
addDrawing2D(out, project(), d, false, lwByCode, colorByCode, catByCode);
|
||||
const text = out.find((p) => p.kind === "drawingText");
|
||||
if (text?.kind === "drawingText") expect(text.text).toBe("±0.00");
|
||||
});
|
||||
});
|
||||
@@ -25,9 +25,21 @@ const DIM_OVERSHOOT_M = 0.05; // Überstand der Masshilfslinie über die Masslin
|
||||
const DIM_TICK_LEN_M = 0.15; // Länge des Massstrichs (Diagonale an den Masslinien-Enden)
|
||||
const DIM_TEXT_HEIGHT_M = 0.2; // Schrifthöhe der Masszahl
|
||||
|
||||
/** Formatiert eine Länge (Meter) als Masszahl: 2 Dezimalstellen, Komma (SIA 400 B.5.2, „2,75"). */
|
||||
/** Formatiert eine Länge (Meter) als Masszahl: 2 Dezimalstellen (SIA 400 B.5.2/B.5.4, „3.25"/„518.60"). */
|
||||
function formatDimLabel(m: number): string {
|
||||
return m.toFixed(2).replace(".", ",");
|
||||
return m.toFixed(2);
|
||||
}
|
||||
|
||||
// ── Höhenkote (SIA 400 B.5.4) ────────────────────────────────────────────────
|
||||
const KOTE_TRI_SIZE_M = 0.15; // Dreieck-Grösse (Spitze bis Basis)
|
||||
const KOTE_TRI_HALF_W_M = KOTE_TRI_SIZE_M * 0.6;
|
||||
const KOTE_TEXT_HEIGHT_M = 0.2;
|
||||
const KOTE_TEXT_GAP_M = 0.08; // Abstand Dreieck-Basis → Zahl
|
||||
|
||||
/** Formatiert einen Höhenwert (SIA 400 B.5.4, Figur 18): „+3.25" · „±0.00" · „-0.10". */
|
||||
function formatKoteLabel(value: number): string {
|
||||
if (Math.abs(value) < 1e-6) return "±0.00";
|
||||
return (value > 0 ? "+" : "") + value.toFixed(2);
|
||||
}
|
||||
|
||||
export function addDrawing2D(
|
||||
@@ -231,6 +243,38 @@ export function addDrawing2D(
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "kote": {
|
||||
// SIA 400 B.5.4/Figur 18: OK = Spitze nach unten, UK = Spitze nach oben;
|
||||
// fertig = Kontur (hohl), roh = voll gefüllt. `at` ist die Spitze.
|
||||
const up = g.kind === "okFertig" || g.kind === "okRoh" ? 1 : -1;
|
||||
const filled = g.kind === "okRoh" || g.kind === "ukRoh";
|
||||
const pts: Vec2[] = [
|
||||
g.at,
|
||||
{ x: g.at.x - KOTE_TRI_HALF_W_M, y: g.at.y + up * KOTE_TRI_SIZE_M },
|
||||
{ x: g.at.x + KOTE_TRI_HALF_W_M, y: g.at.y + up * KOTE_TRI_SIZE_M },
|
||||
];
|
||||
out.push({
|
||||
kind: "polygon",
|
||||
pts,
|
||||
fill: filled ? color : "none",
|
||||
stroke: color,
|
||||
strokeWidthMm: weightMm,
|
||||
hatch: NO_HATCH,
|
||||
greyed,
|
||||
drawingId: d.id,
|
||||
});
|
||||
out.push({
|
||||
kind: "drawingText",
|
||||
at: { x: g.at.x + KOTE_TRI_HALF_W_M + KOTE_TEXT_GAP_M, y: g.at.y + up * KOTE_TRI_SIZE_M * 0.5 },
|
||||
text: formatKoteLabel(g.value),
|
||||
heightM: KOTE_TEXT_HEIGHT_M,
|
||||
angle: 0,
|
||||
color,
|
||||
greyed,
|
||||
drawingId: d.id,
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "text":
|
||||
out.push({
|
||||
kind: "drawingText",
|
||||
|
||||
Reference in new issue
Block a user