@kensnzk/koyu 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +2 -2
- package/README.md +3 -3
- package/dist/cli.js +156 -81
- package/dist/cli.js.map +1 -1
- package/dist/core/derive.d.ts +259 -0
- package/dist/core/derive.d.ts.map +1 -0
- package/dist/core/derive.js +570 -0
- package/dist/core/derive.js.map +1 -0
- package/dist/{check.d.ts → core/diagnose.d.ts} +11 -12
- package/dist/core/diagnose.d.ts.map +1 -0
- package/dist/{check.js → core/diagnose.js} +232 -221
- package/dist/core/diagnose.js.map +1 -0
- package/dist/core/diff.d.ts.map +1 -0
- package/dist/{diff.js → core/diff.js} +84 -41
- package/dist/core/diff.js.map +1 -0
- package/dist/{fabric.d.ts → core/fabric.d.ts} +4 -0
- package/dist/core/fabric.d.ts.map +1 -0
- package/dist/{fabric.js → core/fabric.js} +4 -3
- package/dist/core/fabric.js.map +1 -0
- package/dist/{graph.d.ts → core/graph.d.ts} +1 -3
- package/dist/core/graph.d.ts.map +1 -0
- package/dist/{graph.js → core/graph.js} +43 -51
- package/dist/core/graph.js.map +1 -0
- package/dist/core/light.d.ts +24 -0
- package/dist/core/light.d.ts.map +1 -0
- package/dist/{light.js → core/light.js} +15 -10
- package/dist/core/light.js.map +1 -0
- package/dist/{model.d.ts → core/model.d.ts} +124 -13
- package/dist/core/model.d.ts.map +1 -0
- package/dist/{model.js → core/model.js} +186 -49
- package/dist/core/model.js.map +1 -0
- package/dist/core/parse.d.ts.map +1 -0
- package/dist/{parse.js → core/parse.js} +528 -116
- package/dist/core/parse.js.map +1 -0
- package/dist/{poly.d.ts → core/poly.d.ts} +3 -2
- package/dist/core/poly.d.ts.map +1 -0
- package/dist/{poly.js → core/poly.js} +8 -9
- package/dist/core/poly.js.map +1 -0
- package/dist/core/site.d.ts.map +1 -0
- package/dist/core/site.js.map +1 -0
- package/dist/core/tolerance.d.ts +26 -0
- package/dist/core/tolerance.d.ts.map +1 -0
- package/dist/core/tolerance.js +48 -0
- package/dist/core/tolerance.js.map +1 -0
- package/dist/{vertical.d.ts → core/vertical.d.ts} +41 -12
- package/dist/core/vertical.d.ts.map +1 -0
- package/dist/{vertical.js → core/vertical.js} +45 -104
- package/dist/core/vertical.js.map +1 -0
- package/dist/core/vocabulary.d.ts +40 -0
- package/dist/core/vocabulary.d.ts.map +1 -0
- package/dist/core/vocabulary.js +164 -0
- package/dist/core/vocabulary.js.map +1 -0
- package/dist/{axo.d.ts → draw/axo.d.ts} +1 -1
- package/dist/draw/axo.d.ts.map +1 -0
- package/dist/{axo.js → draw/axo.js} +53 -81
- package/dist/draw/axo.js.map +1 -0
- package/dist/draw/index.d.ts +3 -0
- package/dist/draw/index.d.ts.map +1 -0
- package/dist/draw/index.js +11 -0
- package/dist/draw/index.js.map +1 -0
- package/dist/draw/plan.d.ts +10 -0
- package/dist/draw/plan.d.ts.map +1 -0
- package/dist/draw/plan.js +284 -0
- package/dist/draw/plan.js.map +1 -0
- package/dist/index.d.ts +15 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +49 -12
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +71 -40
- package/dist/mcp.js.map +1 -1
- package/dist/parse-file.d.ts +1 -1
- package/dist/parse-file.d.ts.map +1 -1
- package/dist/parse-file.js +1 -1
- package/dist/parse-file.js.map +1 -1
- package/dist/validate/access.d.ts +6 -0
- package/dist/validate/access.d.ts.map +1 -0
- package/dist/validate/access.js +238 -0
- package/dist/validate/access.js.map +1 -0
- package/dist/validate/envelope.d.ts +4 -0
- package/dist/validate/envelope.d.ts.map +1 -0
- package/dist/validate/envelope.js +55 -0
- package/dist/validate/envelope.js.map +1 -0
- package/dist/validate/index.d.ts +60 -0
- package/dist/validate/index.d.ts.map +1 -0
- package/dist/validate/index.js +77 -0
- package/dist/validate/index.js.map +1 -0
- package/dist/validate/light.d.ts +6 -0
- package/dist/validate/light.d.ts.map +1 -0
- package/dist/validate/light.js +28 -0
- package/dist/validate/light.js.map +1 -0
- package/dist/validate/runs.d.ts +16 -0
- package/dist/validate/runs.d.ts.map +1 -0
- package/dist/validate/runs.js +60 -0
- package/dist/validate/runs.js.map +1 -0
- package/dist/validate/site.d.ts +6 -0
- package/dist/validate/site.d.ts.map +1 -0
- package/dist/validate/site.js +63 -0
- package/dist/validate/site.js.map +1 -0
- package/editors/vscode/.vscodeignore +2 -0
- package/editors/vscode/README.md +28 -0
- package/editors/vscode/extension.js +150 -0
- package/editors/vscode/language-configuration.json +19 -0
- package/editors/vscode/package.json +57 -0
- package/editors/vscode/syntaxes/koyu.tmLanguage.json +226 -0
- package/examples/basement/main.muro +1 -1
- package/examples/complex/main.muro +1 -1
- package/examples/house/main.muro +2 -2
- package/examples/house.muro +2 -2
- package/examples/mansion.muro +2 -2
- package/examples/office.muro +2 -2
- package/examples/steps/01-one-room.muro +1 -1
- package/examples/steps/02-two-rooms.muro +1 -1
- package/examples/steps/03-door.muro +1 -1
- package/examples/steps/04-exterior.muro +1 -1
- package/examples/steps/05-two-storeys.muro +1 -1
- package/examples/steps/06-finished.muro +2 -2
- package/examples/tower/main.muro +1 -1
- package/examples/twin/main.muro +2 -2
- package/examples/two-rooms.canonical.json +4 -2
- package/examples/two-rooms.muro +2 -2
- package/package.json +16 -1
- package/spec/README.md +28 -0
- package/spec/canonical-json.md +98 -0
- package/spec/composition.md +121 -0
- package/spec/derivation.md +393 -0
- package/spec/en/README.md +30 -0
- package/spec/en/canonical-json.md +101 -0
- package/spec/en/composition.md +121 -0
- package/spec/en/derivation.md +393 -0
- package/spec/en/language.md +164 -0
- package/spec/en/notation-v0.md +145 -0
- package/spec/en/scope.md +229 -0
- package/spec/en/semantics.md +132 -0
- package/spec/en/tools.md +108 -0
- package/spec/en/validation.md +79 -0
- package/spec/en/vocabulary.md +103 -0
- package/spec/language.md +163 -0
- package/spec/notation-v0.md +184 -0
- package/spec/scope.md +229 -0
- package/spec/semantics.md +130 -0
- package/spec/tools.md +106 -0
- package/spec/validation.md +79 -0
- package/spec/vocabulary.md +114 -0
- package/src/cli.ts +165 -80
- package/src/core/derive.ts +852 -0
- package/src/{check.ts → core/diagnose.ts} +260 -229
- package/src/{diff.ts → core/diff.ts} +84 -40
- package/src/{fabric.ts → core/fabric.ts} +4 -3
- package/src/{graph.ts → core/graph.ts} +47 -60
- package/src/core/light.ts +69 -0
- package/src/{model.ts → core/model.ts} +228 -51
- package/src/{parse.ts → core/parse.ts} +584 -116
- package/src/{poly.ts → core/poly.ts} +8 -9
- package/src/core/tolerance.ts +55 -0
- package/src/{vertical.ts → core/vertical.ts} +65 -115
- package/src/core/vocabulary.ts +197 -0
- package/src/{axo.ts → draw/axo.ts} +51 -94
- package/src/draw/index.ts +11 -0
- package/src/draw/plan.ts +344 -0
- package/src/index.ts +181 -35
- package/src/mcp.ts +76 -40
- package/src/parse-file.ts +2 -2
- package/src/validate/access.ts +279 -0
- package/src/validate/envelope.ts +59 -0
- package/src/validate/index.ts +107 -0
- package/src/validate/light.ts +43 -0
- package/src/validate/runs.ts +87 -0
- package/src/validate/site.ts +84 -0
- package/dist/axo.d.ts.map +0 -1
- package/dist/axo.js.map +0 -1
- package/dist/check.d.ts.map +0 -1
- package/dist/check.js.map +0 -1
- package/dist/diff.d.ts.map +0 -1
- package/dist/diff.js.map +0 -1
- package/dist/fabric.d.ts.map +0 -1
- package/dist/fabric.js.map +0 -1
- package/dist/graph.d.ts.map +0 -1
- package/dist/graph.js.map +0 -1
- package/dist/light.d.ts +0 -15
- package/dist/light.d.ts.map +0 -1
- package/dist/light.js.map +0 -1
- package/dist/model.d.ts.map +0 -1
- package/dist/model.js.map +0 -1
- package/dist/parse.d.ts.map +0 -1
- package/dist/parse.js.map +0 -1
- package/dist/plan.d.ts +0 -10
- package/dist/plan.d.ts.map +0 -1
- package/dist/plan.js +0 -354
- package/dist/plan.js.map +0 -1
- package/dist/poly.d.ts.map +0 -1
- package/dist/poly.js.map +0 -1
- package/dist/site.d.ts.map +0 -1
- package/dist/site.js.map +0 -1
- package/dist/vertical.d.ts.map +0 -1
- package/dist/vertical.js.map +0 -1
- package/src/light.ts +0 -63
- package/src/plan.ts +0 -472
- /package/dist/{diff.d.ts → core/diff.d.ts} +0 -0
- /package/dist/{parse.d.ts → core/parse.d.ts} +0 -0
- /package/dist/{site.d.ts → core/site.d.ts} +0 -0
- /package/dist/{site.js → core/site.js} +0 -0
- /package/src/{site.ts → core/site.ts} +0 -0
|
@@ -5,15 +5,17 @@
|
|
|
5
5
|
// 吹抜け (type:void) はこの不変量の宣言的な免除である。
|
|
6
6
|
//
|
|
7
7
|
// 診断契約 (ADR-0016): 一次形式は checkDiagnostics の Diagnostic[] — code / severity /
|
|
8
|
-
//
|
|
8
|
+
// 本文 / 出所 / 対象パス。check は互換層で、従来の文字列 (位置接頭辞つき) を組み立てる。
|
|
9
9
|
// severity はコードの不変属性 — 重さを変えたくなったら新コードを切る。
|
|
10
|
-
import { placeBand, placeOpening, planOverlap, segmentsFor,
|
|
11
|
-
import { heff, isSemiOutdoor, levelsSorted, columnSites, columnsFor, pointInPolygon, rectToPoly,
|
|
12
|
-
import {
|
|
10
|
+
import { placeBand, placeOpening, planOverlap, segmentsFor, spacesOverlap, } from "./graph.js";
|
|
11
|
+
import { heff, isSemiOutdoor, levelsSorted, SUPPORTED_LANGUAGE_VERSIONS, columnSites, openingIdentity, regionOf, columnsFor, pointInPolygon, rectToPoly, srcRef, polygonSelfIntersection, } from "./model.js";
|
|
12
|
+
import { ASSET_ELEM, attrSpec, isNamespaced } from "./vocabulary.js";
|
|
13
13
|
import { runDecls, runIssues } from "./vertical.js";
|
|
14
14
|
/**
|
|
15
15
|
* 診断コードの台帳 — 全コードと規範severity。specの表 (semantics.md §5) とテストで一致を守る。
|
|
16
16
|
* BND07 は欠番 — 「接しているのに境界が無い」警告はADR-0014 (既定境界) で廃止された。
|
|
17
|
+
* HGT03・HGT04・HGT05・RUN04 も欠番 — この四つは「高さがどうか」「縦動線がどうか」ではなく
|
|
18
|
+
* 「形を作るのに必要な情報が書かれていない」という一つの話であり、SUF01-04 へ合流した (ADR-0034)。
|
|
17
19
|
* SYN01 は構文・合成エラー (SourceError) の写し — checkは例外を診断にしない。CLIの check --json だけが写す。
|
|
18
20
|
*/
|
|
19
21
|
export const DIAGNOSTIC_CODES = {
|
|
@@ -53,37 +55,34 @@ export const DIAGNOSTIC_CODES = {
|
|
|
53
55
|
ZON02: "warning", // ゾーンと同パスの空間
|
|
54
56
|
HGT01: "error", // 上階への食い込み (高さ不変量違反)
|
|
55
57
|
HGT02: "error", // 部分吹抜けの被覆不足
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
SUF01: "error", // 天井高が決まらず、天井も屋根も生成できない (ADR-0034)
|
|
59
|
+
SUF02: "error", // レベルが特定できず、立体が一つも生成できない
|
|
60
|
+
SUF03: "warning", // レベルに slab が無く、床が一枚も生成されない
|
|
61
|
+
SUF04: "warning", // 縦動線の宣言に対して形が一つも生成されない
|
|
59
62
|
SIT01: "error", // 敷地形状の重複頂点
|
|
60
63
|
SIT02: "error", // 敷地形状の自己交差
|
|
61
|
-
SIT03: "error", // 建物の敷地形状からのはみ出し
|
|
62
64
|
SIT04: "warning", // 対応するゾーンの無いpolygon
|
|
63
|
-
SIT05: "warning", // 敷地面積の宣言と導出の食い違い
|
|
64
65
|
UID01: "error", // 数字だけのuid (ADR-0015)
|
|
65
66
|
UID02: "error", // 空白を含むuid
|
|
66
67
|
UID03: "error", // uidの重複
|
|
68
|
+
UID04: "error", // 含む対象の中で name が重複 (開口・seg・area・柱の同一性 — ADR-0039)
|
|
67
69
|
ATT01: "error", // 解釈される属性の値が数値でない (ADR-0028)
|
|
68
70
|
ATT02: "error", // 解釈される属性の値が台帳の語彙にない (ADR-0028)
|
|
71
|
+
ATT03: "error", // 台帳に無い属性キー — 名前空間が無い (ADR-0033)
|
|
69
72
|
DAY01: "error", // daylightの値が 0/1 以外 (ADR-0020)
|
|
70
73
|
RUN01: "error", // 一つの空間に縦動線の宣言が複数 (ADR-0021)
|
|
71
74
|
RUN02: "error", // 縦動線の値が上る向き (N/E/S/W) でない
|
|
72
75
|
RUN03: "error", // 縦動線の領域が矩形一つでない / レベルが不明
|
|
73
|
-
RUN04: "warning", // 上にレベルが無く縦動線の形が生成できない
|
|
74
76
|
RUN05: "error", // form の値が不正、または形が決まらない
|
|
75
|
-
RUN06: "warning", // 導出された段の寸法が窮屈 (書かないが検査する)
|
|
76
|
-
RUN07: "warning", // 導出された勾配が宣言・常用域から外れる
|
|
77
|
-
RUN08: "warning", // 縦動線の形はあるが上下を繋ぐ垂直境界が無い
|
|
78
77
|
LIN01: "error", // 描かれた線が二つの空間を分離しない (ADR-0022)
|
|
79
78
|
LIN02: "error", // 垂直境界に描かれた線
|
|
80
79
|
LIN03: "warning", // 描かれた線が何も切っていない
|
|
81
|
-
ENV01: "warning", // 外皮に穴 — 何にも面していない外周 (ADR-0025)
|
|
82
80
|
COL01: "warning", // 柱の宣言に対して立つ柱が0本 (ADR-0023)
|
|
83
81
|
COL02: "warning", // 同じ通りの交点に複数の柱宣言が重なる (先の宣言が勝つ)
|
|
84
82
|
VER01: "error", // koyu 0.1 での既定境界の導出 (ADR-0017)
|
|
85
83
|
VER02: "error", // koyu 0.3以前で採光の推定対象だった型に daylight が無い (ADR-0020)
|
|
86
84
|
VER03: "error", // koyu 0.4以前のファイルに0.5の語 (縦動線・線・柱・地下)
|
|
85
|
+
VER04: "error", // koyu 0.5以前のファイルに1.0の語 (over・drop・集合編集 — ADR-0035/0038)
|
|
87
86
|
SYN01: "error", // 構文・合成エラー (SourceError の写し — check --json のみ)
|
|
88
87
|
};
|
|
89
88
|
const EPS = 0.5;
|
|
@@ -92,51 +91,50 @@ const EPS_SITE = 1;
|
|
|
92
91
|
const VERTICAL = new Set(["stair", "shaft", "void"]);
|
|
93
92
|
/** 0.3以前が採光の対象と推定していた型 (ADR-0020で廃止)。旧版の受理条件の判定にだけ使う — 意味論には効かない */
|
|
94
93
|
const LEGACY_DAYLIT = new Set(["unit", "room", "ldk", "bedroom", "living"]);
|
|
95
|
-
/** 互換層 — 従来の文字列形式。位置を持つ診断は「file:N行目: 本文」に組み立てる */
|
|
96
94
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
95
|
+
* 版の新旧は `SUPPORTED_LANGUAGE_VERSIONS` の並びで決まる。**辞書順で比べてはならない** —
|
|
96
|
+
* 文字列としては "0.5" > "1.0" であり、比較を綴りに任せると新しい版が古い版と判定される
|
|
97
|
+
*/
|
|
98
|
+
const olderThan = (version, ref) => SUPPORTED_LANGUAGE_VERSIONS.indexOf(version) < SUPPORTED_LANGUAGE_VERSIONS.indexOf(ref);
|
|
99
|
+
/**
|
|
100
|
+
* 属性を検査すべき宣言を、出所つきで数え上げる — 母集団は**書かれた宣言**である。
|
|
101
|
+
* 走査は宣言の順 (空間 → ゾーン → 境界 → その開口・seg → 空間の area → 柱)。
|
|
102
102
|
*/
|
|
103
|
-
const ATTR_RULES = {
|
|
104
|
-
space: {
|
|
105
|
-
h: {},
|
|
106
|
-
ceiling: { of: [0, 1] },
|
|
107
|
-
turn: { of: ["R", "L"] },
|
|
108
|
-
riser: {},
|
|
109
|
-
tread: {},
|
|
110
|
-
entry: {},
|
|
111
|
-
landing: {},
|
|
112
|
-
lane: {},
|
|
113
|
-
slope: {},
|
|
114
|
-
road: {},
|
|
115
|
-
},
|
|
116
|
-
zone: { site: { of: [0, 1] }, area: {} },
|
|
117
|
-
// air:1 の境界の天端高 (手すり・腰壁) — 立体が読むので台帳に載る (ADR-0028)
|
|
118
|
-
boundary: { h: {} },
|
|
119
|
-
opening: { style: { of: ["hinged", "sliding", "auto"] } },
|
|
120
|
-
};
|
|
121
|
-
/** 値を検査すべき宣言を、出所つきで数え上げる — 母集団は**書かれた宣言**である */
|
|
122
103
|
function attrSubjects(model) {
|
|
123
104
|
const out = [];
|
|
124
105
|
for (const s of model.spaces.values()) {
|
|
125
|
-
|
|
106
|
+
const at = { line: s.line, file: s.file, path: [s.path] };
|
|
107
|
+
out.push([s.path, { elem: "space", of: s.attrs }, at]);
|
|
108
|
+
for (const a of s.areas) {
|
|
109
|
+
out.push([`area (${s.path})`, { elem: "area", of: a.attrs }, { line: a.line, file: s.file, path: [s.path] }]);
|
|
110
|
+
}
|
|
126
111
|
}
|
|
127
112
|
for (const z of model.zones.values()) {
|
|
128
|
-
out.push([
|
|
113
|
+
out.push([`zone ${z.path}`, { elem: "zone", of: z.attrs }, { line: z.line, file: z.file, path: [z.path] }]);
|
|
129
114
|
}
|
|
130
115
|
for (const b of model.boundaries) {
|
|
131
116
|
const at = { line: b.line, file: b.file, path: [b.a, b.b] };
|
|
132
|
-
out.push([
|
|
117
|
+
out.push([`boundary ${b.a} | ${b.b}`, { elem: "boundary", of: b.attrs }, at]);
|
|
133
118
|
for (const o of b.openings) {
|
|
134
119
|
out.push([
|
|
135
120
|
`${o.kind} (${b.a} | ${b.b})`,
|
|
136
|
-
{
|
|
121
|
+
{ elem: "opening", of: o.attrs },
|
|
137
122
|
{ line: o.line, file: b.file, path: [b.a, b.b] },
|
|
138
123
|
]);
|
|
139
124
|
}
|
|
125
|
+
for (const g of b.segs) {
|
|
126
|
+
out.push([
|
|
127
|
+
`seg (${b.a} | ${b.b})`,
|
|
128
|
+
{ elem: "seg", of: g.attrs },
|
|
129
|
+
{ line: g.line, file: b.file, path: [b.a, b.b] },
|
|
130
|
+
]);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
for (const a of model.assets.values()) {
|
|
134
|
+
out.push([`asset ${a.name}`, { elem: ASSET_ELEM, of: a.attrs }, { line: a.line, file: a.file }]);
|
|
135
|
+
}
|
|
136
|
+
for (const c of model.columns) {
|
|
137
|
+
out.push([`column ${c.size}mm`, { elem: "column", of: c.attrs }, { line: c.line, file: c.file }]);
|
|
140
138
|
}
|
|
141
139
|
return out;
|
|
142
140
|
}
|
|
@@ -191,7 +189,6 @@ export function checkDiagnostics(model) {
|
|
|
191
189
|
checkAttrValues(ctx);
|
|
192
190
|
checkRuns(ctx);
|
|
193
191
|
checkDrawnLines(ctx);
|
|
194
|
-
checkEnvelopeGaps(ctx);
|
|
195
192
|
checkColumns(ctx);
|
|
196
193
|
checkLanguageVersion(ctx);
|
|
197
194
|
checkUids(ctx);
|
|
@@ -199,7 +196,8 @@ export function checkDiagnostics(model) {
|
|
|
199
196
|
checkAreas(ctx);
|
|
200
197
|
checkZones(ctx);
|
|
201
198
|
checkHeights(ctx);
|
|
202
|
-
|
|
199
|
+
checkSpaceSufficiency(ctx);
|
|
200
|
+
checkLevelSufficiency(ctx);
|
|
203
201
|
checkSite(ctx);
|
|
204
202
|
return diags;
|
|
205
203
|
}
|
|
@@ -225,11 +223,11 @@ function checkBoundaryRefs(ctx) {
|
|
|
225
223
|
for (const b of model.boundaries) {
|
|
226
224
|
for (const p of [b.a, b.b]) {
|
|
227
225
|
if (!model.spaces.has(p)) {
|
|
228
|
-
emit("REF01",
|
|
226
|
+
emit("REF01", `References an undefined space: ${p}`, { line: b.line, file: b.file, path: [b.a, b.b] });
|
|
229
227
|
}
|
|
230
228
|
}
|
|
231
229
|
if (b.a === b.b) {
|
|
232
|
-
emit("BND01",
|
|
230
|
+
emit("BND01", `A boundary between a space and itself cannot be written: ${b.a}`, { line: b.line, file: b.file, path: [b.a, b.b] });
|
|
233
231
|
}
|
|
234
232
|
}
|
|
235
233
|
}
|
|
@@ -247,7 +245,7 @@ function checkBoundaryIdentity(ctx) {
|
|
|
247
245
|
const key = `${pair}#${b.edge ?? ""}#${b.drawn ? `${b.drawn.aRef}..${b.drawn.bRef}` : ""}`;
|
|
248
246
|
const prev = seenBoundary.get(key);
|
|
249
247
|
if (prev) {
|
|
250
|
-
emit("BND02",
|
|
248
|
+
emit("BND02", `Duplicate boundary: ${pair}${b.edge ? ` edge:${b.edge}` : ""} (first seen at ${srcRef(prev.line, prev.file)})`, { line: b.line, file: b.file, path: [b.a, b.b], related: [loc(prev.line, prev.file)] });
|
|
251
249
|
}
|
|
252
250
|
else {
|
|
253
251
|
seenBoundary.set(key, b);
|
|
@@ -265,7 +263,7 @@ function checkBoundaryIdentity(ctx) {
|
|
|
265
263
|
// 「どこかで併存している」だけでは直す場所が無い
|
|
266
264
|
const members = model.boundaries.filter((b) => !b.drawn && [b.a, b.b].sort().join(" | ") === pair);
|
|
267
265
|
const first = members.find((b) => !b.edge) ?? members[0];
|
|
268
|
-
emit("BND05",
|
|
266
|
+
emit("BND05", `The same pair of spaces carries both an edge-restricted and an unrestricted boundary (the segments overlap): ${pair}`, {
|
|
269
267
|
...(first ? { line: first.line, file: first.file } : {}),
|
|
270
268
|
path: pair.split(" | "),
|
|
271
269
|
related: members.filter((b) => b !== first).map((b) => loc(b.line, b.file)),
|
|
@@ -279,7 +277,7 @@ function checkLevelDepth(ctx) {
|
|
|
279
277
|
// レベルの重複
|
|
280
278
|
for (let i = 1; i < levels.length; i++) {
|
|
281
279
|
if (Math.abs(levels[i].z - levels[i - 1].z) < EPS) {
|
|
282
|
-
emit("LVL01",
|
|
280
|
+
emit("LVL01", `Levels ${levels[i - 1].name} and ${levels[i].name} have the same z`, {
|
|
283
281
|
line: levels[i].line,
|
|
284
282
|
file: levels[i].file,
|
|
285
283
|
related: [loc(levels[i - 1].line, levels[i - 1].file)],
|
|
@@ -296,7 +294,7 @@ function checkSelfOverlap(ctx) {
|
|
|
296
294
|
for (let j = i + 1; j < s.rects.length; j++) {
|
|
297
295
|
if (planOverlap(s.rects[i], s.rects[j])) {
|
|
298
296
|
// どの組かを言わなければ、三つ重なる空間にバイト同一の診断が三件並ぶ
|
|
299
|
-
emit("GEO01",
|
|
297
|
+
emit("GEO01", `Regions within ${s.path} overlap: ${gridRefText(s, i)} and ${gridRefText(s, j)}`, {
|
|
300
298
|
line: s.line,
|
|
301
299
|
file: s.file,
|
|
302
300
|
path: [s.path],
|
|
@@ -317,7 +315,7 @@ function checkSpaceOverlap(ctx) {
|
|
|
317
315
|
if (a.level !== b.level)
|
|
318
316
|
continue;
|
|
319
317
|
if (spacesOverlap(a, b)) {
|
|
320
|
-
emit("GEO02",
|
|
318
|
+
emit("GEO02", `Space regions overlap: ${a.path} and ${b.path}`, {
|
|
321
319
|
line: a.line,
|
|
322
320
|
file: a.file,
|
|
323
321
|
path: [a.path, b.path],
|
|
@@ -337,7 +335,7 @@ function checkDaylightScope(ctx) {
|
|
|
337
335
|
if (v === undefined)
|
|
338
336
|
continue;
|
|
339
337
|
if (v !== 0 && v !== 1) {
|
|
340
|
-
emit("DAY01", `daylight
|
|
338
|
+
emit("DAY01", `daylight is either 1 (in scope for the daylight check) or 0 (out of scope): ${s.path} carries daylight:${v}`, {
|
|
341
339
|
line: s.line,
|
|
342
340
|
file: s.file,
|
|
343
341
|
path: [s.path],
|
|
@@ -347,31 +345,38 @@ function checkDaylightScope(ctx) {
|
|
|
347
345
|
}
|
|
348
346
|
/** 解釈される属性の値 — ATT01 / ATT02 */
|
|
349
347
|
function checkAttrValues(ctx) {
|
|
350
|
-
const { model, emit
|
|
351
|
-
//
|
|
348
|
+
const { model, emit } = ctx;
|
|
349
|
+
// 属性の三層 (spec/scope.md §7)。**書いたのに解釈されなかったものを、黙って落とさない。**
|
|
350
|
+
//
|
|
351
|
+
// ADR-0028 は値を守った — `site:yes` は敷地の判定を、`h:35OO` は高さ不変量を、
|
|
352
|
+
// それぞれ丸ごと無音にしていた。だが**キー**は無防備のままだった。
|
|
353
|
+
// `heigh:2400` `sit:1` `stiar:N` は、一字違いで同じことを起こしながら緑で通る。
|
|
352
354
|
//
|
|
353
|
-
//
|
|
354
|
-
//
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
355
|
+
// 台帳に無いキーは、名前空間 (`acme.sensor`) を持たなければエラーである (ATT03) —
|
|
356
|
+
// これが「見ていない」と「見て問題がない」を区別できる唯一の形である (ADR-0033)。
|
|
357
|
+
for (const [where, subj, at] of attrSubjects(model)) {
|
|
358
|
+
for (const [key, v] of Object.entries(subj.of)) {
|
|
359
|
+
const spec = attrSpec(subj.elem, key);
|
|
360
|
+
if (!spec) {
|
|
361
|
+
if (isNamespaced(key))
|
|
362
|
+
continue; // 運搬層 — core は中身に一切の意味を与えない
|
|
363
|
+
emit("ATT03", `${where} carries ${key}:, which is not in the ledger (check the spelling, or add a namespace if the value is only carried — e.g. acme.${key}:${v})`, at);
|
|
362
364
|
continue;
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
365
|
+
}
|
|
366
|
+
if (spec.tier === "carry")
|
|
367
|
+
continue; // 運搬層は値を見ない
|
|
368
|
+
if (spec.of) {
|
|
369
|
+
if (!spec.of.includes(v)) {
|
|
370
|
+
emit("ATT02", `${key} on ${where} is one of ${spec.of.join(" / ")}: ${key}:${v}`, at);
|
|
366
371
|
}
|
|
367
372
|
}
|
|
368
|
-
else if (typeof v !== "number" || !(v > 0)) {
|
|
369
|
-
emit("ATT01", `${
|
|
373
|
+
else if (spec.num && (typeof v !== "number" || !(v > 0))) {
|
|
374
|
+
emit("ATT01", `${key} on ${where} is written as a positive number: ${key}:${v}`, at);
|
|
370
375
|
}
|
|
371
376
|
}
|
|
372
377
|
}
|
|
373
378
|
}
|
|
374
|
-
/** 縦動線 — RUN01〜
|
|
379
|
+
/** 縦動線 — RUN01〜RUN03 / RUN05 / SUF04 (形が一意に決まるか。登りやすさは検証の面) */
|
|
375
380
|
function checkRuns(ctx) {
|
|
376
381
|
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
377
382
|
// 縦動線 (ADR-0021): 宣言の妥当性と、**書かれていない導出値**の妥当性。
|
|
@@ -390,7 +395,7 @@ function checkDrawnLines(ctx) {
|
|
|
390
395
|
continue;
|
|
391
396
|
const bAt = { line: b.drawn.line, file: b.file, path: [b.a, b.b] };
|
|
392
397
|
if (VERTICAL.has(b.kind)) {
|
|
393
|
-
emit("LIN02",
|
|
398
|
+
emit("LIN02", `A line cannot be drawn on a vertical boundary (drawing a line is an act of dividing a plan): ${b.a} | ${b.b}`, bAt);
|
|
394
399
|
continue;
|
|
395
400
|
}
|
|
396
401
|
const sa = model.spaces.get(b.a);
|
|
@@ -398,70 +403,23 @@ function checkDrawnLines(ctx) {
|
|
|
398
403
|
if (!sa || !sb)
|
|
399
404
|
continue;
|
|
400
405
|
if (sa.rects.length === 0 && sb.rects.length === 0) {
|
|
401
|
-
emit("LIN01",
|
|
406
|
+
emit("LIN01", `A line cannot be drawn between spaces that have no region: ${b.a} | ${b.b}`, bAt);
|
|
402
407
|
continue;
|
|
403
408
|
}
|
|
404
|
-
//
|
|
405
|
-
//
|
|
406
|
-
//
|
|
407
|
-
|
|
408
|
-
if (!cut) {
|
|
409
|
+
// **帰結は導出のその場で記録されている** (ADR-0041)。ここで計算し直すと、
|
|
410
|
+
// 既に切られた形を相手に窓を組み立てることになり、母集団が食い違う —
|
|
411
|
+
// 実際に切った線に「何も切っていない」と言う経路がそこにあった
|
|
412
|
+
if (b.drawn.effect === "undetermined") {
|
|
409
413
|
emit("LIN01", sa.rects.length > 0 && sb.rects.length > 0
|
|
410
|
-
?
|
|
411
|
-
:
|
|
414
|
+
? `Line ${b.drawn.aRef}..${b.drawn.bRef} does not separate ${b.a} and ${b.b} (draw it so the two allocations fall on opposite sides)`
|
|
415
|
+
: `Line ${b.drawn.aRef}..${b.drawn.bRef} bisects the allocation exactly, so which side to keep is undetermined`, bAt);
|
|
412
416
|
continue;
|
|
413
417
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
emit("LIN03", `線 ${b.drawn.aRef}..${b.drawn.bRef} は何も切っていません (既定の隣接線と同じか、割付の外にあります)`, bAt);
|
|
418
|
+
if (b.drawn.effect === "nothing") {
|
|
419
|
+
emit("LIN03", `Line ${b.drawn.aRef}..${b.drawn.bRef} cuts nothing (it is the same as the default adjacency line, or falls outside the allocation)`, bAt);
|
|
417
420
|
}
|
|
418
421
|
}
|
|
419
422
|
}
|
|
420
|
-
/** 外皮の穴 — ENV01 */
|
|
421
|
-
function checkEnvelopeGaps(ctx) {
|
|
422
|
-
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
423
|
-
// 外皮の穴 (ADR-0025): 既定境界は領域を持たない空間との間には導かれない (ADR-0014) ので、
|
|
424
|
-
// 外部への境界の書き忘れは黙って壁の不在になる。導出された外周のうち、
|
|
425
|
-
// 他の空間とも宣言された境界とも向かい合っていない区間を数える。
|
|
426
|
-
// 外構のタイル (site:1 ゾーンの配下)・外部・半屋外は囲われていないのが正常なので数えない。
|
|
427
|
-
// そして**外皮を書き始めているレベルだけ**を見る — 外部への境界が一本も無い階は
|
|
428
|
-
// 外皮をまだ模型にしていないだけであって、穴が開いているのではない。
|
|
429
|
-
// 「書き始めたなら閉じきる」という整合の検査であって、完全性の要求ではない
|
|
430
|
-
const siteZones = [...model.zones.values()].filter((z) => z.attrs["site"] === 1).map((z) => z.path);
|
|
431
|
-
const envelopedLevels = new Set();
|
|
432
|
-
for (const b of model.boundaries) {
|
|
433
|
-
if (b.derived || VERTICAL.has(b.kind))
|
|
434
|
-
continue;
|
|
435
|
-
const sa = model.spaces.get(b.a);
|
|
436
|
-
const sb = model.spaces.get(b.b);
|
|
437
|
-
if (!sa || !sb)
|
|
438
|
-
continue;
|
|
439
|
-
const outer = sa.rects.length === 0 ? sb : sb.rects.length === 0 ? sa : undefined;
|
|
440
|
-
if (outer?.level)
|
|
441
|
-
envelopedLevels.add(outer.level);
|
|
442
|
-
}
|
|
443
|
-
for (const s of withRect) {
|
|
444
|
-
if (!s.level || !envelopedLevels.has(s.level))
|
|
445
|
-
continue;
|
|
446
|
-
if (s.type === "exterior" || isSemiOutdoor(model, s))
|
|
447
|
-
continue;
|
|
448
|
-
if (siteZones.some((z) => s.path.startsWith(z + "/")))
|
|
449
|
-
continue;
|
|
450
|
-
const gaps = envelopeGaps(model, s);
|
|
451
|
-
if (gaps.length === 0)
|
|
452
|
-
continue;
|
|
453
|
-
// **どの辺かを言う。**合計長だけでは、edge を書き分けている図面で直す辺が特定できない。
|
|
454
|
-
// envelopeGaps は座標つきの線分を返しているので、方角は既に手元にある
|
|
455
|
-
const byDir = new Map();
|
|
456
|
-
for (const g of gaps) {
|
|
457
|
-
const d = g.edgeOfA ?? (g.horizontal ? "N/S" : "E/W");
|
|
458
|
-
byDir.set(d, (byDir.get(d) ?? 0) + segmentLength(g));
|
|
459
|
-
}
|
|
460
|
-
const total = gaps.reduce((a, g) => a + segmentLength(g), 0);
|
|
461
|
-
const where = [...byDir].map(([d, mm]) => `${d} ${Math.round(mm)}mm`).join(" / ");
|
|
462
|
-
emit("ENV01", `外皮に面していない外周があります: ${s.path} — ${where} (合計 ${Math.round(total)}mm・${gaps.length}区間)。外部への境界を書きます`, { line: s.line, file: s.file, path: [s.path] });
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
423
|
/** 柱 — COL01 / COL02 */
|
|
466
424
|
function checkColumns(ctx) {
|
|
467
425
|
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
@@ -495,14 +453,14 @@ function checkColumns(ctx) {
|
|
|
495
453
|
return false;
|
|
496
454
|
return o.levels.some((lv) => columnsFor(model, lv).some((k) => k.decl === oi && sites.has(`${lv}|${k.grid}`)));
|
|
497
455
|
});
|
|
498
|
-
emit("COL02",
|
|
456
|
+
emit("COL02", `This column declaration (${c.levels.join(",")} ${c.size}mm square) stands nowhere because an earlier declaration took the same intersections (at the same intersection the earlier declaration wins)`, { ...at, related: shadow.map((o) => loc(o.line, o.file)) });
|
|
499
457
|
}
|
|
500
458
|
else {
|
|
501
|
-
emit("COL01",
|
|
459
|
+
emit("COL01", `Not one column stands for this declaration (the grid intersections have no floor): ${c.levels.join(",")} ${c.size}mm square`, at);
|
|
502
460
|
}
|
|
503
461
|
}
|
|
504
462
|
}
|
|
505
|
-
/** 言語版の受理条件 — VER01〜
|
|
463
|
+
/** 言語版の受理条件 — VER01〜VER04 */
|
|
506
464
|
function checkLanguageVersion(ctx) {
|
|
507
465
|
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
508
466
|
// 言語版の受理条件 (ADR-0017): 旧版は意味保存の場合のみ受理する。
|
|
@@ -510,7 +468,7 @@ function checkLanguageVersion(ctx) {
|
|
|
510
468
|
if (model.version === "0.1") {
|
|
511
469
|
for (const b of model.boundaries) {
|
|
512
470
|
if (b.derived) {
|
|
513
|
-
emit("VER01", `koyu 0.1
|
|
471
|
+
emit("VER01", `A koyu 0.1 file has a touching pair with no declared boundary: ${b.a} | ${b.b} — in 0.2 a default wall is derived and the meaning changes. Declare the boundary, or raise the version to koyu 0.2`, { path: [b.a, b.b] });
|
|
514
472
|
}
|
|
515
473
|
}
|
|
516
474
|
}
|
|
@@ -520,17 +478,17 @@ function checkLanguageVersion(ctx) {
|
|
|
520
478
|
for (const s of model.spaces.values()) {
|
|
521
479
|
if (!LEGACY_DAYLIT.has(s.type) || s.attrs["daylight"] !== undefined)
|
|
522
480
|
continue;
|
|
523
|
-
emit("VER02", `koyu ${model.version}
|
|
481
|
+
emit("VER02", `A koyu ${model.version} file has a ${s.type} with no daylight: ${s.path} — 0.4 does not infer the daylight scope from the type, so it falls out of the check. Write daylight:1 (in scope) or daylight:0 (out of scope), then raise the version to koyu 0.4`, { line: s.line, file: s.file, path: [s.path] });
|
|
524
482
|
}
|
|
525
483
|
}
|
|
526
484
|
// 0.5 で入った語 (縦動線の宣言・描かれた線・柱・地下) は 0.4 以前の処理系が知らない。
|
|
527
485
|
// 知らない処理系では黙って形が生成されないので、版を上げずに使うのはエラー (ADR-0017 決定3)
|
|
528
|
-
if (model.version
|
|
529
|
-
const older = `koyu ${model.version}
|
|
486
|
+
if (olderThan(model.version, "0.5")) {
|
|
487
|
+
const older = `A koyu ${model.version} file uses a 0.5 word`;
|
|
530
488
|
for (const s of model.spaces.values()) {
|
|
531
489
|
const d = runDecls(s);
|
|
532
490
|
if (d.length > 0) {
|
|
533
|
-
emit("VER03", `${older}: ${s.path}
|
|
491
|
+
emit("VER03", `${older}: ${s.path} carries ${d[0].device}: (a vertical circulation) — raise the version to koyu 0.5`, {
|
|
534
492
|
line: s.line,
|
|
535
493
|
file: s.file,
|
|
536
494
|
path: [s.path],
|
|
@@ -539,7 +497,7 @@ function checkLanguageVersion(ctx) {
|
|
|
539
497
|
}
|
|
540
498
|
for (const b of model.boundaries) {
|
|
541
499
|
if (b.drawn) {
|
|
542
|
-
emit("VER03", `${older}: ${b.a} | ${b.b}
|
|
500
|
+
emit("VER03", `${older}: ${b.a} | ${b.b} carries line (a drawn line) — raise the version to koyu 0.5`, {
|
|
543
501
|
line: b.drawn.line,
|
|
544
502
|
file: b.file,
|
|
545
503
|
path: [b.a, b.b],
|
|
@@ -547,19 +505,36 @@ function checkLanguageVersion(ctx) {
|
|
|
547
505
|
}
|
|
548
506
|
}
|
|
549
507
|
for (const c of model.columns) {
|
|
550
|
-
emit("VER03", `${older}: column
|
|
508
|
+
emit("VER03", `${older}: column — raise the version to koyu 0.5`, { line: c.line, file: c.file });
|
|
551
509
|
}
|
|
552
510
|
for (const l of Object.values(model.levels)) {
|
|
553
511
|
if (l.underground) {
|
|
554
|
-
emit("VER03", `${older}: level ${l.name}
|
|
512
|
+
emit("VER03", `${older}: level ${l.name} carries underground: — raise the version to koyu 0.5`, {
|
|
555
513
|
line: l.line,
|
|
556
514
|
file: l.file,
|
|
557
515
|
});
|
|
558
516
|
}
|
|
559
517
|
}
|
|
560
518
|
}
|
|
519
|
+
// 1.0 で入った語 (上書き `over`・削除 `drop`・`over` 直下の集合編集 `+` `-` `=`) は
|
|
520
|
+
// 0.5 以前の処理系が知らない。知らない処理系ではその行が語として読めず、上書きも削除も
|
|
521
|
+
// 起きない — **黙って別の建物になる**。VER03 と同型の理屈である (ADR-0017 決定3 / ADR-0035)
|
|
522
|
+
if (olderThan(model.version, "1.0")) {
|
|
523
|
+
const older = `A koyu ${model.version} file uses a 1.0 word`;
|
|
524
|
+
for (const e of model.compositionEdits) {
|
|
525
|
+
const what = e.word === "over" ? "a composition override"
|
|
526
|
+
: e.word === "drop" ? "a composition removal"
|
|
527
|
+
: "a set edit under over";
|
|
528
|
+
const paths = e.subject.split(" ").filter((t) => t.startsWith("/"));
|
|
529
|
+
emit("VER04", `${older}: ${[e.word, e.subject].filter(Boolean).join(" ")} (${what}) — raise the version to koyu 1.0`, {
|
|
530
|
+
line: e.line,
|
|
531
|
+
file: e.file,
|
|
532
|
+
...(paths.length > 0 ? { path: paths } : {}),
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
}
|
|
561
536
|
}
|
|
562
|
-
/**
|
|
537
|
+
/** 同一性 — UID01〜UID04 */
|
|
563
538
|
function checkUids(ctx) {
|
|
564
539
|
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
565
540
|
// uid (ADR-0015): 不透明トークン、space/zone横断でモデル全体一意。
|
|
@@ -570,7 +545,7 @@ function checkUids(ctx) {
|
|
|
570
545
|
if (v === undefined)
|
|
571
546
|
return;
|
|
572
547
|
if (typeof v === "number") {
|
|
573
|
-
emit("UID01", `uid
|
|
548
|
+
emit("UID01", `A uid cannot be a token of digits alone: uid:${v} (write something like sp-${v})`, {
|
|
574
549
|
line,
|
|
575
550
|
file,
|
|
576
551
|
path: [path],
|
|
@@ -578,7 +553,7 @@ function checkUids(ctx) {
|
|
|
578
553
|
return;
|
|
579
554
|
}
|
|
580
555
|
if (v === "" || /\s/.test(v)) {
|
|
581
|
-
emit("UID02", `uid
|
|
556
|
+
emit("UID02", `A uid cannot contain whitespace: "${v}"`, { line, file, path: [path] });
|
|
582
557
|
return;
|
|
583
558
|
}
|
|
584
559
|
const arr = uidOwners.get(v) ?? [];
|
|
@@ -591,9 +566,45 @@ function checkUids(ctx) {
|
|
|
591
566
|
collectUid("zone", z.path, z.attrs, z.line, z.file);
|
|
592
567
|
for (const [uid, owners] of uidOwners) {
|
|
593
568
|
if (owners.length > 1) {
|
|
594
|
-
emit("UID03", `uid
|
|
569
|
+
emit("UID03", `Duplicate uid: ${uid} (${owners.map((o) => `${o.kind} ${o.path} — ${srcRef(o.line, o.file)}`).join(", ")})`, { path: owners.map((o) => o.path), related: owners.map((o) => loc(o.line, o.file)) });
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
// 開口・内包物の同一性は「含む対象 + その中で一意な名」から導かれる (spec/scope.md §5)。
|
|
573
|
+
// 名が重複していれば、その同一性は成り立たない — `over ... = door D1` はどちらを指すのか
|
|
574
|
+
// 決められず、`drop column C1` は二本まとめて消してしまう。**推測せずに拒む** (ADR-0039)。
|
|
575
|
+
// 名を書かない要素は同一性を主張していないので、母集団に入らない
|
|
576
|
+
const dupNames = (what, where, items, path) => {
|
|
577
|
+
const byName = new Map();
|
|
578
|
+
for (const it of items) {
|
|
579
|
+
if (it.name === undefined || it.name === "")
|
|
580
|
+
continue;
|
|
581
|
+
const arr = byName.get(it.name) ?? [];
|
|
582
|
+
arr.push(loc(it.line, it.file));
|
|
583
|
+
byName.set(it.name, arr);
|
|
584
|
+
}
|
|
585
|
+
for (const [name, at] of byName) {
|
|
586
|
+
if (at.length < 2)
|
|
587
|
+
continue;
|
|
588
|
+
const last = at[at.length - 1];
|
|
589
|
+
emit("UID04", `Duplicate ${what} name within ${where}: ${name} (${at.map((o) => srcRef(o.line, o.file)).join(", ")}) — the name is what identifies it inside its container`, { line: last.line, file: last.file, ...(path ? { path } : {}), related: at.slice(0, -1) });
|
|
595
590
|
}
|
|
591
|
+
};
|
|
592
|
+
const written = (attrs) => {
|
|
593
|
+
const n = attrs["name"];
|
|
594
|
+
return n === undefined || n === "" ? undefined : String(n);
|
|
595
|
+
};
|
|
596
|
+
for (const b of model.boundaries) {
|
|
597
|
+
const where = `boundary ${b.a} | ${b.b}`;
|
|
598
|
+
const at = b.file !== undefined ? { file: b.file } : {};
|
|
599
|
+
// 開口だけは、アセットから継いだ型の名を主張として数えない (ADR-0039)
|
|
600
|
+
dupNames("opening", where, b.openings.map((o) => ({ name: openingIdentity(model, o), line: o.line, ...at })), [b.a, b.b]);
|
|
601
|
+
dupNames("seg", where, b.segs.map((g) => ({ name: written(g.attrs), line: g.line, ...at })), [b.a, b.b]);
|
|
602
|
+
}
|
|
603
|
+
for (const s of model.spaces.values()) {
|
|
604
|
+
const at = s.file !== undefined ? { file: s.file } : {};
|
|
605
|
+
dupNames("area", `space ${s.path}`, s.areas.map((a) => ({ name: written(a.attrs), line: a.line, ...at })), [s.path]);
|
|
596
606
|
}
|
|
607
|
+
dupNames("column", "the model", model.columns.map((c) => ({ name: written(c.attrs), line: c.line, ...(c.file !== undefined ? { file: c.file } : {}) })));
|
|
597
608
|
}
|
|
598
609
|
/** 境界の妥当性 — VRT / BND03〜06 / OPN / SEG */
|
|
599
610
|
function checkBoundaryValidity(ctx) {
|
|
@@ -614,7 +625,7 @@ function checkBoundaryValidity(ctx) {
|
|
|
614
625
|
continue; // 垂直境界は水平の検査 (線分・開口・seg) を一切受けない
|
|
615
626
|
}
|
|
616
627
|
if (sa.rects.length > 0 && sb.rects.length > 0 && sa.level !== sb.level) {
|
|
617
|
-
emit("BND03",
|
|
628
|
+
emit("BND03", `A wall boundary cannot be written to a space on a different level (vertical takes type:stair/shaft/void): ${b.a} | ${b.b}`, bAt);
|
|
618
629
|
continue; // レベルを跨ぐ壁は成立していない — 線分も開口も問わない
|
|
619
630
|
}
|
|
620
631
|
checkBoundarySegments(ctx, b, sa, sb, bAt);
|
|
@@ -627,30 +638,30 @@ function checkVerticalBoundary(ctx, b, sa, sb, bAt) {
|
|
|
627
638
|
const { emit, levelIndex } = ctx;
|
|
628
639
|
// 垂直境界: 隣り合うレベルの、平面で重なる空間同士にしか張れない
|
|
629
640
|
if (sa.rects.length === 0 || sb.rects.length === 0 || !sa.level || !sb.level) {
|
|
630
|
-
emit("VRT01",
|
|
641
|
+
emit("VRT01", `A ${b.kind} boundary is written between spaces that have both a region and a level`, bAt);
|
|
631
642
|
return; // 前提が崩れているので、以降の判定は意味を持たない
|
|
632
643
|
}
|
|
633
644
|
const ia = levelIndex.get(sa.level);
|
|
634
645
|
const ib = levelIndex.get(sb.level);
|
|
635
646
|
if (ia === undefined || ib === undefined || Math.abs(ia - ib) !== 1) {
|
|
636
|
-
emit("VRT02",
|
|
647
|
+
emit("VRT02", `A ${b.kind} boundary is written between adjacent levels: ${b.a} | ${b.b}`, bAt);
|
|
637
648
|
}
|
|
638
649
|
else if (!spacesOverlap(sa, sb)) {
|
|
639
|
-
emit("VRT03",
|
|
650
|
+
emit("VRT03", `The spaces of a ${b.kind} boundary do not overlap in plan: ${b.a} | ${b.b}`, bAt);
|
|
640
651
|
}
|
|
641
652
|
if (b.kind === "void") {
|
|
642
653
|
const upper = (ia ?? 0) > (ib ?? 0) ? sa : sb;
|
|
643
654
|
if (upper.type !== "void") {
|
|
644
|
-
emit("VRT04", `void
|
|
655
|
+
emit("VRT04", `The space above a void boundary is expected to be type:void: ${upper.path}`, bAt);
|
|
645
656
|
}
|
|
646
657
|
}
|
|
647
658
|
// 咎めているのは字下げされた door / window / seg の行そのものなので、
|
|
648
659
|
// 親の境界宣言ではなくその行を指す。宣言が複数あれば診断も複数出る
|
|
649
660
|
for (const o of b.openings) {
|
|
650
|
-
emit("VRT05",
|
|
661
|
+
emit("VRT05", `A ${o.kind} on a vertical boundary is not interpreted`, { line: o.line, file: b.file, path: [b.a, b.b] });
|
|
651
662
|
}
|
|
652
663
|
for (const g of b.segs) {
|
|
653
|
-
emit("VRT06",
|
|
664
|
+
emit("VRT06", `A seg on a vertical boundary is not interpreted`, { line: g.line, file: b.file, path: [b.a, b.b] });
|
|
654
665
|
}
|
|
655
666
|
}
|
|
656
667
|
/** 水平境界の線分がゼロ — BND04 / BND06 */
|
|
@@ -668,14 +679,14 @@ function checkBoundarySegments(ctx, b, sa, sb, bAt) {
|
|
|
668
679
|
const without = b.edge ? segmentsFor(model, { ...b, edge: undefined }) : [];
|
|
669
680
|
if (without.length > 0) {
|
|
670
681
|
const dirs = [...new Set(without.map((g) => g.edgeOfA))].filter((d) => d !== undefined);
|
|
671
|
-
emit("BND04", `edge:${b.edge}
|
|
682
|
+
emit("BND04", `No shared edge on edge:${b.edge}: ${b.a} | ${b.b} (they actually touch on ${dirs.join(" / ") || "another edge"})`, bAt);
|
|
672
683
|
}
|
|
673
684
|
else {
|
|
674
|
-
emit("BND04",
|
|
685
|
+
emit("BND04", `The spaces do not touch, so no boundary can be derived: ${b.a} | ${b.b}`, bAt);
|
|
675
686
|
}
|
|
676
687
|
}
|
|
677
688
|
if ((sa.rects.length > 0 ? 1 : 0) + (sb.rects.length > 0 ? 1 : 0) === 1 && segs.length === 0) {
|
|
678
|
-
emit("BND06",
|
|
689
|
+
emit("BND06", `No edge remains on the perimeter${b.edge ? ` for edge:${b.edge}` : ""}, so the boundary segment is of zero length: ${b.a} | ${b.b}`, bAt);
|
|
679
690
|
}
|
|
680
691
|
}
|
|
681
692
|
/**
|
|
@@ -687,7 +698,7 @@ function checkOpenings(ctx, b) {
|
|
|
687
698
|
const { model, emit, loc } = ctx;
|
|
688
699
|
if (b.kind === "open" && b.openings.length > 0) {
|
|
689
700
|
for (const o of b.openings) {
|
|
690
|
-
emit("OPN03", `
|
|
701
|
+
emit("OPN03", `A ${o.kind} on an open boundary has no effect on passage (it is always passable)`, {
|
|
691
702
|
line: o.line,
|
|
692
703
|
file: b.file,
|
|
693
704
|
path: [b.a, b.b],
|
|
@@ -714,7 +725,7 @@ function checkOpenings(ctx, b) {
|
|
|
714
725
|
? o.hinge === "W" || o.hinge === "E"
|
|
715
726
|
: o.hinge === "N" || o.hinge === "S";
|
|
716
727
|
if (!okAxis) {
|
|
717
|
-
emit("OPN01", `hinge:${o.hinge}
|
|
728
|
+
emit("OPN01", `hinge:${o.hinge}: ${placed.segment.horizontal ? "a horizontal segment takes W/E" : "a vertical segment takes N/S"}`, { line: o.line, file: b.file, path: [b.a, b.b] });
|
|
718
729
|
}
|
|
719
730
|
}
|
|
720
731
|
}
|
|
@@ -732,7 +743,7 @@ function checkOpenings(ctx, b) {
|
|
|
732
743
|
const q = group[k + 1];
|
|
733
744
|
const need = (p.o.w + q.o.w) / 2;
|
|
734
745
|
if (q.c - p.c < need - EPS) {
|
|
735
|
-
emit("OPN02",
|
|
746
|
+
emit("OPN02", `Openings overlap (${p.o.kind} and ${q.o.kind} — center to center ${Math.round(q.c - p.c)}mm < the required ${Math.round(need)}mm)`, { line: q.o.line, file: b.file, path: [b.a, b.b], related: [loc(p.o.line, b.file)] });
|
|
736
747
|
}
|
|
737
748
|
}
|
|
738
749
|
}
|
|
@@ -742,7 +753,7 @@ function checkBoundarySegs(ctx, b) {
|
|
|
742
753
|
const { model, emit } = ctx;
|
|
743
754
|
for (const g of b.segs) {
|
|
744
755
|
if (b.kind === "open") {
|
|
745
|
-
emit("SEG03", `open
|
|
756
|
+
emit("SEG03", `A seg on an open boundary (there is no wall) is not interpreted`, { line: g.line, file: b.file, path: [b.a, b.b] });
|
|
746
757
|
continue;
|
|
747
758
|
}
|
|
748
759
|
const placed = placeBand(model, b, g, "seg");
|
|
@@ -758,7 +769,7 @@ function checkAreas(ctx) {
|
|
|
758
769
|
for (const s of model.spaces.values()) {
|
|
759
770
|
for (const a of s.areas) {
|
|
760
771
|
if (s.rects.length === 0) {
|
|
761
|
-
emit("SEG01",
|
|
772
|
+
emit("SEG01", `An area cannot be written on ${s.path}, which has no region`, {
|
|
762
773
|
line: a.line,
|
|
763
774
|
file: s.file,
|
|
764
775
|
path: [s.path],
|
|
@@ -768,7 +779,7 @@ function checkAreas(ctx) {
|
|
|
768
779
|
// 内包も導出された形で見る — 割付で見ると、切り落とした側に置いた床材が通ってしまう
|
|
769
780
|
const inside = regionOf(s).some((g) => rectToPoly(a.rect).every((pt) => pointInPolygon(pt, g, EPS)));
|
|
770
781
|
if (!inside) {
|
|
771
|
-
emit("SEG02", `area
|
|
782
|
+
emit("SEG02", `The area spills outside the region of ${s.path}`, { line: a.line, file: s.file, path: [s.path] });
|
|
772
783
|
}
|
|
773
784
|
}
|
|
774
785
|
}
|
|
@@ -780,10 +791,10 @@ function checkZones(ctx) {
|
|
|
780
791
|
for (const z of model.zones.values()) {
|
|
781
792
|
const children = [...model.spaces.keys()].filter((p) => p.startsWith(z.path + "/"));
|
|
782
793
|
if (children.length === 0) {
|
|
783
|
-
emit("ZON01",
|
|
794
|
+
emit("ZON01", `There are no spaces beneath zone ${z.path}`, { line: z.line, file: z.file, path: [z.path] });
|
|
784
795
|
}
|
|
785
796
|
if (model.spaces.has(z.path)) {
|
|
786
|
-
emit("ZON02",
|
|
797
|
+
emit("ZON02", `A space shares its path with a zone (settle on one of them): ${z.path}`, {
|
|
787
798
|
line: z.line,
|
|
788
799
|
file: z.file,
|
|
789
800
|
path: [z.path],
|
|
@@ -791,7 +802,12 @@ function checkZones(ctx) {
|
|
|
791
802
|
}
|
|
792
803
|
}
|
|
793
804
|
}
|
|
794
|
-
/**
|
|
805
|
+
/**
|
|
806
|
+
* 高さ方向の一貫性 — HGT01 / HGT02。
|
|
807
|
+
* **ここは「書かれた値が矛盾しているか」だけを見る。**値が書かれていないこと (上階の slab が無い、
|
|
808
|
+
* 天井高が決まらない) は不変量の破れではなく情報の欠落なので、充足性の節が SUF01 / SUF03 で言う
|
|
809
|
+
* (ADR-0034)。以前はここが HGT03 / HGT04 として二重に言っていた
|
|
810
|
+
*/
|
|
795
811
|
function checkHeights(ctx) {
|
|
796
812
|
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
797
813
|
// 高さ方向の一貫性: 下階の空間の天井高 + 上階のslab ≤ 階高
|
|
@@ -828,7 +844,6 @@ function checkHeights(ctx) {
|
|
|
828
844
|
const below = byLevel.get(lb.name) ?? [];
|
|
829
845
|
const above = byLevel.get(lu.name) ?? [];
|
|
830
846
|
const pitch = lu.z - lb.z;
|
|
831
|
-
let slabMissing = false;
|
|
832
847
|
for (const s of below) {
|
|
833
848
|
if (isSemiOutdoor(model, s))
|
|
834
849
|
continue; // 屋外・半屋外 (庭・バルコニー等) に天井は無い
|
|
@@ -840,19 +855,11 @@ function checkHeights(ctx) {
|
|
|
840
855
|
const covered = above.some((u) => spacesOverlap(s, u)) || above.length === 0;
|
|
841
856
|
if (!covered)
|
|
842
857
|
continue;
|
|
843
|
-
if (lu.slab === undefined)
|
|
844
|
-
|
|
845
|
-
continue;
|
|
846
|
-
}
|
|
858
|
+
if (lu.slab === undefined)
|
|
859
|
+
continue; // 立式に要る値が無い — SUF03 が言う
|
|
847
860
|
const h = heff(model, s);
|
|
848
|
-
if (h === undefined)
|
|
849
|
-
|
|
850
|
-
line: s.line,
|
|
851
|
-
file: s.file,
|
|
852
|
-
path: [s.path],
|
|
853
|
-
});
|
|
854
|
-
continue;
|
|
855
|
-
}
|
|
861
|
+
if (h === undefined)
|
|
862
|
+
continue; // 同上 — SUF01 が言う
|
|
856
863
|
if (h + lu.slab > pitch + EPS) {
|
|
857
864
|
const partners = voidPartners.get(`${s.path}|${lu.name}`) ?? [];
|
|
858
865
|
const cover = partners.length ? voidCoverage(s, partners) : 0;
|
|
@@ -862,36 +869,65 @@ function checkHeights(ctx) {
|
|
|
862
869
|
// 本文は HGT01 と同じ三項を出す — 決め手が上階の slab のとき
|
|
863
870
|
// 「天井高3000は階高3000を超えます」という成り立たない不等式になっていた。
|
|
864
871
|
// 被覆は免除しきい値 (99%) と衝突しないよう小数一桁で言う
|
|
865
|
-
emit("HGT02", `${s.path}
|
|
872
|
+
emit("HGT02", `${s.path} collides into the floor above: ceiling height ${h} + ${lu.name}'s slab ${lu.slab} = ${h + lu.slab} > storey height ${pitch}. The void covers only ${(cover * 100).toFixed(1)}% — under a partial void keep the ceiling height within the storey height (the height of the void part is derived)`, { line: s.line, file: s.file, path: [s.path] });
|
|
866
873
|
}
|
|
867
874
|
else {
|
|
868
|
-
emit("HGT01", `${s.path}
|
|
875
|
+
emit("HGT01", `${s.path} collides into the floor above: ceiling height ${h} + ${lu.name}'s slab ${lu.slab} = ${h + lu.slab} > storey height ${pitch}`, { line: s.line, file: s.file, path: [s.path] });
|
|
869
876
|
}
|
|
870
877
|
}
|
|
871
878
|
}
|
|
872
|
-
if (slabMissing) {
|
|
873
|
-
emit("HGT03", `レベル ${lu.name} に slab が未宣言のため、${lb.name} との高さ検査ができません`, {
|
|
874
|
-
line: lu.line,
|
|
875
|
-
file: lu.file,
|
|
876
|
-
});
|
|
877
|
-
}
|
|
878
879
|
}
|
|
879
880
|
}
|
|
880
|
-
/**
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
881
|
+
/**
|
|
882
|
+
* 充足性 — 領域を持つ空間の走査 (SUF02 / SUF01)。
|
|
883
|
+
*
|
|
884
|
+
* **妥当性の判定ではなく、完全性の検査である** (spec/scope.md §6-2)。形を作らないことと
|
|
885
|
+
* 形を作れないことは違う — 天井高が決まらなければ押し出す高さが無く、レベルが決まらなければ
|
|
886
|
+
* z が無い。どちらも「書いてある構成から一意な形が出る」という契約 (ADR-0034) の破れである。
|
|
887
|
+
*
|
|
888
|
+
* 除くのは、その空間の形が天井高に依らないものだけ — 吹抜け (床も天井も無い)、外部 (地面)、
|
|
889
|
+
* 半屋外 (`fabric.ts` が天井も屋根も架けない)。**節の粒度は走査単位である** (ADR-0028) ので、
|
|
890
|
+
* 一つの空間が出す二つのコードはこの一本のループの中で決まる
|
|
891
|
+
*/
|
|
892
|
+
function checkSpaceSufficiency(ctx) {
|
|
893
|
+
const { model, emit, withRect } = ctx;
|
|
884
894
|
for (const s of withRect) {
|
|
895
|
+
const at = { line: s.line, file: s.file, path: [s.path] };
|
|
885
896
|
if (!s.level) {
|
|
886
|
-
emit("
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
897
|
+
emit("SUF02", `${s.path} has a region, but its level cannot be determined (give it at the head of the path or with level:)`, at);
|
|
898
|
+
continue; // z が決まらない空間には、天井高を問う意味が無い
|
|
899
|
+
}
|
|
900
|
+
if (s.type === "void" || s.type === "exterior" || isSemiOutdoor(model, s))
|
|
901
|
+
continue;
|
|
902
|
+
if (heff(model, s) === undefined) {
|
|
903
|
+
emit("SUF01", `The ceiling height of ${s.path} cannot be determined (neither the space's h: nor level ${s.level}'s h: is there)`, at);
|
|
891
904
|
}
|
|
892
905
|
}
|
|
893
906
|
}
|
|
894
|
-
/**
|
|
907
|
+
/**
|
|
908
|
+
* 充足性 — レベルの走査 (SUF03)。
|
|
909
|
+
*
|
|
910
|
+
* 床は level の `slab` (床組み厚) だけが与える (ADR-0024) ので、書かなければその階に床は
|
|
911
|
+
* 一枚も生成されない。**形そのものは定まる**ので警告である — 「slab が無ければ床要素を作らない」は
|
|
912
|
+
* 決定的な規則であり、複数の形が出るわけではない。ただし床の無い建物になることは知らされるべきである
|
|
913
|
+
*/
|
|
914
|
+
function checkLevelSufficiency(ctx) {
|
|
915
|
+
const { emit, withRect, levels } = ctx;
|
|
916
|
+
for (const l of levels) {
|
|
917
|
+
if (l.slab !== undefined)
|
|
918
|
+
continue;
|
|
919
|
+
// 床を持ちうる空間が一つも載っていない階 (最上階の上限を与えるだけの屋上レベルなど) には
|
|
920
|
+
// 言うことが無い — 生成されなかった床が無いのだから
|
|
921
|
+
const n = withRect.filter((s) => s.level === l.name && s.type !== "void" && s.type !== "exterior").length;
|
|
922
|
+
if (n === 0)
|
|
923
|
+
continue;
|
|
924
|
+
emit("SUF03", `Level ${l.name} has no slab:, so not one floor is generated on this storey`, {
|
|
925
|
+
line: l.line,
|
|
926
|
+
file: l.file,
|
|
927
|
+
});
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
/** 敷地形状 — SIT01 / SIT02 / SIT04 (与件の健全性。建物との関係の判断は検証の面) */
|
|
895
931
|
function checkSite(ctx) {
|
|
896
932
|
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
897
933
|
// 敷地形状 (ADR-0011): 形の妥当性、対応ゾーンの存在、宣言面積との照合、建物のはみ出し検査。
|
|
@@ -902,7 +938,7 @@ function checkSite(ctx) {
|
|
|
902
938
|
const a = poly.points[i];
|
|
903
939
|
const b = poly.points[(i + 1) % poly.points.length];
|
|
904
940
|
if (Math.hypot(b.x - a.x, b.y - a.y) <= EPS_SITE) {
|
|
905
|
-
emit("SIT01",
|
|
941
|
+
emit("SIT01", `The site shape has a duplicate vertex (${Math.round(a.x)},${Math.round(a.y)})`, {
|
|
906
942
|
line: poly.line,
|
|
907
943
|
file: poly.file,
|
|
908
944
|
path: [poly.path],
|
|
@@ -911,7 +947,7 @@ function checkSite(ctx) {
|
|
|
911
947
|
}
|
|
912
948
|
const selfX = polygonSelfIntersection(poly.points);
|
|
913
949
|
if (selfX) {
|
|
914
|
-
emit("SIT02",
|
|
950
|
+
emit("SIT02", `The site shape is self-intersecting (near ${Math.round(selfX.x)},${Math.round(selfX.y)})`, {
|
|
915
951
|
line: poly.line,
|
|
916
952
|
file: poly.file,
|
|
917
953
|
path: [poly.path],
|
|
@@ -920,38 +956,13 @@ function checkSite(ctx) {
|
|
|
920
956
|
}
|
|
921
957
|
const zone = model.zones.get(poly.path);
|
|
922
958
|
if (!zone) {
|
|
923
|
-
emit("SIT04", `polygon ${poly.path}
|
|
959
|
+
emit("SIT04", `No zone corresponds to polygon ${poly.path}`, {
|
|
924
960
|
line: poly.line,
|
|
925
961
|
file: poly.file,
|
|
926
962
|
path: [poly.path],
|
|
927
963
|
});
|
|
928
964
|
continue;
|
|
929
965
|
}
|
|
930
|
-
if (zone.attrs["site"] !== 1)
|
|
931
|
-
continue;
|
|
932
|
-
const declared = zone.attrs["area"];
|
|
933
|
-
if (typeof declared === "number") {
|
|
934
|
-
const derived = polygonAreaM2(poly.points);
|
|
935
|
-
if (Math.abs(declared - derived) >= 0.05) {
|
|
936
|
-
emit("SIT05", `敷地面積の宣言と導出が食い違います: 宣言 ${declared}㎡ / 導出 ${derived.toFixed(2)}㎡`, { line: zone.line, file: zone.file, path: [zone.path] });
|
|
937
|
-
}
|
|
938
|
-
}
|
|
939
|
-
for (const s of withRect) {
|
|
940
|
-
if (s.type === "exterior" || s.path.startsWith(poly.path + "/"))
|
|
941
|
-
continue;
|
|
942
|
-
// 照合するのは割付ではなく**導出された領域** — 敷地なりに切った外形はここで通る
|
|
943
|
-
for (const r of regionOf(s)) {
|
|
944
|
-
const out = shapeEscapesPolygon(r, poly.points, EPS_SITE);
|
|
945
|
-
if (out) {
|
|
946
|
-
emit("SIT03", `${s.path} が敷地形状からはみ出しています (${Math.round(out.x)},${Math.round(out.y)} 付近)`, {
|
|
947
|
-
line: s.line,
|
|
948
|
-
file: s.file,
|
|
949
|
-
path: [s.path],
|
|
950
|
-
});
|
|
951
|
-
break;
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
966
|
}
|
|
956
967
|
}
|
|
957
|
-
//# sourceMappingURL=
|
|
968
|
+
//# sourceMappingURL=diagnose.js.map
|