@kensnzk/koyu 0.15.0 → 0.17.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 +14 -10
- package/README.md +16 -13
- package/dist/cli.js +162 -84
- package/dist/cli.js.map +1 -1
- package/dist/core/derive.d.ts +264 -0
- package/dist/core/derive.d.ts.map +1 -0
- package/dist/core/derive.js +576 -0
- package/dist/core/derive.js.map +1 -0
- package/dist/{check.d.ts → core/diagnose.d.ts} +15 -15
- package/dist/core/diagnose.d.ts.map +1 -0
- package/dist/{check.js → core/diagnose.js} +269 -223
- package/dist/core/diagnose.js.map +1 -0
- package/dist/{diff.d.ts → core/diff.d.ts} +3 -2
- package/dist/core/diff.d.ts.map +1 -0
- package/dist/{diff.js → core/diff.js} +89 -43
- package/dist/core/diff.js.map +1 -0
- package/dist/{fabric.d.ts → core/fabric.d.ts} +5 -3
- package/dist/core/fabric.d.ts.map +1 -0
- package/dist/{fabric.js → core/fabric.js} +12 -11
- package/dist/core/fabric.js.map +1 -0
- package/dist/{graph.d.ts → core/graph.d.ts} +2 -4
- package/dist/core/graph.d.ts.map +1 -0
- package/dist/{graph.js → core/graph.js} +53 -54
- 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} +17 -12
- package/dist/core/light.js.map +1 -0
- package/dist/{model.d.ts → core/model.d.ts} +178 -18
- package/dist/core/model.d.ts.map +1 -0
- package/dist/{model.js → core/model.js} +307 -68
- package/dist/core/model.js.map +1 -0
- package/dist/core/parse.d.ts.map +1 -0
- package/dist/{parse.js → core/parse.js} +546 -133
- package/dist/core/parse.js.map +1 -0
- package/dist/{poly.d.ts → core/poly.d.ts} +3 -6
- package/dist/core/poly.d.ts.map +1 -0
- package/dist/{poly.js → core/poly.js} +8 -13
- package/dist/core/poly.js.map +1 -0
- package/dist/core/site.d.ts.map +1 -0
- package/dist/{site.js → core/site.js} +2 -2
- 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} +48 -12
- package/dist/core/vertical.d.ts.map +1 -0
- package/dist/{vertical.js → core/vertical.js} +53 -105
- 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 +176 -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 +16 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +55 -12
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +112 -50
- 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 +19 -4
- 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 +248 -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 +3 -3
- package/examples/complex/main.muro +1 -1
- package/examples/complex/podium.muro +1 -1
- package/examples/complex/site.muro +6 -6
- package/examples/house/L2.muro +1 -1
- package/examples/house/main.muro +2 -2
- package/examples/house/site.muro +4 -4
- package/examples/house.muro +7 -7
- package/examples/mansion.muro +3 -3
- package/examples/office.muro +4 -4
- 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 +2 -2
- package/examples/steps/05-two-storeys.muro +2 -2
- package/examples/steps/06-finished.muro +3 -3
- package/examples/tower/L2.muro +1 -1
- package/examples/tower/main.muro +1 -1
- package/examples/tower/site.muro +4 -4
- package/examples/twin/main.muro +2 -2
- package/examples/twin/podium.muro +4 -4
- package/examples/twin/site.muro +8 -8
- package/examples/two-rooms.canonical.json +6 -4
- package/examples/two-rooms.muro +3 -3
- package/package.json +18 -3
- package/src/cli.ts +173 -83
- package/src/core/derive.ts +869 -0
- package/src/{check.ts → core/diagnose.ts} +313 -235
- package/src/{diff.ts → core/diff.ts} +91 -43
- package/src/{fabric.ts → core/fabric.ts} +22 -12
- package/src/{graph.ts → core/graph.ts} +64 -63
- package/src/core/light.ts +69 -0
- package/src/{model.ts → core/model.ts} +361 -74
- package/src/{parse.ts → core/parse.ts} +618 -135
- package/src/{poly.ts → core/poly.ts} +8 -16
- package/src/{site.ts → core/site.ts} +2 -2
- package/src/core/tolerance.ts +55 -0
- package/src/{vertical.ts → core/vertical.ts} +73 -116
- package/src/core/vocabulary.ts +210 -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 +201 -34
- package/src/mcp.ts +119 -50
- package/src/parse-file.ts +19 -5
- package/src/validate/access.ts +291 -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/{parse.d.ts → core/parse.d.ts} +0 -0
- /package/dist/{site.d.ts → core/site.d.ts} +0 -0
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// 吹抜け (type:void) はこの不変量の宣言的な免除である。
|
|
6
6
|
//
|
|
7
7
|
// 診断契約 (ADR-0016): 一次形式は checkDiagnostics の Diagnostic[] — code / severity /
|
|
8
|
-
//
|
|
8
|
+
// 本文 / 出所 / 対象パス。check は互換層で、従来の文字列 (位置接頭辞つき) を組み立てる。
|
|
9
9
|
// severity はコードの不変属性 — 重さを変えたくなったら新コードを切る。
|
|
10
10
|
|
|
11
11
|
import {
|
|
@@ -13,23 +13,21 @@ import {
|
|
|
13
13
|
placeOpening,
|
|
14
14
|
planOverlap,
|
|
15
15
|
segmentsFor,
|
|
16
|
-
segmentLength,
|
|
17
|
-
envelopeGaps,
|
|
18
|
-
drawnCut,
|
|
19
16
|
spacesOverlap,
|
|
20
17
|
} from "./graph.js";
|
|
21
|
-
import { heff, isSemiOutdoor, levelsSorted, type Attrs, type Boundary, type Edge, type Level, type Model, type
|
|
18
|
+
import { heff, isSemiOutdoor, levelsSorted, SUPPORTED_LANGUAGE_VERSIONS, type Attrs, type Boundary, type Edge, type Level, type Model, type Space,
|
|
22
19
|
columnSites,
|
|
20
|
+
openingIdentity,
|
|
21
|
+
regionOf,
|
|
23
22
|
columnsFor,
|
|
24
23
|
pointInPolygon,
|
|
25
24
|
rectToPoly,
|
|
26
|
-
regionOf,
|
|
27
25
|
srcRef,
|
|
28
|
-
polygonAreaM2,
|
|
29
26
|
polygonSelfIntersection,
|
|
30
|
-
|
|
27
|
+
isOutside,
|
|
28
|
+
isVoid
|
|
31
29
|
} from "./model.js";
|
|
32
|
-
import {
|
|
30
|
+
import { ASSET_ELEM, attrSpec, isNamespaced } from "./vocabulary.js";
|
|
33
31
|
import { runDecls, runIssues } from "./vertical.js";
|
|
34
32
|
|
|
35
33
|
export interface CheckResult {
|
|
@@ -37,12 +35,12 @@ export interface CheckResult {
|
|
|
37
35
|
warnings: string[];
|
|
38
36
|
}
|
|
39
37
|
|
|
40
|
-
/** 構造化診断 (ADR-0016)。message は本文のみ — 位置接頭辞「file:N
|
|
38
|
+
/** 構造化診断 (ADR-0016)。message は本文のみ — 位置接頭辞「file:line N: 」を含まない */
|
|
41
39
|
export interface Diagnostic {
|
|
42
|
-
/** 台帳 DIAGNOSTIC_CODES のコード (領域
|
|
40
|
+
/** 台帳 DIAGNOSTIC_CODES のコード (領域3字 + 2桁連番) */
|
|
43
41
|
code: DiagnosticCode;
|
|
44
42
|
severity: "error" | "warning";
|
|
45
|
-
/**
|
|
43
|
+
/** 本文 (位置接頭辞なし) */
|
|
46
44
|
message: string;
|
|
47
45
|
/** 出所の行 (位置を持たない診断は省略) */
|
|
48
46
|
line?: number;
|
|
@@ -55,8 +53,10 @@ export interface Diagnostic {
|
|
|
55
53
|
}
|
|
56
54
|
|
|
57
55
|
/**
|
|
58
|
-
* 診断コードの台帳 — 全コードと規範severity
|
|
56
|
+
* 診断コードの台帳 — 全コードと規範severity。公開文書の表 (docs/reference/diagnostics/index.md) とテストで一致を守る。
|
|
59
57
|
* BND07 は欠番 — 「接しているのに境界が無い」警告はADR-0014 (既定境界) で廃止された。
|
|
58
|
+
* HGT03・HGT04・HGT05・RUN04 も欠番 — この四つは「高さがどうか」「縦動線がどうか」ではなく
|
|
59
|
+
* 「形を作るのに必要な情報が書かれていない」という一つの話であり、SUF01-04 へ合流した (ADR-0034)。
|
|
60
60
|
* SYN01 は構文・合成エラー (SourceError) の写し — checkは例外を診断にしない。CLIの check --json だけが写す。
|
|
61
61
|
*/
|
|
62
62
|
export const DIAGNOSTIC_CODES = {
|
|
@@ -96,37 +96,35 @@ export const DIAGNOSTIC_CODES = {
|
|
|
96
96
|
ZON02: "warning", // ゾーンと同パスの空間
|
|
97
97
|
HGT01: "error", // 上階への食い込み (高さ不変量違反)
|
|
98
98
|
HGT02: "error", // 部分吹抜けの被覆不足
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
SUF01: "error", // 天井高が決まらず、天井も屋根も生成できない (ADR-0034)
|
|
100
|
+
SUF02: "error", // レベルが特定できず、立体が一つも生成できない
|
|
101
|
+
SUF03: "warning", // レベルに slab が無く、床が一枚も生成されない
|
|
102
|
+
SUF04: "warning", // 縦動線の宣言に対して形が一つも生成されない
|
|
102
103
|
SIT01: "error", // 敷地形状の重複頂点
|
|
103
104
|
SIT02: "error", // 敷地形状の自己交差
|
|
104
|
-
SIT03: "error", // 建物の敷地形状からのはみ出し
|
|
105
105
|
SIT04: "warning", // 対応するゾーンの無いpolygon
|
|
106
|
-
SIT05: "warning", // 敷地面積の宣言と導出の食い違い
|
|
107
106
|
UID01: "error", // 数字だけのuid (ADR-0015)
|
|
108
107
|
UID02: "error", // 空白を含むuid
|
|
109
108
|
UID03: "error", // uidの重複
|
|
109
|
+
UID04: "error", // 含む対象の中で name が重複 (開口・seg・area・柱の同一性 — ADR-0039)
|
|
110
110
|
ATT01: "error", // 解釈される属性の値が数値でない (ADR-0028)
|
|
111
111
|
ATT02: "error", // 解釈される属性の値が台帳の語彙にない (ADR-0028)
|
|
112
|
+
ATT03: "error", // 台帳に無い属性キー — 名前空間が無い (ADR-0033)
|
|
112
113
|
DAY01: "error", // daylightの値が 0/1 以外 (ADR-0020)
|
|
113
114
|
RUN01: "error", // 一つの空間に縦動線の宣言が複数 (ADR-0021)
|
|
114
115
|
RUN02: "error", // 縦動線の値が上る向き (N/E/S/W) でない
|
|
115
116
|
RUN03: "error", // 縦動線の領域が矩形一つでない / レベルが不明
|
|
116
|
-
RUN04: "warning", // 上にレベルが無く縦動線の形が生成できない
|
|
117
117
|
RUN05: "error", // form の値が不正、または形が決まらない
|
|
118
|
-
RUN06: "warning", // 導出された段の寸法が窮屈 (書かないが検査する)
|
|
119
|
-
RUN07: "warning", // 導出された勾配が宣言・常用域から外れる
|
|
120
|
-
RUN08: "warning", // 縦動線の形はあるが上下を繋ぐ垂直境界が無い
|
|
121
118
|
LIN01: "error", // 描かれた線が二つの空間を分離しない (ADR-0022)
|
|
122
119
|
LIN02: "error", // 垂直境界に描かれた線
|
|
123
120
|
LIN03: "warning", // 描かれた線が何も切っていない
|
|
124
|
-
ENV01: "warning", // 外皮に穴 — 何にも面していない外周 (ADR-0025)
|
|
125
121
|
COL01: "warning", // 柱の宣言に対して立つ柱が0本 (ADR-0023)
|
|
126
122
|
COL02: "warning", // 同じ通りの交点に複数の柱宣言が重なる (先の宣言が勝つ)
|
|
127
123
|
VER01: "error", // koyu 0.1 での既定境界の導出 (ADR-0017)
|
|
128
124
|
VER02: "error", // koyu 0.3以前で採光の推定対象だった型に daylight が無い (ADR-0020)
|
|
129
125
|
VER03: "error", // koyu 0.4以前のファイルに0.5の語 (縦動線・線・柱・地下)
|
|
126
|
+
VER04: "error", // koyu 0.5以前のファイルに1.0の語 (over・drop・集合編集 — ADR-0035/0038)
|
|
127
|
+
VER05: "error", // koyu 1.0以前のファイルの型の位置に exterior / void (ADR-0051)
|
|
130
128
|
SYN01: "error", // 構文・合成エラー (SourceError の写し — check --json のみ)
|
|
131
129
|
} as const satisfies Record<string, "error" | "warning">;
|
|
132
130
|
|
|
@@ -145,59 +143,71 @@ const VERTICAL = new Set(["stair", "shaft", "void"]);
|
|
|
145
143
|
/** 0.3以前が採光の対象と推定していた型 (ADR-0020で廃止)。旧版の受理条件の判定にだけ使う — 意味論には効かない */
|
|
146
144
|
const LEGACY_DAYLIT = new Set(["unit", "room", "ldk", "bedroom", "living"]);
|
|
147
145
|
|
|
148
|
-
/** 互換層 — 従来の文字列形式。位置を持つ診断は「file:N行目: 本文」に組み立てる */
|
|
149
146
|
/**
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
* (台帳の規則3)。daylight は DAY01 が、form は RUN05 が、縦動線の向きは RUN02 が
|
|
154
|
-
* 既に守っているので重ねない。
|
|
147
|
+
* 1.0以前が型の位置から構造として読んでいた二語 (ADR-0051で廃止)。
|
|
148
|
+
* **VER05 の受理条件の判定にだけ使う — 意味論には効かない。**
|
|
149
|
+
* 型を読む場所がここにしか無いことは test/vocabulary.test.ts が守っている
|
|
155
150
|
*/
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
ceiling: { of: [0, 1] },
|
|
160
|
-
turn: { of: ["R", "L"] },
|
|
161
|
-
riser: {},
|
|
162
|
-
tread: {},
|
|
163
|
-
entry: {},
|
|
164
|
-
landing: {},
|
|
165
|
-
lane: {},
|
|
166
|
-
slope: {},
|
|
167
|
-
road: {},
|
|
168
|
-
},
|
|
169
|
-
zone: { site: { of: [0, 1] }, area: {} },
|
|
170
|
-
// air:1 の境界の天端高 (手すり・腰壁) — 立体が読むので台帳に載る (ADR-0028)
|
|
171
|
-
boundary: { h: {} },
|
|
172
|
-
opening: { style: { of: ["hinged", "sliding", "auto"] } },
|
|
151
|
+
const RETIRED_STRUCTURAL_TYPES: Record<string, { decl: string; loses: string }> = {
|
|
152
|
+
exterior: { decl: "outside:1", loses: "stops being outside (it becomes indoor floor area)" },
|
|
153
|
+
void: { decl: "void:1", loses: "stops being a void (a floor is generated in it)" },
|
|
173
154
|
};
|
|
174
155
|
|
|
156
|
+
/**
|
|
157
|
+
* 版の新旧は `SUPPORTED_LANGUAGE_VERSIONS` の並びで決まる。**辞書順で比べてはならない** —
|
|
158
|
+
* 文字列としては "0.5" > "1.0" であり、比較を綴りに任せると新しい版が古い版と判定される
|
|
159
|
+
*/
|
|
160
|
+
const olderThan = (version: string, ref: string): boolean =>
|
|
161
|
+
SUPPORTED_LANGUAGE_VERSIONS.indexOf(version) < SUPPORTED_LANGUAGE_VERSIONS.indexOf(ref);
|
|
162
|
+
|
|
163
|
+
/** 互換層 — 従来の文字列形式。位置を持つ診断は「file:line N: 本文」に組み立てる */
|
|
175
164
|
interface AttrSubject {
|
|
176
|
-
|
|
165
|
+
/** 台帳を引く要素名 */
|
|
166
|
+
elem: string;
|
|
177
167
|
of: Attrs;
|
|
178
168
|
}
|
|
179
169
|
|
|
180
|
-
/**
|
|
170
|
+
/**
|
|
171
|
+
* 属性を検査すべき宣言を、出所つきで数え上げる — 母集団は**書かれた宣言**である。
|
|
172
|
+
* 走査は宣言の順 (空間 → ゾーン → 境界 → その開口・seg → 空間の area → 柱)。
|
|
173
|
+
*/
|
|
181
174
|
function attrSubjects(
|
|
182
175
|
model: Model,
|
|
183
176
|
): Array<[string, AttrSubject, { line?: number; file?: string; path?: string[] }]> {
|
|
184
177
|
const out: Array<[string, AttrSubject, { line?: number; file?: string; path?: string[] }]> = [];
|
|
185
178
|
for (const s of model.spaces.values()) {
|
|
186
|
-
|
|
179
|
+
const at = { line: s.line, file: s.file, path: [s.path] };
|
|
180
|
+
out.push([s.path, { elem: "space", of: s.attrs }, at]);
|
|
181
|
+
for (const a of s.areas) {
|
|
182
|
+
out.push([`area (${s.path})`, { elem: "area", of: a.attrs }, { line: a.line, file: s.file, path: [s.path] }]);
|
|
183
|
+
}
|
|
187
184
|
}
|
|
188
185
|
for (const z of model.zones.values()) {
|
|
189
|
-
out.push([
|
|
186
|
+
out.push([`zone ${z.path}`, { elem: "zone", of: z.attrs }, { line: z.line, file: z.file, path: [z.path] }]);
|
|
190
187
|
}
|
|
191
188
|
for (const b of model.boundaries) {
|
|
192
189
|
const at = { line: b.line, file: b.file, path: [b.a, b.b] };
|
|
193
|
-
out.push([
|
|
190
|
+
out.push([`boundary ${b.a} | ${b.b}`, { elem: "boundary", of: b.attrs }, at]);
|
|
194
191
|
for (const o of b.openings) {
|
|
195
192
|
out.push([
|
|
196
193
|
`${o.kind} (${b.a} | ${b.b})`,
|
|
197
|
-
{
|
|
194
|
+
{ elem: "opening", of: o.attrs },
|
|
198
195
|
{ line: o.line, file: b.file, path: [b.a, b.b] },
|
|
199
196
|
]);
|
|
200
197
|
}
|
|
198
|
+
for (const g of b.segs) {
|
|
199
|
+
out.push([
|
|
200
|
+
`seg (${b.a} | ${b.b})`,
|
|
201
|
+
{ elem: "seg", of: g.attrs },
|
|
202
|
+
{ line: g.line, file: b.file, path: [b.a, b.b] },
|
|
203
|
+
]);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
for (const a of model.assets.values()) {
|
|
207
|
+
out.push([`asset ${a.name}`, { elem: ASSET_ELEM, of: a.attrs }, { line: a.line, file: a.file }]);
|
|
208
|
+
}
|
|
209
|
+
for (const c of model.columns) {
|
|
210
|
+
out.push([`column ${c.size}mm`, { elem: "column", of: c.attrs }, { line: c.line, file: c.file }]);
|
|
201
211
|
}
|
|
202
212
|
return out;
|
|
203
213
|
}
|
|
@@ -295,7 +305,6 @@ export function checkDiagnostics(model: Model): Diagnostic[] {
|
|
|
295
305
|
checkAttrValues(ctx);
|
|
296
306
|
checkRuns(ctx);
|
|
297
307
|
checkDrawnLines(ctx);
|
|
298
|
-
checkEnvelopeGaps(ctx);
|
|
299
308
|
checkColumns(ctx);
|
|
300
309
|
checkLanguageVersion(ctx);
|
|
301
310
|
checkUids(ctx);
|
|
@@ -303,7 +312,8 @@ export function checkDiagnostics(model: Model): Diagnostic[] {
|
|
|
303
312
|
checkAreas(ctx);
|
|
304
313
|
checkZones(ctx);
|
|
305
314
|
checkHeights(ctx);
|
|
306
|
-
|
|
315
|
+
checkSpaceSufficiency(ctx);
|
|
316
|
+
checkLevelSufficiency(ctx);
|
|
307
317
|
checkSite(ctx);
|
|
308
318
|
return diags;
|
|
309
319
|
}
|
|
@@ -331,11 +341,11 @@ function checkBoundaryRefs(ctx: Ctx): void {
|
|
|
331
341
|
for (const b of model.boundaries) {
|
|
332
342
|
for (const p of [b.a, b.b]) {
|
|
333
343
|
if (!model.spaces.has(p)) {
|
|
334
|
-
emit("REF01",
|
|
344
|
+
emit("REF01", `References an undefined space: ${p}`, { line: b.line, file: b.file, path: [b.a, b.b] });
|
|
335
345
|
}
|
|
336
346
|
}
|
|
337
347
|
if (b.a === b.b) {
|
|
338
|
-
emit("BND01",
|
|
348
|
+
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] });
|
|
339
349
|
}
|
|
340
350
|
}
|
|
341
351
|
}
|
|
@@ -356,7 +366,7 @@ function checkBoundaryIdentity(ctx: Ctx): void {
|
|
|
356
366
|
if (prev) {
|
|
357
367
|
emit(
|
|
358
368
|
"BND02",
|
|
359
|
-
|
|
369
|
+
`Duplicate boundary: ${pair}${b.edge ? ` edge:${b.edge}` : ""} (first seen at ${srcRef(prev.line, prev.file)})`,
|
|
360
370
|
{ line: b.line, file: b.file, path: [b.a, b.b], related: [loc(prev.line, prev.file)] },
|
|
361
371
|
);
|
|
362
372
|
} else {
|
|
@@ -375,7 +385,7 @@ function checkBoundaryIdentity(ctx: Ctx): void {
|
|
|
375
385
|
// 「どこかで併存している」だけでは直す場所が無い
|
|
376
386
|
const members = model.boundaries.filter((b) => !b.drawn && [b.a, b.b].sort().join(" | ") === pair);
|
|
377
387
|
const first = members.find((b) => !b.edge) ?? members[0];
|
|
378
|
-
emit("BND05",
|
|
388
|
+
emit("BND05", `The same pair of spaces carries both an edge-restricted and an unrestricted boundary (the segments overlap): ${pair}`, {
|
|
379
389
|
...(first ? { line: first.line, file: first.file } : {}),
|
|
380
390
|
path: pair.split(" | "),
|
|
381
391
|
related: members.filter((b) => b !== first).map((b) => loc(b.line, b.file)),
|
|
@@ -390,7 +400,7 @@ function checkLevelDepth(ctx: Ctx): void {
|
|
|
390
400
|
// レベルの重複
|
|
391
401
|
for (let i = 1; i < levels.length; i++) {
|
|
392
402
|
if (Math.abs(levels[i]!.z - levels[i - 1]!.z) < EPS) {
|
|
393
|
-
emit("LVL01",
|
|
403
|
+
emit("LVL01", `Levels ${levels[i - 1]!.name} and ${levels[i]!.name} have the same z`, {
|
|
394
404
|
line: levels[i]!.line,
|
|
395
405
|
file: levels[i]!.file,
|
|
396
406
|
related: [loc(levels[i - 1]!.line, levels[i - 1]!.file)],
|
|
@@ -408,7 +418,7 @@ function checkSelfOverlap(ctx: Ctx): void {
|
|
|
408
418
|
for (let j = i + 1; j < s.rects.length; j++) {
|
|
409
419
|
if (planOverlap(s.rects[i]!, s.rects[j]!)) {
|
|
410
420
|
// どの組かを言わなければ、三つ重なる空間にバイト同一の診断が三件並ぶ
|
|
411
|
-
emit("GEO01",
|
|
421
|
+
emit("GEO01", `Regions within ${s.path} overlap: ${gridRefText(s, i)} and ${gridRefText(s, j)}`, {
|
|
412
422
|
line: s.line,
|
|
413
423
|
file: s.file,
|
|
414
424
|
path: [s.path],
|
|
@@ -429,7 +439,7 @@ function checkSpaceOverlap(ctx: Ctx): void {
|
|
|
429
439
|
const b = withRect[j]!;
|
|
430
440
|
if (a.level !== b.level) continue;
|
|
431
441
|
if (spacesOverlap(a, b)) {
|
|
432
|
-
emit("GEO02",
|
|
442
|
+
emit("GEO02", `Space regions overlap: ${a.path} and ${b.path}`, {
|
|
433
443
|
line: a.line,
|
|
434
444
|
file: a.file,
|
|
435
445
|
path: [a.path, b.path],
|
|
@@ -449,7 +459,7 @@ function checkDaylightScope(ctx: Ctx): void {
|
|
|
449
459
|
const v = s.attrs["daylight"];
|
|
450
460
|
if (v === undefined) continue;
|
|
451
461
|
if (v !== 0 && v !== 1) {
|
|
452
|
-
emit("DAY01", `daylight
|
|
462
|
+
emit("DAY01", `daylight is either 1 (in scope for the daylight check) or 0 (out of scope): ${s.path} carries daylight:${v}`, {
|
|
453
463
|
line: s.line,
|
|
454
464
|
file: s.file,
|
|
455
465
|
path: [s.path],
|
|
@@ -460,30 +470,40 @@ function checkDaylightScope(ctx: Ctx): void {
|
|
|
460
470
|
|
|
461
471
|
/** 解釈される属性の値 — ATT01 / ATT02 */
|
|
462
472
|
function checkAttrValues(ctx: Ctx): void {
|
|
463
|
-
const { model, emit
|
|
464
|
-
//
|
|
473
|
+
const { model, emit } = ctx;
|
|
474
|
+
// 属性の三層 (docs/reference/scope.md)。**書いたのに解釈されなかったものを、黙って落とさない。**
|
|
475
|
+
//
|
|
476
|
+
// ADR-0028 は値を守った — `site:yes` は敷地の判定を、`h:35OO` は高さ不変量を、
|
|
477
|
+
// それぞれ丸ごと無音にしていた。だが**キー**は無防備のままだった。
|
|
478
|
+
// `heigh:2400` `sit:1` `stiar:N` は、一字違いで同じことを起こしながら緑で通る。
|
|
465
479
|
//
|
|
466
|
-
//
|
|
467
|
-
//
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
480
|
+
// 台帳に無いキーは、名前空間 (`acme.sensor`) を持たなければエラーである (ATT03) —
|
|
481
|
+
// これが「見ていない」と「見て問題がない」を区別できる唯一の形である (ADR-0033)。
|
|
482
|
+
for (const [where, subj, at] of attrSubjects(model)) {
|
|
483
|
+
for (const [key, v] of Object.entries(subj.of)) {
|
|
484
|
+
const spec = attrSpec(subj.elem, key);
|
|
485
|
+
if (!spec) {
|
|
486
|
+
if (isNamespaced(key)) continue; // 運搬層 — core は中身に一切の意味を与えない
|
|
487
|
+
emit(
|
|
488
|
+
"ATT03",
|
|
489
|
+
`${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})`,
|
|
490
|
+
at,
|
|
491
|
+
);
|
|
492
|
+
continue;
|
|
493
|
+
}
|
|
494
|
+
if (spec.tier === "carry") continue; // 運搬層は値を見ない
|
|
495
|
+
if (spec.of) {
|
|
496
|
+
if (!spec.of.includes(v as string | number)) {
|
|
497
|
+
emit("ATT02", `${key} on ${where} is one of ${spec.of.join(" / ")}: ${key}:${v}`, at);
|
|
478
498
|
}
|
|
479
|
-
} else if (typeof v !== "number" || !(v > 0)) {
|
|
480
|
-
emit("ATT01", `${
|
|
499
|
+
} else if (spec.num && (typeof v !== "number" || !(v > 0))) {
|
|
500
|
+
emit("ATT01", `${key} on ${where} is written as a positive number: ${key}:${v}`, at);
|
|
481
501
|
}
|
|
482
502
|
}
|
|
483
503
|
}
|
|
484
504
|
}
|
|
485
505
|
|
|
486
|
-
/** 縦動線 — RUN01〜
|
|
506
|
+
/** 縦動線 — RUN01〜RUN03 / RUN05 / SUF04 (形が一意に決まるか。登りやすさは検証の面) */
|
|
487
507
|
function checkRuns(ctx: Ctx): void {
|
|
488
508
|
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
489
509
|
// 縦動線 (ADR-0021): 宣言の妥当性と、**書かれていない導出値**の妥当性。
|
|
@@ -502,84 +522,39 @@ function checkDrawnLines(ctx: Ctx): void {
|
|
|
502
522
|
if (!b.drawn) continue;
|
|
503
523
|
const bAt = { line: b.drawn.line, file: b.file, path: [b.a, b.b] };
|
|
504
524
|
if (VERTICAL.has(b.kind)) {
|
|
505
|
-
emit("LIN02",
|
|
525
|
+
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);
|
|
506
526
|
continue;
|
|
507
527
|
}
|
|
508
528
|
const sa = model.spaces.get(b.a);
|
|
509
529
|
const sb = model.spaces.get(b.b);
|
|
510
530
|
if (!sa || !sb) continue;
|
|
511
531
|
if (sa.rects.length === 0 && sb.rects.length === 0) {
|
|
512
|
-
emit("LIN01",
|
|
532
|
+
emit("LIN01", `A line cannot be drawn between spaces that have no region: ${b.a} | ${b.b}`, bAt);
|
|
513
533
|
continue;
|
|
514
534
|
}
|
|
515
|
-
//
|
|
516
|
-
//
|
|
517
|
-
//
|
|
518
|
-
|
|
519
|
-
if (!cut) {
|
|
535
|
+
// **帰結は導出のその場で記録されている** (ADR-0041)。ここで計算し直すと、
|
|
536
|
+
// 既に切られた形を相手に窓を組み立てることになり、母集団が食い違う —
|
|
537
|
+
// 実際に切った線に「何も切っていない」と言う経路がそこにあった
|
|
538
|
+
if (b.drawn.effect === "undetermined") {
|
|
520
539
|
emit(
|
|
521
540
|
"LIN01",
|
|
522
541
|
sa.rects.length > 0 && sb.rects.length > 0
|
|
523
|
-
?
|
|
524
|
-
:
|
|
542
|
+
? `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)`
|
|
543
|
+
: `Line ${b.drawn.aRef}..${b.drawn.bRef} bisects the allocation exactly, so which side to keep is undetermined`,
|
|
525
544
|
bAt,
|
|
526
545
|
);
|
|
527
546
|
continue;
|
|
528
547
|
}
|
|
529
|
-
|
|
530
|
-
if (!target.some((s) => cutsInWindow(s.rects.map(rectToPoly), cut.window, b.drawn!.a, b.drawn!.b))) {
|
|
548
|
+
if (b.drawn.effect === "nothing") {
|
|
531
549
|
emit(
|
|
532
550
|
"LIN03",
|
|
533
|
-
|
|
551
|
+
`Line ${b.drawn.aRef}..${b.drawn.bRef} cuts nothing (it is the same as the default adjacency line, or falls outside the allocation)`,
|
|
534
552
|
bAt,
|
|
535
553
|
);
|
|
536
554
|
}
|
|
537
555
|
}
|
|
538
556
|
}
|
|
539
557
|
|
|
540
|
-
/** 外皮の穴 — ENV01 */
|
|
541
|
-
function checkEnvelopeGaps(ctx: Ctx): void {
|
|
542
|
-
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
543
|
-
// 外皮の穴 (ADR-0025): 既定境界は領域を持たない空間との間には導かれない (ADR-0014) ので、
|
|
544
|
-
// 外部への境界の書き忘れは黙って壁の不在になる。導出された外周のうち、
|
|
545
|
-
// 他の空間とも宣言された境界とも向かい合っていない区間を数える。
|
|
546
|
-
// 外構のタイル (site:1 ゾーンの配下)・外部・半屋外は囲われていないのが正常なので数えない。
|
|
547
|
-
// そして**外皮を書き始めているレベルだけ**を見る — 外部への境界が一本も無い階は
|
|
548
|
-
// 外皮をまだ模型にしていないだけであって、穴が開いているのではない。
|
|
549
|
-
// 「書き始めたなら閉じきる」という整合の検査であって、完全性の要求ではない
|
|
550
|
-
const siteZones = [...model.zones.values()].filter((z) => z.attrs["site"] === 1).map((z) => z.path);
|
|
551
|
-
const envelopedLevels = new Set<string>();
|
|
552
|
-
for (const b of model.boundaries) {
|
|
553
|
-
if (b.derived || VERTICAL.has(b.kind)) continue;
|
|
554
|
-
const sa = model.spaces.get(b.a);
|
|
555
|
-
const sb = model.spaces.get(b.b);
|
|
556
|
-
if (!sa || !sb) continue;
|
|
557
|
-
const outer = sa.rects.length === 0 ? sb : sb.rects.length === 0 ? sa : undefined;
|
|
558
|
-
if (outer?.level) envelopedLevels.add(outer.level);
|
|
559
|
-
}
|
|
560
|
-
for (const s of withRect) {
|
|
561
|
-
if (!s.level || !envelopedLevels.has(s.level)) continue;
|
|
562
|
-
if (s.type === "exterior" || isSemiOutdoor(model, s)) continue;
|
|
563
|
-
if (siteZones.some((z) => s.path.startsWith(z + "/"))) continue;
|
|
564
|
-
const gaps = envelopeGaps(model, s);
|
|
565
|
-
if (gaps.length === 0) continue;
|
|
566
|
-
// **どの辺かを言う。**合計長だけでは、edge を書き分けている図面で直す辺が特定できない。
|
|
567
|
-
// envelopeGaps は座標つきの線分を返しているので、方角は既に手元にある
|
|
568
|
-
const byDir = new Map<string, number>();
|
|
569
|
-
for (const g of gaps) {
|
|
570
|
-
const d = g.edgeOfA ?? (g.horizontal ? "N/S" : "E/W");
|
|
571
|
-
byDir.set(d, (byDir.get(d) ?? 0) + segmentLength(g));
|
|
572
|
-
}
|
|
573
|
-
const total = gaps.reduce((a, g) => a + segmentLength(g), 0);
|
|
574
|
-
const where = [...byDir].map(([d, mm]) => `${d} ${Math.round(mm)}mm`).join(" / ");
|
|
575
|
-
emit(
|
|
576
|
-
"ENV01",
|
|
577
|
-
`外皮に面していない外周があります: ${s.path} — ${where} (合計 ${Math.round(total)}mm・${gaps.length}区間)。外部への境界を書きます`,
|
|
578
|
-
{ line: s.line, file: s.file, path: [s.path] },
|
|
579
|
-
);
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
|
|
583
558
|
/** 柱 — COL01 / COL02 */
|
|
584
559
|
function checkColumns(ctx: Ctx): void {
|
|
585
560
|
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
@@ -612,20 +587,20 @@ function checkColumns(ctx: Ctx): void {
|
|
|
612
587
|
});
|
|
613
588
|
emit(
|
|
614
589
|
"COL02",
|
|
615
|
-
|
|
590
|
+
`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)`,
|
|
616
591
|
{ ...at, related: shadow.map((o) => loc(o.line, o.file)) },
|
|
617
592
|
);
|
|
618
593
|
} else {
|
|
619
594
|
emit(
|
|
620
595
|
"COL01",
|
|
621
|
-
|
|
596
|
+
`Not one column stands for this declaration (the grid intersections have no floor): ${c.levels.join(",")} ${c.size}mm square`,
|
|
622
597
|
at,
|
|
623
598
|
);
|
|
624
599
|
}
|
|
625
600
|
}
|
|
626
601
|
}
|
|
627
602
|
|
|
628
|
-
/** 言語版の受理条件 — VER01〜
|
|
603
|
+
/** 言語版の受理条件 — VER01〜VER05 */
|
|
629
604
|
function checkLanguageVersion(ctx: Ctx): void {
|
|
630
605
|
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
631
606
|
// 言語版の受理条件 (ADR-0017): 旧版は意味保存の場合のみ受理する。
|
|
@@ -635,7 +610,7 @@ function checkLanguageVersion(ctx: Ctx): void {
|
|
|
635
610
|
if (b.derived) {
|
|
636
611
|
emit(
|
|
637
612
|
"VER01",
|
|
638
|
-
`koyu 0.1
|
|
613
|
+
`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`,
|
|
639
614
|
{ path: [b.a, b.b] },
|
|
640
615
|
);
|
|
641
616
|
}
|
|
@@ -646,23 +621,59 @@ function checkLanguageVersion(ctx: Ctx): void {
|
|
|
646
621
|
// 書かれていなければ、0.4では判定から黙って外れる — 意味が変わるのでエラーで二択を示す
|
|
647
622
|
if (["0.1", "0.2", "0.3"].includes(model.version)) {
|
|
648
623
|
for (const s of model.spaces.values()) {
|
|
649
|
-
if (!LEGACY_DAYLIT.has(s.type) || s.attrs["daylight"] !== undefined) continue;
|
|
624
|
+
if (s.type === undefined || !LEGACY_DAYLIT.has(s.type) || s.attrs["daylight"] !== undefined) continue;
|
|
650
625
|
emit(
|
|
651
626
|
"VER02",
|
|
652
|
-
`koyu ${model.version}
|
|
627
|
+
`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`,
|
|
653
628
|
{ line: s.line, file: s.file, path: [s.path] },
|
|
654
629
|
);
|
|
655
630
|
}
|
|
656
631
|
}
|
|
657
632
|
|
|
633
|
+
// 1.0 以前は型の位置に書かれた `exterior` と `void` が構造として読まれていた (ADR-0051 で廃止)。
|
|
634
|
+
// 1.1 の処理系はそこを一切読まないので、**書き換えないまま版を上げないと黙って別の建物になる** —
|
|
635
|
+
// 外部が屋内の床になり、吹抜けに床が生成される。実測で複合用途の例は延床 31,606.24㎡ が
|
|
636
|
+
// 33,004.00㎡ に増えながら check は緑で通った。ADR-0020 が `daylight` で下したのと同じ判断で、
|
|
637
|
+
// エラーにして二択を示す。
|
|
638
|
+
if (olderThan(model.version, "1.1")) {
|
|
639
|
+
for (const s of model.spaces.values()) {
|
|
640
|
+
const retired = RETIRED_STRUCTURAL_TYPES[s.type ?? ""];
|
|
641
|
+
if (!retired) continue;
|
|
642
|
+
emit(
|
|
643
|
+
"VER05",
|
|
644
|
+
`A koyu ${model.version} file writes ${s.type} in the type position: ${s.path} — 1.1 reads no meaning from the type, so this space silently ${retired.loses}. Write ${retired.decl} instead, then raise the version to koyu 1.1`,
|
|
645
|
+
{ line: s.line, file: s.file, path: [s.path] },
|
|
646
|
+
);
|
|
647
|
+
}
|
|
648
|
+
// 逆向きも同じ境界である — 1.1 で入った語を古い版で書けば、知らない処理系は
|
|
649
|
+
// ATT03 で拒む。版の宣言と語彙は一致していなければならない (VER03/VER04 と同型)
|
|
650
|
+
for (const s of model.spaces.values()) {
|
|
651
|
+
if (s.type === undefined) {
|
|
652
|
+
emit(
|
|
653
|
+
"VER05",
|
|
654
|
+
`A koyu ${model.version} file writes a space with no type: ${s.path} — the type became optional in 1.1, and an older processor refuses the line. Write a type, or raise the version to koyu 1.1`,
|
|
655
|
+
{ line: s.line, file: s.file, path: [s.path] },
|
|
656
|
+
);
|
|
657
|
+
}
|
|
658
|
+
for (const key of ["outside", "void"]) {
|
|
659
|
+
if (s.attrs[key] === undefined) continue;
|
|
660
|
+
emit(
|
|
661
|
+
"VER05",
|
|
662
|
+
`A koyu ${model.version} file carries ${key}: on ${s.path} — that word arrives in 1.1. Raise the version to koyu 1.1`,
|
|
663
|
+
{ line: s.line, file: s.file, path: [s.path] },
|
|
664
|
+
);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
|
|
658
669
|
// 0.5 で入った語 (縦動線の宣言・描かれた線・柱・地下) は 0.4 以前の処理系が知らない。
|
|
659
670
|
// 知らない処理系では黙って形が生成されないので、版を上げずに使うのはエラー (ADR-0017 決定3)
|
|
660
|
-
if (model.version
|
|
661
|
-
const older = `koyu ${model.version}
|
|
671
|
+
if (olderThan(model.version, "0.5")) {
|
|
672
|
+
const older = `A koyu ${model.version} file uses a 0.5 word`;
|
|
662
673
|
for (const s of model.spaces.values()) {
|
|
663
674
|
const d = runDecls(s);
|
|
664
675
|
if (d.length > 0) {
|
|
665
|
-
emit("VER03", `${older}: ${s.path}
|
|
676
|
+
emit("VER03", `${older}: ${s.path} carries ${d[0]!.device}: (a vertical circulation) — raise the version to koyu 0.5`, {
|
|
666
677
|
line: s.line,
|
|
667
678
|
file: s.file,
|
|
668
679
|
path: [s.path],
|
|
@@ -671,7 +682,7 @@ function checkLanguageVersion(ctx: Ctx): void {
|
|
|
671
682
|
}
|
|
672
683
|
for (const b of model.boundaries) {
|
|
673
684
|
if (b.drawn) {
|
|
674
|
-
emit("VER03", `${older}: ${b.a} | ${b.b}
|
|
685
|
+
emit("VER03", `${older}: ${b.a} | ${b.b} carries line (a drawn line) — raise the version to koyu 0.5`, {
|
|
675
686
|
line: b.drawn.line,
|
|
676
687
|
file: b.file,
|
|
677
688
|
path: [b.a, b.b],
|
|
@@ -679,20 +690,39 @@ function checkLanguageVersion(ctx: Ctx): void {
|
|
|
679
690
|
}
|
|
680
691
|
}
|
|
681
692
|
for (const c of model.columns) {
|
|
682
|
-
emit("VER03", `${older}: column
|
|
693
|
+
emit("VER03", `${older}: column — raise the version to koyu 0.5`, { line: c.line, file: c.file });
|
|
683
694
|
}
|
|
684
695
|
for (const l of Object.values(model.levels)) {
|
|
685
696
|
if (l.underground) {
|
|
686
|
-
emit("VER03", `${older}: level ${l.name}
|
|
697
|
+
emit("VER03", `${older}: level ${l.name} carries underground: — raise the version to koyu 0.5`, {
|
|
687
698
|
line: l.line,
|
|
688
699
|
file: l.file,
|
|
689
700
|
});
|
|
690
701
|
}
|
|
691
702
|
}
|
|
692
703
|
}
|
|
704
|
+
|
|
705
|
+
// 1.0 で入った語 (上書き `over`・削除 `drop`・`over` 直下の集合編集 `+` `-` `=`) は
|
|
706
|
+
// 0.5 以前の処理系が知らない。知らない処理系ではその行が語として読めず、上書きも削除も
|
|
707
|
+
// 起きない — **黙って別の建物になる**。VER03 と同型の理屈である (ADR-0017 決定3 / ADR-0035)
|
|
708
|
+
if (olderThan(model.version, "1.0")) {
|
|
709
|
+
const older = `A koyu ${model.version} file uses a 1.0 word`;
|
|
710
|
+
for (const e of model.compositionEdits) {
|
|
711
|
+
const what =
|
|
712
|
+
e.word === "over" ? "a composition override"
|
|
713
|
+
: e.word === "drop" ? "a composition removal"
|
|
714
|
+
: "a set edit under over";
|
|
715
|
+
const paths = e.subject.split(" ").filter((t) => t.startsWith("/"));
|
|
716
|
+
emit("VER04", `${older}: ${[e.word, e.subject].filter(Boolean).join(" ")} (${what}) — raise the version to koyu 1.0`, {
|
|
717
|
+
line: e.line,
|
|
718
|
+
file: e.file,
|
|
719
|
+
...(paths.length > 0 ? { path: paths } : {}),
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
}
|
|
693
723
|
}
|
|
694
724
|
|
|
695
|
-
/**
|
|
725
|
+
/** 同一性 — UID01〜UID04 */
|
|
696
726
|
function checkUids(ctx: Ctx): void {
|
|
697
727
|
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
698
728
|
// uid (ADR-0015): 不透明トークン、space/zone横断でモデル全体一意。
|
|
@@ -702,7 +732,7 @@ function checkUids(ctx: Ctx): void {
|
|
|
702
732
|
const v = attrs["uid"];
|
|
703
733
|
if (v === undefined) return;
|
|
704
734
|
if (typeof v === "number") {
|
|
705
|
-
emit("UID01", `uid
|
|
735
|
+
emit("UID01", `A uid cannot be a token of digits alone: uid:${v} (write something like sp-${v})`, {
|
|
706
736
|
line,
|
|
707
737
|
file,
|
|
708
738
|
path: [path],
|
|
@@ -710,7 +740,7 @@ function checkUids(ctx: Ctx): void {
|
|
|
710
740
|
return;
|
|
711
741
|
}
|
|
712
742
|
if (v === "" || /\s/.test(v)) {
|
|
713
|
-
emit("UID02", `uid
|
|
743
|
+
emit("UID02", `A uid cannot contain whitespace: "${v}"`, { line, file, path: [path] });
|
|
714
744
|
return;
|
|
715
745
|
}
|
|
716
746
|
const arr = uidOwners.get(v) ?? [];
|
|
@@ -723,11 +753,59 @@ function checkUids(ctx: Ctx): void {
|
|
|
723
753
|
if (owners.length > 1) {
|
|
724
754
|
emit(
|
|
725
755
|
"UID03",
|
|
726
|
-
`uid
|
|
756
|
+
`Duplicate uid: ${uid} (${owners.map((o) => `${o.kind} ${o.path} — ${srcRef(o.line, o.file)}`).join(", ")})`,
|
|
727
757
|
{ path: owners.map((o) => o.path), related: owners.map((o) => loc(o.line, o.file)) },
|
|
728
758
|
);
|
|
729
759
|
}
|
|
730
760
|
}
|
|
761
|
+
|
|
762
|
+
// 開口・内包物の同一性は「含む対象 + その中で一意な名」から導かれる (docs/reference/scope.md)。
|
|
763
|
+
// 名が重複していれば、その同一性は成り立たない — `over ... = door D1` はどちらを指すのか
|
|
764
|
+
// 決められず、`drop column C1` は二本まとめて消してしまう。**推測せずに拒む** (ADR-0039)。
|
|
765
|
+
// 名を書かない要素は同一性を主張していないので、母集団に入らない
|
|
766
|
+
const dupNames = (
|
|
767
|
+
what: string,
|
|
768
|
+
where: string,
|
|
769
|
+
items: Array<{ name?: string; line: number; file?: string }>,
|
|
770
|
+
path?: string[],
|
|
771
|
+
) => {
|
|
772
|
+
const byName = new Map<string, Array<{ line: number; file?: string }>>();
|
|
773
|
+
for (const it of items) {
|
|
774
|
+
if (it.name === undefined || it.name === "") continue;
|
|
775
|
+
const arr = byName.get(it.name) ?? [];
|
|
776
|
+
arr.push(loc(it.line, it.file));
|
|
777
|
+
byName.set(it.name, arr);
|
|
778
|
+
}
|
|
779
|
+
for (const [name, at] of byName) {
|
|
780
|
+
if (at.length < 2) continue;
|
|
781
|
+
const last = at[at.length - 1]!;
|
|
782
|
+
emit(
|
|
783
|
+
"UID04",
|
|
784
|
+
`Duplicate ${what} name within ${where}: ${name} (${at.map((o) => srcRef(o.line, o.file)).join(", ")}) — the name is what identifies it inside its container`,
|
|
785
|
+
{ line: last.line, file: last.file, ...(path ? { path } : {}), related: at.slice(0, -1) },
|
|
786
|
+
);
|
|
787
|
+
}
|
|
788
|
+
};
|
|
789
|
+
const written = (attrs: Attrs): string | undefined => {
|
|
790
|
+
const n = attrs["name"];
|
|
791
|
+
return n === undefined || n === "" ? undefined : String(n);
|
|
792
|
+
};
|
|
793
|
+
for (const b of model.boundaries) {
|
|
794
|
+
const where = `boundary ${b.a} | ${b.b}`;
|
|
795
|
+
const at = b.file !== undefined ? { file: b.file } : {};
|
|
796
|
+
// 開口だけは、アセットから継いだ型の名を主張として数えない (ADR-0039)
|
|
797
|
+
dupNames("opening", where, b.openings.map((o) => ({ name: openingIdentity(model, o), line: o.line, ...at })), [b.a, b.b]);
|
|
798
|
+
dupNames("seg", where, b.segs.map((g) => ({ name: written(g.attrs), line: g.line, ...at })), [b.a, b.b]);
|
|
799
|
+
}
|
|
800
|
+
for (const s of model.spaces.values()) {
|
|
801
|
+
const at = s.file !== undefined ? { file: s.file } : {};
|
|
802
|
+
dupNames("area", `space ${s.path}`, s.areas.map((a) => ({ name: written(a.attrs), line: a.line, ...at })), [s.path]);
|
|
803
|
+
}
|
|
804
|
+
dupNames(
|
|
805
|
+
"column",
|
|
806
|
+
"the model",
|
|
807
|
+
model.columns.map((c) => ({ name: written(c.attrs), line: c.line, ...(c.file !== undefined ? { file: c.file } : {}) })),
|
|
808
|
+
);
|
|
731
809
|
}
|
|
732
810
|
|
|
733
811
|
/** 境界の妥当性 — VRT / BND03〜06 / OPN / SEG */
|
|
@@ -751,7 +829,7 @@ function checkBoundaryValidity(ctx: Ctx): void {
|
|
|
751
829
|
if (sa.rects.length > 0 && sb.rects.length > 0 && sa.level !== sb.level) {
|
|
752
830
|
emit(
|
|
753
831
|
"BND03",
|
|
754
|
-
|
|
832
|
+
`A wall boundary cannot be written to a space on a different level (vertical takes type:stair/shaft/void): ${b.a} | ${b.b}`,
|
|
755
833
|
bAt,
|
|
756
834
|
);
|
|
757
835
|
continue; // レベルを跨ぐ壁は成立していない — 線分も開口も問わない
|
|
@@ -767,29 +845,29 @@ function checkVerticalBoundary(ctx: Ctx, b: Boundary, sa: Space, sb: Space, bAt:
|
|
|
767
845
|
const { emit, levelIndex } = ctx;
|
|
768
846
|
// 垂直境界: 隣り合うレベルの、平面で重なる空間同士にしか張れない
|
|
769
847
|
if (sa.rects.length === 0 || sb.rects.length === 0 || !sa.level || !sb.level) {
|
|
770
|
-
emit("VRT01",
|
|
848
|
+
emit("VRT01", `A ${b.kind} boundary is written between spaces that have both a region and a level`, bAt);
|
|
771
849
|
return; // 前提が崩れているので、以降の判定は意味を持たない
|
|
772
850
|
}
|
|
773
851
|
const ia = levelIndex.get(sa.level);
|
|
774
852
|
const ib = levelIndex.get(sb.level);
|
|
775
853
|
if (ia === undefined || ib === undefined || Math.abs(ia - ib) !== 1) {
|
|
776
|
-
emit("VRT02",
|
|
854
|
+
emit("VRT02", `A ${b.kind} boundary is written between adjacent levels: ${b.a} | ${b.b}`, bAt);
|
|
777
855
|
} else if (!spacesOverlap(sa, sb)) {
|
|
778
|
-
emit("VRT03",
|
|
856
|
+
emit("VRT03", `The spaces of a ${b.kind} boundary do not overlap in plan: ${b.a} | ${b.b}`, bAt);
|
|
779
857
|
}
|
|
780
858
|
if (b.kind === "void") {
|
|
781
859
|
const upper = (ia ?? 0) > (ib ?? 0) ? sa : sb;
|
|
782
|
-
if (upper
|
|
783
|
-
emit("VRT04", `void
|
|
860
|
+
if (!isVoid(upper)) {
|
|
861
|
+
emit("VRT04", `The space above a void boundary is expected to declare void:1: ${upper.path}`, bAt);
|
|
784
862
|
}
|
|
785
863
|
}
|
|
786
864
|
// 咎めているのは字下げされた door / window / seg の行そのものなので、
|
|
787
865
|
// 親の境界宣言ではなくその行を指す。宣言が複数あれば診断も複数出る
|
|
788
866
|
for (const o of b.openings) {
|
|
789
|
-
emit("VRT05",
|
|
867
|
+
emit("VRT05", `A ${o.kind} on a vertical boundary is not interpreted`, { line: o.line, file: b.file, path: [b.a, b.b] });
|
|
790
868
|
}
|
|
791
869
|
for (const g of b.segs) {
|
|
792
|
-
emit("VRT06",
|
|
870
|
+
emit("VRT06", `A seg on a vertical boundary is not interpreted`, { line: g.line, file: b.file, path: [b.a, b.b] });
|
|
793
871
|
}
|
|
794
872
|
}
|
|
795
873
|
|
|
@@ -809,19 +887,19 @@ function checkBoundarySegments(ctx: Ctx, b: Boundary, sa: Space, sb: Space, bAt:
|
|
|
809
887
|
const dirs = [...new Set(without.map((g) => g.edgeOfA))].filter((d): d is Edge => d !== undefined);
|
|
810
888
|
emit(
|
|
811
889
|
"BND04",
|
|
812
|
-
`edge:${b.edge}
|
|
813
|
-
dirs.join("
|
|
814
|
-
}
|
|
890
|
+
`No shared edge on edge:${b.edge}: ${b.a} | ${b.b} (they actually touch on ${
|
|
891
|
+
dirs.join(" / ") || "another edge"
|
|
892
|
+
})`,
|
|
815
893
|
bAt,
|
|
816
894
|
);
|
|
817
895
|
} else {
|
|
818
|
-
emit("BND04",
|
|
896
|
+
emit("BND04", `The spaces do not touch, so no boundary can be derived: ${b.a} | ${b.b}`, bAt);
|
|
819
897
|
}
|
|
820
898
|
}
|
|
821
899
|
if ((sa.rects.length > 0 ? 1 : 0) + (sb.rects.length > 0 ? 1 : 0) === 1 && segs.length === 0) {
|
|
822
900
|
emit(
|
|
823
901
|
"BND06",
|
|
824
|
-
|
|
902
|
+
`No edge remains on the perimeter${b.edge ? ` for edge:${b.edge}` : ""}, so the boundary segment is of zero length: ${b.a} | ${b.b}`,
|
|
825
903
|
bAt,
|
|
826
904
|
);
|
|
827
905
|
}
|
|
@@ -836,7 +914,7 @@ function checkOpenings(ctx: Ctx, b: Boundary): void {
|
|
|
836
914
|
const { model, emit, loc } = ctx;
|
|
837
915
|
if (b.kind === "open" && b.openings.length > 0) {
|
|
838
916
|
for (const o of b.openings) {
|
|
839
|
-
emit("OPN03", `
|
|
917
|
+
emit("OPN03", `A ${o.kind} on an open boundary has no effect on passage (it is always passable)`, {
|
|
840
918
|
line: o.line,
|
|
841
919
|
file: b.file,
|
|
842
920
|
path: [b.a, b.b],
|
|
@@ -865,7 +943,7 @@ function checkOpenings(ctx: Ctx, b: Boundary): void {
|
|
|
865
943
|
if (!okAxis) {
|
|
866
944
|
emit(
|
|
867
945
|
"OPN01",
|
|
868
|
-
`hinge:${o.hinge}
|
|
946
|
+
`hinge:${o.hinge}: ${placed.segment.horizontal ? "a horizontal segment takes W/E" : "a vertical segment takes N/S"}`,
|
|
869
947
|
{ line: o.line, file: b.file, path: [b.a, b.b] },
|
|
870
948
|
);
|
|
871
949
|
}
|
|
@@ -887,9 +965,9 @@ function checkOpenings(ctx: Ctx, b: Boundary): void {
|
|
|
887
965
|
if (q.c - p.c < need - EPS) {
|
|
888
966
|
emit(
|
|
889
967
|
"OPN02",
|
|
890
|
-
|
|
968
|
+
`Openings overlap (${p.o.kind} and ${q.o.kind} — center to center ${Math.round(
|
|
891
969
|
q.c - p.c,
|
|
892
|
-
)}mm <
|
|
970
|
+
)}mm < the required ${Math.round(need)}mm)`,
|
|
893
971
|
{ line: q.o.line, file: b.file, path: [b.a, b.b], related: [loc(p.o.line, b.file)] },
|
|
894
972
|
);
|
|
895
973
|
}
|
|
@@ -902,7 +980,7 @@ function checkBoundarySegs(ctx: Ctx, b: Boundary): void {
|
|
|
902
980
|
const { model, emit } = ctx;
|
|
903
981
|
for (const g of b.segs) {
|
|
904
982
|
if (b.kind === "open") {
|
|
905
|
-
emit("SEG03", `open
|
|
983
|
+
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] });
|
|
906
984
|
continue;
|
|
907
985
|
}
|
|
908
986
|
const placed = placeBand(model, b, g, "seg");
|
|
@@ -919,7 +997,7 @@ function checkAreas(ctx: Ctx): void {
|
|
|
919
997
|
for (const s of model.spaces.values()) {
|
|
920
998
|
for (const a of s.areas) {
|
|
921
999
|
if (s.rects.length === 0) {
|
|
922
|
-
emit("SEG01",
|
|
1000
|
+
emit("SEG01", `An area cannot be written on ${s.path}, which has no region`, {
|
|
923
1001
|
line: a.line,
|
|
924
1002
|
file: s.file,
|
|
925
1003
|
path: [s.path],
|
|
@@ -931,7 +1009,7 @@ function checkAreas(ctx: Ctx): void {
|
|
|
931
1009
|
rectToPoly(a.rect).every((pt) => pointInPolygon(pt, g, EPS)),
|
|
932
1010
|
);
|
|
933
1011
|
if (!inside) {
|
|
934
|
-
emit("SEG02", `area
|
|
1012
|
+
emit("SEG02", `The area spills outside the region of ${s.path}`, { line: a.line, file: s.file, path: [s.path] });
|
|
935
1013
|
}
|
|
936
1014
|
}
|
|
937
1015
|
}
|
|
@@ -944,10 +1022,10 @@ function checkZones(ctx: Ctx): void {
|
|
|
944
1022
|
for (const z of model.zones.values()) {
|
|
945
1023
|
const children = [...model.spaces.keys()].filter((p) => p.startsWith(z.path + "/"));
|
|
946
1024
|
if (children.length === 0) {
|
|
947
|
-
emit("ZON01",
|
|
1025
|
+
emit("ZON01", `There are no spaces beneath zone ${z.path}`, { line: z.line, file: z.file, path: [z.path] });
|
|
948
1026
|
}
|
|
949
1027
|
if (model.spaces.has(z.path)) {
|
|
950
|
-
emit("ZON02",
|
|
1028
|
+
emit("ZON02", `A space shares its path with a zone (settle on one of them): ${z.path}`, {
|
|
951
1029
|
line: z.line,
|
|
952
1030
|
file: z.file,
|
|
953
1031
|
path: [z.path],
|
|
@@ -956,7 +1034,12 @@ function checkZones(ctx: Ctx): void {
|
|
|
956
1034
|
}
|
|
957
1035
|
}
|
|
958
1036
|
|
|
959
|
-
/**
|
|
1037
|
+
/**
|
|
1038
|
+
* 高さ方向の一貫性 — HGT01 / HGT02。
|
|
1039
|
+
* **ここは「書かれた値が矛盾しているか」だけを見る。**値が書かれていないこと (上階の slab が無い、
|
|
1040
|
+
* 天井高が決まらない) は不変量の破れではなく情報の欠落なので、充足性の節が SUF01 / SUF03 で言う
|
|
1041
|
+
* (ADR-0034)。以前はここが HGT03 / HGT04 として二重に言っていた
|
|
1042
|
+
*/
|
|
960
1043
|
function checkHeights(ctx: Ctx): void {
|
|
961
1044
|
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
962
1045
|
// 高さ方向の一貫性: 下階の空間の天井高 + 上階のslab ≤ 階高
|
|
@@ -991,7 +1074,6 @@ function checkHeights(ctx: Ctx): void {
|
|
|
991
1074
|
const below = byLevel.get(lb.name) ?? [];
|
|
992
1075
|
const above = byLevel.get(lu.name) ?? [];
|
|
993
1076
|
const pitch = lu.z - lb.z;
|
|
994
|
-
let slabMissing = false;
|
|
995
1077
|
for (const s of below) {
|
|
996
1078
|
if (isSemiOutdoor(model, s)) continue; // 屋外・半屋外 (庭・バルコニー等) に天井は無い
|
|
997
1079
|
// 縦動線の宣言的免除 (ADR-0021)。void の免除が「床の不在」だったのに対し、
|
|
@@ -1000,19 +1082,9 @@ function checkHeights(ctx: Ctx): void {
|
|
|
1000
1082
|
if (runDecls(s).length > 0) continue;
|
|
1001
1083
|
const covered = above.some((u) => spacesOverlap(s, u)) || above.length === 0;
|
|
1002
1084
|
if (!covered) continue;
|
|
1003
|
-
if (lu.slab === undefined)
|
|
1004
|
-
slabMissing = true;
|
|
1005
|
-
continue;
|
|
1006
|
-
}
|
|
1085
|
+
if (lu.slab === undefined) continue; // 立式に要る値が無い — SUF03 が言う
|
|
1007
1086
|
const h = heff(model, s);
|
|
1008
|
-
if (h === undefined)
|
|
1009
|
-
emit("HGT04", `${s.path} の天井高が不明で、${lu.name} との高さ検査ができません`, {
|
|
1010
|
-
line: s.line,
|
|
1011
|
-
file: s.file,
|
|
1012
|
-
path: [s.path],
|
|
1013
|
-
});
|
|
1014
|
-
continue;
|
|
1015
|
-
}
|
|
1087
|
+
if (h === undefined) continue; // 同上 — SUF01 が言う
|
|
1016
1088
|
if (h + lu.slab > pitch + EPS) {
|
|
1017
1089
|
const partners = voidPartners.get(`${s.path}|${lu.name}`) ?? [];
|
|
1018
1090
|
const cover = partners.length ? voidCoverage(s, partners) : 0;
|
|
@@ -1023,45 +1095,78 @@ function checkHeights(ctx: Ctx): void {
|
|
|
1023
1095
|
// 被覆は免除しきい値 (99%) と衝突しないよう小数一桁で言う
|
|
1024
1096
|
emit(
|
|
1025
1097
|
"HGT02",
|
|
1026
|
-
`${s.path}
|
|
1098
|
+
`${s.path} collides into the floor above: ceiling height ${h} + ${lu.name}'s slab ${lu.slab} = ${
|
|
1027
1099
|
h + lu.slab
|
|
1028
|
-
} >
|
|
1100
|
+
} > 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)`,
|
|
1029
1101
|
{ line: s.line, file: s.file, path: [s.path] },
|
|
1030
1102
|
);
|
|
1031
1103
|
} else {
|
|
1032
1104
|
emit(
|
|
1033
1105
|
"HGT01",
|
|
1034
|
-
`${s.path}
|
|
1106
|
+
`${s.path} collides into the floor above: ceiling height ${h} + ${lu.name}'s slab ${lu.slab} = ${h + lu.slab} > storey height ${pitch}`,
|
|
1035
1107
|
{ line: s.line, file: s.file, path: [s.path] },
|
|
1036
1108
|
);
|
|
1037
1109
|
}
|
|
1038
1110
|
}
|
|
1039
1111
|
}
|
|
1040
|
-
if (slabMissing) {
|
|
1041
|
-
emit("HGT03", `レベル ${lu.name} に slab が未宣言のため、${lb.name} との高さ検査ができません`, {
|
|
1042
|
-
line: lu.line,
|
|
1043
|
-
file: lu.file,
|
|
1044
|
-
});
|
|
1045
|
-
}
|
|
1046
1112
|
}
|
|
1047
1113
|
}
|
|
1048
1114
|
|
|
1049
|
-
/**
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1115
|
+
/**
|
|
1116
|
+
* 充足性 — 領域を持つ空間の走査 (SUF02 / SUF01)。
|
|
1117
|
+
*
|
|
1118
|
+
* **妥当性の判定ではなく、完全性の検査である** (docs/reference/scope.md-2)。形を作らないことと
|
|
1119
|
+
* 形を作れないことは違う — 天井高が決まらなければ押し出す高さが無く、レベルが決まらなければ
|
|
1120
|
+
* z が無い。どちらも「書いてある構成から一意な形が出る」という契約 (ADR-0034) の破れである。
|
|
1121
|
+
*
|
|
1122
|
+
* 除くのは、その空間の形が天井高に依らないものだけ — 吹抜け (床も天井も無い)、外部 (地面)、
|
|
1123
|
+
* 半屋外 (`fabric.ts` が天井も屋根も架けない)。**節の粒度は走査単位である** (ADR-0028) ので、
|
|
1124
|
+
* 一つの空間が出す二つのコードはこの一本のループの中で決まる
|
|
1125
|
+
*/
|
|
1126
|
+
function checkSpaceSufficiency(ctx: Ctx): void {
|
|
1127
|
+
const { model, emit, withRect } = ctx;
|
|
1053
1128
|
for (const s of withRect) {
|
|
1129
|
+
const at = { line: s.line, file: s.file, path: [s.path] };
|
|
1054
1130
|
if (!s.level) {
|
|
1055
|
-
emit("
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1131
|
+
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);
|
|
1132
|
+
continue; // z が決まらない空間には、天井高を問う意味が無い
|
|
1133
|
+
}
|
|
1134
|
+
if (isVoid(s) || isOutside(s) || isSemiOutdoor(model, s)) continue;
|
|
1135
|
+
if (heff(model, s) === undefined) {
|
|
1136
|
+
emit(
|
|
1137
|
+
"SUF01",
|
|
1138
|
+
`The ceiling height of ${s.path} cannot be determined (neither the space's h: nor level ${s.level}'s h: is there)`,
|
|
1139
|
+
at,
|
|
1140
|
+
);
|
|
1060
1141
|
}
|
|
1061
1142
|
}
|
|
1062
1143
|
}
|
|
1063
1144
|
|
|
1064
|
-
/**
|
|
1145
|
+
/**
|
|
1146
|
+
* 充足性 — レベルの走査 (SUF03)。
|
|
1147
|
+
*
|
|
1148
|
+
* 床は level の `slab` (床組み厚) だけが与える (ADR-0024) ので、書かなければその階に床は
|
|
1149
|
+
* 一枚も生成されない。**形そのものは定まる**ので警告である — 「slab が無ければ床要素を作らない」は
|
|
1150
|
+
* 決定的な規則であり、複数の形が出るわけではない。ただし床の無い建物になることは知らされるべきである
|
|
1151
|
+
*/
|
|
1152
|
+
function checkLevelSufficiency(ctx: Ctx): void {
|
|
1153
|
+
const { emit, withRect, levels } = ctx;
|
|
1154
|
+
for (const l of levels) {
|
|
1155
|
+
if (l.slab !== undefined) continue;
|
|
1156
|
+
// 床を持ちうる空間が一つも載っていない階 (最上階の上限を与えるだけの屋上レベルなど) には
|
|
1157
|
+
// 言うことが無い — 生成されなかった床が無いのだから
|
|
1158
|
+
const n = withRect.filter(
|
|
1159
|
+
(s) => s.level === l.name && !isVoid(s) && !isOutside(s),
|
|
1160
|
+
).length;
|
|
1161
|
+
if (n === 0) continue;
|
|
1162
|
+
emit("SUF03", `Level ${l.name} has no slab:, so not one floor is generated on this storey`, {
|
|
1163
|
+
line: l.line,
|
|
1164
|
+
file: l.file,
|
|
1165
|
+
});
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
/** 敷地形状 — SIT01 / SIT02 / SIT04 (与件の健全性。建物との関係の判断は検証の面) */
|
|
1065
1170
|
function checkSite(ctx: Ctx): void {
|
|
1066
1171
|
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
1067
1172
|
// 敷地形状 (ADR-0011): 形の妥当性、対応ゾーンの存在、宣言面積との照合、建物のはみ出し検査。
|
|
@@ -1072,7 +1177,7 @@ function checkSite(ctx: Ctx): void {
|
|
|
1072
1177
|
const a = poly.points[i]!;
|
|
1073
1178
|
const b = poly.points[(i + 1) % poly.points.length]!;
|
|
1074
1179
|
if (Math.hypot(b.x - a.x, b.y - a.y) <= EPS_SITE) {
|
|
1075
|
-
emit("SIT01",
|
|
1180
|
+
emit("SIT01", `The site shape has a duplicate vertex (${Math.round(a.x)},${Math.round(a.y)})`, {
|
|
1076
1181
|
line: poly.line,
|
|
1077
1182
|
file: poly.file,
|
|
1078
1183
|
path: [poly.path],
|
|
@@ -1081,7 +1186,7 @@ function checkSite(ctx: Ctx): void {
|
|
|
1081
1186
|
}
|
|
1082
1187
|
const selfX = polygonSelfIntersection(poly.points);
|
|
1083
1188
|
if (selfX) {
|
|
1084
|
-
emit("SIT02",
|
|
1189
|
+
emit("SIT02", `The site shape is self-intersecting (near ${Math.round(selfX.x)},${Math.round(selfX.y)})`, {
|
|
1085
1190
|
line: poly.line,
|
|
1086
1191
|
file: poly.file,
|
|
1087
1192
|
path: [poly.path],
|
|
@@ -1090,39 +1195,12 @@ function checkSite(ctx: Ctx): void {
|
|
|
1090
1195
|
}
|
|
1091
1196
|
const zone = model.zones.get(poly.path);
|
|
1092
1197
|
if (!zone) {
|
|
1093
|
-
emit("SIT04", `polygon ${poly.path}
|
|
1198
|
+
emit("SIT04", `No zone corresponds to polygon ${poly.path}`, {
|
|
1094
1199
|
line: poly.line,
|
|
1095
1200
|
file: poly.file,
|
|
1096
1201
|
path: [poly.path],
|
|
1097
1202
|
});
|
|
1098
1203
|
continue;
|
|
1099
1204
|
}
|
|
1100
|
-
if (zone.attrs["site"] !== 1) continue;
|
|
1101
|
-
const declared = zone.attrs["area"];
|
|
1102
|
-
if (typeof declared === "number") {
|
|
1103
|
-
const derived = polygonAreaM2(poly.points);
|
|
1104
|
-
if (Math.abs(declared - derived) >= 0.05) {
|
|
1105
|
-
emit(
|
|
1106
|
-
"SIT05",
|
|
1107
|
-
`敷地面積の宣言と導出が食い違います: 宣言 ${declared}㎡ / 導出 ${derived.toFixed(2)}㎡`,
|
|
1108
|
-
{ line: zone.line, file: zone.file, path: [zone.path] },
|
|
1109
|
-
);
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
for (const s of withRect) {
|
|
1113
|
-
if (s.type === "exterior" || s.path.startsWith(poly.path + "/")) continue;
|
|
1114
|
-
// 照合するのは割付ではなく**導出された領域** — 敷地なりに切った外形はここで通る
|
|
1115
|
-
for (const r of regionOf(s)) {
|
|
1116
|
-
const out = shapeEscapesPolygon(r, poly.points, EPS_SITE);
|
|
1117
|
-
if (out) {
|
|
1118
|
-
emit("SIT03", `${s.path} が敷地形状からはみ出しています (${Math.round(out.x)},${Math.round(out.y)} 付近)`, {
|
|
1119
|
-
line: s.line,
|
|
1120
|
-
file: s.file,
|
|
1121
|
-
path: [s.path],
|
|
1122
|
-
});
|
|
1123
|
-
break;
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
1205
|
}
|
|
1128
1206
|
}
|