@kensnzk/koyu 0.5.0 → 0.13.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 +43 -11
- package/README.md +51 -11
- package/dist/axo.d.ts +16 -0
- package/dist/axo.d.ts.map +1 -0
- package/dist/axo.js +211 -0
- package/dist/axo.js.map +1 -0
- package/dist/check.d.ts +109 -0
- package/dist/check.d.ts.map +1 -0
- package/dist/check.js +957 -0
- package/dist/check.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +410 -0
- package/dist/cli.js.map +1 -0
- package/dist/diff.d.ts +105 -0
- package/dist/diff.d.ts.map +1 -0
- package/dist/diff.js +583 -0
- package/dist/diff.js.map +1 -0
- package/dist/fabric.d.ts +28 -0
- package/dist/fabric.d.ts.map +1 -0
- package/dist/fabric.js +105 -0
- package/dist/fabric.js.map +1 -0
- package/dist/graph.d.ts +118 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +627 -0
- package/dist/graph.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/light.d.ts +15 -0
- package/dist/light.d.ts.map +1 -0
- package/dist/light.js +53 -0
- package/dist/light.js.map +1 -0
- package/dist/mcp.d.ts +3 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +361 -0
- package/dist/mcp.js.map +1 -0
- package/dist/model.d.ts +379 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +464 -0
- package/dist/model.js.map +1 -0
- package/dist/parse-file.d.ts +9 -0
- package/dist/parse-file.d.ts.map +1 -0
- package/dist/parse-file.js +22 -0
- package/dist/parse-file.js.map +1 -0
- package/dist/parse.d.ts +16 -0
- package/dist/parse.d.ts.map +1 -0
- package/dist/parse.js +1040 -0
- package/dist/parse.js.map +1 -0
- package/dist/plan.d.ts +10 -0
- package/dist/plan.d.ts.map +1 -0
- package/dist/plan.js +354 -0
- package/dist/plan.js.map +1 -0
- package/dist/poly.d.ts +78 -0
- package/dist/poly.d.ts.map +1 -0
- package/dist/poly.js +277 -0
- package/dist/poly.js.map +1 -0
- package/dist/site.d.ts +24 -0
- package/dist/site.d.ts.map +1 -0
- package/dist/site.js +54 -0
- package/dist/site.js.map +1 -0
- package/dist/vertical.d.ts +176 -0
- package/dist/vertical.d.ts.map +1 -0
- package/dist/vertical.js +669 -0
- package/dist/vertical.js.map +1 -0
- package/examples/basement/main.muro +84 -0
- package/examples/comparison/README.md +64 -1
- package/examples/comparison/gen-ifc4.ts +1 -1
- package/examples/comparison/gen-ifcx.ts +2 -2
- package/examples/comparison/two-rooms.ifcx +1 -1
- package/examples/complex/L1.muro +132 -0
- package/examples/complex/assets.muro +17 -0
- package/examples/complex/basement.muro +40 -0
- package/examples/complex/core.muro +40 -0
- package/examples/complex/hotel.muro +117 -0
- package/examples/complex/main.muro +67 -0
- package/examples/complex/office.muro +41 -0
- package/examples/complex/plant.muro +34 -0
- package/examples/complex/podium.muro +140 -0
- package/examples/complex/site.muro +18 -0
- package/examples/house/L1.muro +16 -0
- package/examples/house/L2.muro +19 -0
- package/examples/house/assets.muro +9 -0
- package/examples/house/main.muro +27 -0
- package/examples/house/site.muro +31 -0
- package/examples/house.muro +3 -3
- package/examples/mansion.muro +18 -13
- package/examples/office.muro +1 -1
- package/examples/steps/01-one-room.muro +4 -0
- package/examples/steps/02-two-rooms.muro +5 -0
- package/examples/steps/03-door.muro +9 -0
- package/examples/steps/04-exterior.muro +15 -0
- package/examples/steps/05-two-storeys.muro +27 -0
- package/examples/steps/06-finished.muro +30 -0
- package/examples/steps/README.md +25 -0
- package/examples/tower/L1.muro +80 -0
- package/examples/tower/L11.muro +49 -0
- package/examples/tower/L2.muro +71 -0
- package/examples/tower/L3.muro +31 -0
- package/examples/tower/assets.muro +14 -0
- package/examples/tower/main.muro +37 -0
- package/examples/tower/site-geometry.muro +7 -0
- package/examples/tower/site.muro +33 -0
- package/examples/tower/typical.muro +131 -0
- package/examples/two-rooms.canonical.json +30 -3
- package/examples/two-rooms.muro +11 -7
- package/package.json +29 -2
- package/src/axo.ts +258 -0
- package/src/check.ts +948 -122
- package/src/cli.ts +175 -12
- package/src/diff.ts +676 -0
- package/src/fabric.ts +123 -0
- package/src/graph.ts +451 -61
- package/src/index.ts +38 -2
- package/src/light.ts +4 -7
- package/src/mcp.ts +397 -0
- package/src/model.ts +462 -67
- package/src/parse-file.ts +28 -0
- package/src/parse.ts +682 -45
- package/src/plan.ts +152 -14
- package/src/poly.ts +295 -0
- package/src/site.ts +19 -11
- package/src/vertical.ts +884 -0
- package/.github/workflows/ci.yml +0 -16
- package/.zenodo.json +0 -20
- package/CITATION.cff +0 -26
- package/docs/decisions/0001-notation-v0.md +0 -29
- package/docs/decisions/0002-height-and-offsets.md +0 -27
- package/docs/decisions/0003-uncounted-divisions.md +0 -36
- package/docs/decisions/0004-typical-floors.md +0 -21
- package/docs/decisions/0005-zones-and-unions.md +0 -23
- package/docs/decisions/0006-voids-and-light.md +0 -31
- package/docs/decisions/0007-semi-outdoor-air.md +0 -27
- package/docs/decisions/0008-vocabulary-and-level-attr.md +0 -23
- package/docs/decisions/0009-site-and-exterior.md +0 -29
- package/docs/ifc-coverage.md +0 -82
- package/docs/ifcx-notes.md +0 -25
- package/docs/img/house-L1.svg +0 -80
- package/docs/img/house-L2.svg +0 -53
- package/docs/img/mansion-L1.svg +0 -113
- package/docs/img/mansion-L10.svg +0 -111
- package/docs/img/mansion-L5.svg +0 -160
- package/docs/img/office-L1.svg +0 -116
- package/docs/img/office-L2.svg +0 -109
- package/docs/img/two-rooms.svg +0 -39
- package/docs/log/2026-07-22.md +0 -13
- package/docs/log/2026-07-23.md +0 -51
- package/docs/roadmap.md +0 -55
- package/docs/writing-architecture.md +0 -119
- package/spec/notation-v0.md +0 -164
- package/spec/vocabulary.md +0 -62
- package/test/core.test.ts +0 -171
- package/test/design2.test.ts +0 -97
- package/test/house.test.ts +0 -74
- package/test/mansion.test.ts +0 -99
- package/test/office.test.ts +0 -71
- package/test/uncounted.test.ts +0 -120
- package/test/vertical.test.ts +0 -75
- package/tsconfig.json +0 -13
package/dist/check.js
ADDED
|
@@ -0,0 +1,957 @@
|
|
|
1
|
+
// koyu — 整合チェック
|
|
2
|
+
// コミットのたびに自動で回る検証の芽。構成の矛盾はここで言葉として現れる。
|
|
3
|
+
// 高さ方向の一貫性 — BIMが3Dであることで暗黙に担保していたもの — は、
|
|
4
|
+
// ここでは宣言された不変量 (天井高 + 上階slab ≤ 階高) の検査として明示的に持つ。
|
|
5
|
+
// 吹抜け (type:void) はこの不変量の宣言的な免除である。
|
|
6
|
+
//
|
|
7
|
+
// 診断契約 (ADR-0016): 一次形式は checkDiagnostics の Diagnostic[] — code / severity /
|
|
8
|
+
// 日本語本文 / 出所 / 対象パス。check は互換層で、従来の文字列 (位置接頭辞つき) を組み立てる。
|
|
9
|
+
// severity はコードの不変属性 — 重さを変えたくなったら新コードを切る。
|
|
10
|
+
import { placeBand, placeOpening, planOverlap, segmentsFor, segmentLength, envelopeGaps, drawnCut, spacesOverlap, } from "./graph.js";
|
|
11
|
+
import { heff, isSemiOutdoor, levelsSorted, columnSites, columnsFor, pointInPolygon, rectToPoly, regionOf, srcRef, polygonAreaM2, polygonSelfIntersection, shapeEscapesPolygon, } from "./model.js";
|
|
12
|
+
import { cutsInWindow } from "./poly.js";
|
|
13
|
+
import { runDecls, runIssues } from "./vertical.js";
|
|
14
|
+
/**
|
|
15
|
+
* 診断コードの台帳 — 全コードと規範severity。specの表 (semantics.md §5) とテストで一致を守る。
|
|
16
|
+
* BND07 は欠番 — 「接しているのに境界が無い」警告はADR-0014 (既定境界) で廃止された。
|
|
17
|
+
* SYN01 は構文・合成エラー (SourceError) の写し — checkは例外を診断にしない。CLIの check --json だけが写す。
|
|
18
|
+
*/
|
|
19
|
+
export const DIAGNOSTIC_CODES = {
|
|
20
|
+
REF01: "error", // 境界が未定義の空間パスを参照
|
|
21
|
+
BND01: "error", // 同一空間同士の境界
|
|
22
|
+
BND02: "error", // 同一空間対の境界の重複 (edge限定まで同一 — ADR-0013)
|
|
23
|
+
BND03: "error", // 異レベルの空間への壁境界
|
|
24
|
+
BND04: "error", // 接していない空間の境界
|
|
25
|
+
BND05: "warning", // 同一空間対でedge限定の有無が混在
|
|
26
|
+
BND06: "warning", // 境界線分がゼロ
|
|
27
|
+
LVL01: "error", // レベルzの重複
|
|
28
|
+
GEO01: "error", // 自らの領域 (合併の矩形) 同士の重なり
|
|
29
|
+
GEO02: "error", // 同一レベルの空間同士の重なり
|
|
30
|
+
VRT01: "error", // 垂直境界の前提 (領域とレベルを持つ空間同士)
|
|
31
|
+
VRT02: "error", // 非隣接レベル間の垂直境界
|
|
32
|
+
VRT03: "error", // 平面が重ならない垂直境界
|
|
33
|
+
VRT04: "warning", // void境界の上側が非void
|
|
34
|
+
VRT05: "warning", // 垂直境界の開口 (解釈されない)
|
|
35
|
+
VRT06: "warning", // 垂直境界のseg (解釈されない)
|
|
36
|
+
OPN01: "error", // hingeの軸違い
|
|
37
|
+
OPN02: "error", // 開口同士の重なり
|
|
38
|
+
OPN03: "warning", // open境界の開口 (通行に影響しない)
|
|
39
|
+
OPN04: "error", // 開口を置ける境界線分が無い
|
|
40
|
+
OPN05: "error", // 境界線分が複数で曖昧
|
|
41
|
+
OPN06: "error", // 開口の幅が線分長を超える
|
|
42
|
+
OPN07: "error", // 開口の明示位置の軸違い
|
|
43
|
+
OPN08: "error", // 開口の明示位置のはみ出し
|
|
44
|
+
SEG01: "error", // 領域を持たない空間へのarea
|
|
45
|
+
SEG02: "warning", // areaのはみ出し
|
|
46
|
+
SEG03: "warning", // open境界のseg (解釈されない)
|
|
47
|
+
SEG04: "error", // segを置ける境界線分が無い
|
|
48
|
+
SEG05: "error", // segの境界線分が複数で曖昧
|
|
49
|
+
SEG06: "error", // segの幅が線分長を超える
|
|
50
|
+
SEG07: "error", // segの明示位置の軸違い
|
|
51
|
+
SEG08: "error", // segの明示位置のはみ出し
|
|
52
|
+
ZON01: "warning", // 空のゾーン
|
|
53
|
+
ZON02: "warning", // ゾーンと同パスの空間
|
|
54
|
+
HGT01: "error", // 上階への食い込み (高さ不変量違反)
|
|
55
|
+
HGT02: "error", // 部分吹抜けの被覆不足
|
|
56
|
+
HGT03: "warning", // 上階slab未宣言で高さ検査ができない
|
|
57
|
+
HGT04: "warning", // 天井高不明で高さ検査ができない
|
|
58
|
+
HGT05: "warning", // レベルが特定できない領域つき空間
|
|
59
|
+
SIT01: "error", // 敷地形状の重複頂点
|
|
60
|
+
SIT02: "error", // 敷地形状の自己交差
|
|
61
|
+
SIT03: "error", // 建物の敷地形状からのはみ出し
|
|
62
|
+
SIT04: "warning", // 対応するゾーンの無いpolygon
|
|
63
|
+
SIT05: "warning", // 敷地面積の宣言と導出の食い違い
|
|
64
|
+
UID01: "error", // 数字だけのuid (ADR-0015)
|
|
65
|
+
UID02: "error", // 空白を含むuid
|
|
66
|
+
UID03: "error", // uidの重複
|
|
67
|
+
ATT01: "error", // 解釈される属性の値が数値でない (ADR-0028)
|
|
68
|
+
ATT02: "error", // 解釈される属性の値が台帳の語彙にない (ADR-0028)
|
|
69
|
+
DAY01: "error", // daylightの値が 0/1 以外 (ADR-0020)
|
|
70
|
+
RUN01: "error", // 一つの空間に縦動線の宣言が複数 (ADR-0021)
|
|
71
|
+
RUN02: "error", // 縦動線の値が上る向き (N/E/S/W) でない
|
|
72
|
+
RUN03: "error", // 縦動線の領域が矩形一つでない / レベルが不明
|
|
73
|
+
RUN04: "warning", // 上にレベルが無く縦動線の形が生成できない
|
|
74
|
+
RUN05: "error", // form の値が不正、または形が決まらない
|
|
75
|
+
RUN06: "warning", // 導出された段の寸法が窮屈 (書かないが検査する)
|
|
76
|
+
RUN07: "warning", // 導出された勾配が宣言・常用域から外れる
|
|
77
|
+
RUN08: "warning", // 縦動線の形はあるが上下を繋ぐ垂直境界が無い
|
|
78
|
+
LIN01: "error", // 描かれた線が二つの空間を分離しない (ADR-0022)
|
|
79
|
+
LIN02: "error", // 垂直境界に描かれた線
|
|
80
|
+
LIN03: "warning", // 描かれた線が何も切っていない
|
|
81
|
+
ENV01: "warning", // 外皮に穴 — 何にも面していない外周 (ADR-0025)
|
|
82
|
+
COL01: "warning", // 柱の宣言に対して立つ柱が0本 (ADR-0023)
|
|
83
|
+
COL02: "warning", // 同じ通りの交点に複数の柱宣言が重なる (先の宣言が勝つ)
|
|
84
|
+
VER01: "error", // koyu 0.1 での既定境界の導出 (ADR-0017)
|
|
85
|
+
VER02: "error", // koyu 0.3以前で採光の推定対象だった型に daylight が無い (ADR-0020)
|
|
86
|
+
VER03: "error", // koyu 0.4以前のファイルに0.5の語 (縦動線・線・柱・地下)
|
|
87
|
+
SYN01: "error", // 構文・合成エラー (SourceError の写し — check --json のみ)
|
|
88
|
+
};
|
|
89
|
+
const EPS = 0.5;
|
|
90
|
+
/** 敷地まわりの幾何の許容 (境界上は内側扱い) — ADR-0011の1mm */
|
|
91
|
+
const EPS_SITE = 1;
|
|
92
|
+
const VERTICAL = new Set(["stair", "shaft", "void"]);
|
|
93
|
+
/** 0.3以前が採光の対象と推定していた型 (ADR-0020で廃止)。旧版の受理条件の判定にだけ使う — 意味論には効かない */
|
|
94
|
+
const LEGACY_DAYLIT = new Set(["unit", "room", "ldk", "bedroom", "living"]);
|
|
95
|
+
/** 互換層 — 従来の文字列形式。位置を持つ診断は「file:N行目: 本文」に組み立てる */
|
|
96
|
+
/**
|
|
97
|
+
* 解釈される属性の値の台帳 (ADR-0028)。**spec/vocabulary.md の★が契約であり、これはその写しである。**
|
|
98
|
+
*
|
|
99
|
+
* `of` があれば列挙、無ければ正の数値。ここに無い属性は自由に書けてそのまま運ばれる
|
|
100
|
+
* (台帳の規則3)。daylight は DAY01 が、form は RUN05 が、縦動線の向きは RUN02 が
|
|
101
|
+
* 既に守っているので重ねない。
|
|
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
|
+
function attrSubjects(model) {
|
|
123
|
+
const out = [];
|
|
124
|
+
for (const s of model.spaces.values()) {
|
|
125
|
+
out.push([s.path, { rules: ATTR_RULES["space"], of: s.attrs }, { line: s.line, file: s.file, path: [s.path] }]);
|
|
126
|
+
}
|
|
127
|
+
for (const z of model.zones.values()) {
|
|
128
|
+
out.push([`ゾーン ${z.path}`, { rules: ATTR_RULES["zone"], of: z.attrs }, { line: z.line, file: z.file, path: [z.path] }]);
|
|
129
|
+
}
|
|
130
|
+
for (const b of model.boundaries) {
|
|
131
|
+
const at = { line: b.line, file: b.file, path: [b.a, b.b] };
|
|
132
|
+
out.push([`境界 ${b.a} | ${b.b}`, { rules: ATTR_RULES["boundary"], of: b.attrs }, at]);
|
|
133
|
+
for (const o of b.openings) {
|
|
134
|
+
out.push([
|
|
135
|
+
`${o.kind} (${b.a} | ${b.b})`,
|
|
136
|
+
{ rules: ATTR_RULES["opening"], of: o.attrs },
|
|
137
|
+
{ line: o.line, file: b.file, path: [b.a, b.b] },
|
|
138
|
+
]);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return out;
|
|
142
|
+
}
|
|
143
|
+
/** 書かれた通り語で矩形を名指す — 「どの組が重なっているか」を言えるようにする */
|
|
144
|
+
function gridRefText(s, i) {
|
|
145
|
+
const g = s.grids[i];
|
|
146
|
+
if (!g)
|
|
147
|
+
return `#${i + 1}`;
|
|
148
|
+
return `${g.xa}..${g.xb} ${g.ya}..${g.yb}`;
|
|
149
|
+
}
|
|
150
|
+
export function check(model) {
|
|
151
|
+
const errors = [];
|
|
152
|
+
const warnings = [];
|
|
153
|
+
for (const d of checkDiagnostics(model)) {
|
|
154
|
+
const text = d.line !== undefined ? `${srcRef(d.line, d.file)}: ${d.message}` : d.message;
|
|
155
|
+
(d.severity === "error" ? errors : warnings).push(text);
|
|
156
|
+
}
|
|
157
|
+
return { errors, warnings };
|
|
158
|
+
}
|
|
159
|
+
export function checkDiagnostics(model) {
|
|
160
|
+
const diags = [];
|
|
161
|
+
/** line:0 は「位置なし」— フィールドごと省略する (既定境界などの導出物) */
|
|
162
|
+
const emit = (code, message, at = {}) => {
|
|
163
|
+
diags.push({
|
|
164
|
+
code,
|
|
165
|
+
severity: DIAGNOSTIC_CODES[code],
|
|
166
|
+
message,
|
|
167
|
+
...(at.line ? { line: at.line } : {}),
|
|
168
|
+
...(at.line && at.file !== undefined ? { file: at.file } : {}),
|
|
169
|
+
...(at.path ? { path: at.path } : {}),
|
|
170
|
+
...(at.related ? { related: at.related } : {}),
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
const loc = (line, file) => ({
|
|
174
|
+
line,
|
|
175
|
+
...(file !== undefined ? { file } : {}),
|
|
176
|
+
});
|
|
177
|
+
const withRect = [...model.spaces.values()].filter((s) => s.rects.length > 0);
|
|
178
|
+
const levels = levelsSorted(model);
|
|
179
|
+
const levelIndex = new Map(levels.map((l, i) => [l.name, i]));
|
|
180
|
+
const ctx = { model, emit, loc, withRect, levels, levelIndex };
|
|
181
|
+
// **節の順序が出力の順序である。**互換層は診断を出た順に文字列へ写すので、
|
|
182
|
+
// ここの並びを入れ替えると check の出力が変わる (test/diagnostics.test.ts が固定している)。
|
|
183
|
+
// 節の粒度は「走査単位」であって「診断コードの族」ではない — 一つのループが
|
|
184
|
+
// 複数のコードを出すとき、それらは走査の順に交互に出る。族で割ると並びが崩れる
|
|
185
|
+
checkBoundaryRefs(ctx);
|
|
186
|
+
checkBoundaryIdentity(ctx);
|
|
187
|
+
checkLevelDepth(ctx);
|
|
188
|
+
checkSelfOverlap(ctx);
|
|
189
|
+
checkSpaceOverlap(ctx);
|
|
190
|
+
checkDaylightScope(ctx);
|
|
191
|
+
checkAttrValues(ctx);
|
|
192
|
+
checkRuns(ctx);
|
|
193
|
+
checkDrawnLines(ctx);
|
|
194
|
+
checkEnvelopeGaps(ctx);
|
|
195
|
+
checkColumns(ctx);
|
|
196
|
+
checkLanguageVersion(ctx);
|
|
197
|
+
checkUids(ctx);
|
|
198
|
+
checkBoundaryValidity(ctx);
|
|
199
|
+
checkAreas(ctx);
|
|
200
|
+
checkZones(ctx);
|
|
201
|
+
checkHeights(ctx);
|
|
202
|
+
checkOrphanSpaces(ctx);
|
|
203
|
+
checkSite(ctx);
|
|
204
|
+
return diags;
|
|
205
|
+
}
|
|
206
|
+
/** 吹抜けが下階の空間の平面をどれだけ覆うか (0..1) */
|
|
207
|
+
function voidCoverage(s, partners) {
|
|
208
|
+
let inter = 0;
|
|
209
|
+
for (const r of s.rects) {
|
|
210
|
+
for (const p of partners) {
|
|
211
|
+
for (const pr of p.rects) {
|
|
212
|
+
const o = planOverlap(r, pr);
|
|
213
|
+
if (o)
|
|
214
|
+
inter += (o.x2 - o.x1) * (o.y2 - o.y1);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
const area = s.rects.reduce((sum, r) => sum + (r.x2 - r.x1) * (r.y2 - r.y1), 0);
|
|
219
|
+
return area > 0 ? inter / area : 0;
|
|
220
|
+
}
|
|
221
|
+
/** 境界の参照先 — REF01 / BND01 */
|
|
222
|
+
function checkBoundaryRefs(ctx) {
|
|
223
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
224
|
+
// 境界の参照先
|
|
225
|
+
for (const b of model.boundaries) {
|
|
226
|
+
for (const p of [b.a, b.b]) {
|
|
227
|
+
if (!model.spaces.has(p)) {
|
|
228
|
+
emit("REF01", `未定義の空間を参照しています: ${p}`, { line: b.line, file: b.file, path: [b.a, b.b] });
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (b.a === b.b) {
|
|
232
|
+
emit("BND01", `同じ空間同士の境界は書けません: ${b.a}`, { line: b.line, file: b.file, path: [b.a, b.b] });
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/** 境界の同一性 — BND02 / BND05 */
|
|
237
|
+
function checkBoundaryIdentity(ctx) {
|
|
238
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
239
|
+
// 境界の同一性: 同じ空間対 (edge限定まで同一) の重複宣言は矛盾の温床 — エラー (ADR-0013)。
|
|
240
|
+
// wall/openの食い違いもこの検査が捕まえる。edge限定の有無が混在する対は線分が重なるため警告
|
|
241
|
+
const seenBoundary = new Map();
|
|
242
|
+
const pairEdges = new Map();
|
|
243
|
+
for (const b of model.boundaries) {
|
|
244
|
+
const pair = [b.a, b.b].sort().join(" | ");
|
|
245
|
+
// 描かれた線を持つ境界は、線そのものが実現なので同一性の鍵に線の綴りが入る。
|
|
246
|
+
// 同じ空間対に二本の線 (二箇所の隅切りなど) を引くのは矛盾ではない
|
|
247
|
+
const key = `${pair}#${b.edge ?? ""}#${b.drawn ? `${b.drawn.aRef}..${b.drawn.bRef}` : ""}`;
|
|
248
|
+
const prev = seenBoundary.get(key);
|
|
249
|
+
if (prev) {
|
|
250
|
+
emit("BND02", `境界が重複しています: ${pair}${b.edge ? ` edge:${b.edge}` : ""} (既出: ${srcRef(prev.line, prev.file)})`, { line: b.line, file: b.file, path: [b.a, b.b], related: [loc(prev.line, prev.file)] });
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
seenBoundary.set(key, b);
|
|
254
|
+
}
|
|
255
|
+
// 線を持つ境界は外周の残りを取らない (線が線分そのもの) ので、edge の混在の話に入れない
|
|
256
|
+
if (!b.drawn) {
|
|
257
|
+
const set = pairEdges.get(pair) ?? new Set();
|
|
258
|
+
set.add(b.edge ?? "");
|
|
259
|
+
pairEdges.set(pair, set);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
for (const [pair, edges] of pairEdges) {
|
|
263
|
+
if (edges.has("") && edges.size > 1) {
|
|
264
|
+
// 集合に対する診断でも、集合を作った宣言の行は必ず指す —
|
|
265
|
+
// 「どこかで併存している」だけでは直す場所が無い
|
|
266
|
+
const members = model.boundaries.filter((b) => !b.drawn && [b.a, b.b].sort().join(" | ") === pair);
|
|
267
|
+
const first = members.find((b) => !b.edge) ?? members[0];
|
|
268
|
+
emit("BND05", `同じ空間対に edge 限定つきと無しの境界が併存しています (線分が重なります): ${pair}`, {
|
|
269
|
+
...(first ? { line: first.line, file: first.file } : {}),
|
|
270
|
+
path: pair.split(" | "),
|
|
271
|
+
related: members.filter((b) => b !== first).map((b) => loc(b.line, b.file)),
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
/** レベルの重複 — LVL01 */
|
|
277
|
+
function checkLevelDepth(ctx) {
|
|
278
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
279
|
+
// レベルの重複
|
|
280
|
+
for (let i = 1; i < levels.length; i++) {
|
|
281
|
+
if (Math.abs(levels[i].z - levels[i - 1].z) < EPS) {
|
|
282
|
+
emit("LVL01", `レベル ${levels[i - 1].name} と ${levels[i].name} のzが同じです`, {
|
|
283
|
+
line: levels[i].line,
|
|
284
|
+
file: levels[i].file,
|
|
285
|
+
related: [loc(levels[i - 1].line, levels[i - 1].file)],
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
/** 自らの領域の重なり — GEO01 */
|
|
291
|
+
function checkSelfOverlap(ctx) {
|
|
292
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
293
|
+
// 自らの領域 (合併の矩形同士) の重なり
|
|
294
|
+
for (const s of withRect) {
|
|
295
|
+
for (let i = 0; i < s.rects.length; i++) {
|
|
296
|
+
for (let j = i + 1; j < s.rects.length; j++) {
|
|
297
|
+
if (planOverlap(s.rects[i], s.rects[j])) {
|
|
298
|
+
// どの組かを言わなければ、三つ重なる空間にバイト同一の診断が三件並ぶ
|
|
299
|
+
emit("GEO01", `${s.path} の領域同士が重なっています: ${gridRefText(s, i)} と ${gridRefText(s, j)}`, {
|
|
300
|
+
line: s.line,
|
|
301
|
+
file: s.file,
|
|
302
|
+
path: [s.path],
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
/** 空間同士の重なり — GEO02 */
|
|
310
|
+
function checkSpaceOverlap(ctx) {
|
|
311
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
312
|
+
// 同一レベルでの空間同士の重なり
|
|
313
|
+
for (let i = 0; i < withRect.length; i++) {
|
|
314
|
+
for (let j = i + 1; j < withRect.length; j++) {
|
|
315
|
+
const a = withRect[i];
|
|
316
|
+
const b = withRect[j];
|
|
317
|
+
if (a.level !== b.level)
|
|
318
|
+
continue;
|
|
319
|
+
if (spacesOverlap(a, b)) {
|
|
320
|
+
emit("GEO02", `空間の領域が重なっています: ${a.path} と ${b.path}`, {
|
|
321
|
+
line: a.line,
|
|
322
|
+
file: a.file,
|
|
323
|
+
path: [a.path, b.path],
|
|
324
|
+
related: [loc(b.line, b.file)],
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
/** 採光の対象の宣言 — DAY01 */
|
|
331
|
+
function checkDaylightScope(ctx) {
|
|
332
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
333
|
+
// 採光の対象の宣言 (ADR-0020): daylight は「この室に 1/7 の判定を掛ける」という二値の宣言。
|
|
334
|
+
// 綴りの揺れ (daylight:true / daylight:yes) が黙って対象外に落ちるのを防ぐ
|
|
335
|
+
for (const s of model.spaces.values()) {
|
|
336
|
+
const v = s.attrs["daylight"];
|
|
337
|
+
if (v === undefined)
|
|
338
|
+
continue;
|
|
339
|
+
if (v !== 0 && v !== 1) {
|
|
340
|
+
emit("DAY01", `daylight は 1 (採光判定の対象) か 0 (対象外) です: ${s.path} に daylight:${v}`, {
|
|
341
|
+
line: s.line,
|
|
342
|
+
file: s.file,
|
|
343
|
+
path: [s.path],
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
/** 解釈される属性の値 — ATT01 / ATT02 */
|
|
349
|
+
function checkAttrValues(ctx) {
|
|
350
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
351
|
+
// 解釈される属性の値 (ADR-0028): **書いたのに解釈されなかった値は、黙って既定へ落とさない。**
|
|
352
|
+
//
|
|
353
|
+
// daylight だけが DAY01 で守られていて、他の★属性は素通りだった。帰結は黙殺である —
|
|
354
|
+
// `site:yes` は敷地の検査 (SIT03 error) を丸ごと無効にし、`h:35OO` は高さ不変量
|
|
355
|
+
// (HGT01 error) を消し、`ceiling:none` は天井を張り、`turn:l` は階段を鏡像にする。
|
|
356
|
+
// どれも check は緑のままだった。台帳 (spec/vocabulary.md) が契約である以上、
|
|
357
|
+
// 台帳の型に合わない値はエラーである。
|
|
358
|
+
for (const [where, attrs, at] of attrSubjects(model)) {
|
|
359
|
+
for (const [key, rule] of Object.entries(attrs.rules)) {
|
|
360
|
+
const v = attrs.of[key];
|
|
361
|
+
if (v === undefined)
|
|
362
|
+
continue;
|
|
363
|
+
if (rule.of) {
|
|
364
|
+
if (!rule.of.includes(v)) {
|
|
365
|
+
emit("ATT02", `${where} の ${key} は ${rule.of.join(" / ")} のどれかです: ${key}:${v}`, at);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
else if (typeof v !== "number" || !(v > 0)) {
|
|
369
|
+
emit("ATT01", `${where} の ${key} は正の数値で書きます: ${key}:${v}`, at);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
/** 縦動線 — RUN01〜RUN08 */
|
|
375
|
+
function checkRuns(ctx) {
|
|
376
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
377
|
+
// 縦動線 (ADR-0021): 宣言の妥当性と、**書かれていない導出値**の妥当性。
|
|
378
|
+
// 段数も踏面も勾配も書かない — だから導出したものを検査する
|
|
379
|
+
for (const i of runIssues(model)) {
|
|
380
|
+
emit(i.code, i.message, { line: i.line, file: i.file, path: [i.path] });
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
/** 描かれた線 — LIN01〜LIN03 */
|
|
384
|
+
function checkDrawnLines(ctx) {
|
|
385
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
386
|
+
// 描かれた線 (ADR-0022): 線は二つの空間を実際に分離しなければならない。
|
|
387
|
+
// 「宣言どおりに切れているか」は arrangement の検査であり、check の仕事
|
|
388
|
+
for (const b of model.boundaries) {
|
|
389
|
+
if (!b.drawn)
|
|
390
|
+
continue;
|
|
391
|
+
const bAt = { line: b.drawn.line, file: b.file, path: [b.a, b.b] };
|
|
392
|
+
if (VERTICAL.has(b.kind)) {
|
|
393
|
+
emit("LIN02", `垂直境界に線は描けません (線は平面を区切る行為です): ${b.a} | ${b.b}`, bAt);
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
396
|
+
const sa = model.spaces.get(b.a);
|
|
397
|
+
const sb = model.spaces.get(b.b);
|
|
398
|
+
if (!sa || !sb)
|
|
399
|
+
continue;
|
|
400
|
+
if (sa.rects.length === 0 && sb.rects.length === 0) {
|
|
401
|
+
emit("LIN01", `領域を持たない空間同士に線は描けません: ${b.a} | ${b.b}`, bAt);
|
|
402
|
+
continue;
|
|
403
|
+
}
|
|
404
|
+
// 判定と操作を同じ関数に通す (ADR-0027)。窓の中で分離が決まらなければ LIN01、
|
|
405
|
+
// 決まるが実際には何も切っていなければ LIN03。以前は判定だけが別の窓 (線分の
|
|
406
|
+
// 外接矩形) を使っていたので、軸平行の線では窓が潰れて必ず誤報していた
|
|
407
|
+
const cut = drawnCut(sa, sb, b.drawn.a, b.drawn.b);
|
|
408
|
+
if (!cut) {
|
|
409
|
+
emit("LIN01", sa.rects.length > 0 && sb.rects.length > 0
|
|
410
|
+
? `線 ${b.drawn.aRef}..${b.drawn.bRef} は ${b.a} と ${b.b} を分離していません (二つの割付が線の両側に来るように引きます)`
|
|
411
|
+
: `線 ${b.drawn.aRef}..${b.drawn.bRef} が割付をちょうど二等分していて、どちらを残すか決まりません`, bAt);
|
|
412
|
+
continue;
|
|
413
|
+
}
|
|
414
|
+
const target = cut.solo ? [cut.solo] : [sa, sb];
|
|
415
|
+
if (!target.some((s) => cutsInWindow(s.rects.map(rectToPoly), cut.window, b.drawn.a, b.drawn.b))) {
|
|
416
|
+
emit("LIN03", `線 ${b.drawn.aRef}..${b.drawn.bRef} は何も切っていません (既定の隣接線と同じか、割付の外にあります)`, bAt);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
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
|
+
/** 柱 — COL01 / COL02 */
|
|
466
|
+
function checkColumns(ctx) {
|
|
467
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
468
|
+
// 柱 (ADR-0023): 位置は書かれない。宣言に対して一本も立たなければ、
|
|
469
|
+
// 通りか階の指定が実際の床とすれ違っている
|
|
470
|
+
//
|
|
471
|
+
// **母集団は宣言である。**「このレベルに何本立ったか」ではなく「この宣言から何本立ったか」を
|
|
472
|
+
// 問う。前者を数えると、同じ階の別の宣言が一本でも立てた瞬間に、一本も立たない宣言が
|
|
473
|
+
// 黙って通る (ADR-0028)。Column.decl がその帰属を持つ。
|
|
474
|
+
const stood = new Map();
|
|
475
|
+
const levelsOfDecl = new Set();
|
|
476
|
+
for (const c of model.columns)
|
|
477
|
+
for (const lv of c.levels)
|
|
478
|
+
levelsOfDecl.add(lv);
|
|
479
|
+
for (const lv of levelsOfDecl) {
|
|
480
|
+
for (const col of columnsFor(model, lv))
|
|
481
|
+
stood.set(col.decl, (stood.get(col.decl) ?? 0) + 1);
|
|
482
|
+
}
|
|
483
|
+
for (let ci = 0; ci < model.columns.length; ci++) {
|
|
484
|
+
const c = model.columns[ci];
|
|
485
|
+
if ((stood.get(ci) ?? 0) > 0)
|
|
486
|
+
continue;
|
|
487
|
+
const at = { line: c.line, file: c.file };
|
|
488
|
+
// 一本も立たない理由は二つある。**狙う交点に床が無い**か、床はあるが先の宣言に
|
|
489
|
+
// 取られたか。後者を「床がありません」と言うと、直しようのない場所へ人を送る
|
|
490
|
+
const sites = new Set(c.levels.flatMap((lv) => columnSites(model, c, lv).map((p) => `${lv}|${p.grid}`)));
|
|
491
|
+
if (sites.size > 0) {
|
|
492
|
+
// 影を作ったのは、この宣言と同じ交点に**実際に立った**先の宣言だけである
|
|
493
|
+
const shadow = model.columns.filter((o, oi) => {
|
|
494
|
+
if (oi >= ci)
|
|
495
|
+
return false;
|
|
496
|
+
return o.levels.some((lv) => columnsFor(model, lv).some((k) => k.decl === oi && sites.has(`${lv}|${k.grid}`)));
|
|
497
|
+
});
|
|
498
|
+
emit("COL02", `この柱の宣言 (${c.levels.join(",")} ${c.size}角) は同じ交点を先の宣言に取られていて、一本も立ちません (同じ交点では先の宣言が勝ちます)`, { ...at, related: shadow.map((o) => loc(o.line, o.file)) });
|
|
499
|
+
}
|
|
500
|
+
else {
|
|
501
|
+
emit("COL01", `柱の宣言に対して立つ柱がありません (通りの交点に床がありません): ${c.levels.join(",")} ${c.size}角`, at);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
/** 言語版の受理条件 — VER01〜VER03 */
|
|
506
|
+
function checkLanguageVersion(ctx) {
|
|
507
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
508
|
+
// 言語版の受理条件 (ADR-0017): 旧版は意味保存の場合のみ受理する。
|
|
509
|
+
// 既定境界 (ADR-0014) が導出されるファイルは、0.1の意味 (境界なし+警告) と食い違う — エラーで二択を示す
|
|
510
|
+
if (model.version === "0.1") {
|
|
511
|
+
for (const b of model.boundaries) {
|
|
512
|
+
if (b.derived) {
|
|
513
|
+
emit("VER01", `koyu 0.1 のファイルに境界が宣言されていない接触ペアがあります: ${b.a} | ${b.b} — 0.2では既定の壁が導出され意味が変わります。境界を宣言するか、koyu 0.2 へ上げます`, { path: [b.a, b.b] });
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
// 0.3以前は型から採光の対象を推定していた (ADR-0020で廃止)。推定対象だった型の空間に daylight が
|
|
518
|
+
// 書かれていなければ、0.4では判定から黙って外れる — 意味が変わるのでエラーで二択を示す
|
|
519
|
+
if (["0.1", "0.2", "0.3"].includes(model.version)) {
|
|
520
|
+
for (const s of model.spaces.values()) {
|
|
521
|
+
if (!LEGACY_DAYLIT.has(s.type) || s.attrs["daylight"] !== undefined)
|
|
522
|
+
continue;
|
|
523
|
+
emit("VER02", `koyu ${model.version} のファイルに daylight の無い ${s.type} があります: ${s.path} — 0.4では型から採光の対象を推定しないので判定から外れます。daylight:1 (対象) か daylight:0 (対象外) を書いてから koyu 0.4 へ上げます`, { line: s.line, file: s.file, path: [s.path] });
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
// 0.5 で入った語 (縦動線の宣言・描かれた線・柱・地下) は 0.4 以前の処理系が知らない。
|
|
527
|
+
// 知らない処理系では黙って形が生成されないので、版を上げずに使うのはエラー (ADR-0017 決定3)
|
|
528
|
+
if (model.version !== "0.5") {
|
|
529
|
+
const older = `koyu ${model.version} のファイルに 0.5 の語があります`;
|
|
530
|
+
for (const s of model.spaces.values()) {
|
|
531
|
+
const d = runDecls(s);
|
|
532
|
+
if (d.length > 0) {
|
|
533
|
+
emit("VER03", `${older}: ${s.path} の ${d[0].device}: (縦動線) — koyu 0.5 へ上げます`, {
|
|
534
|
+
line: s.line,
|
|
535
|
+
file: s.file,
|
|
536
|
+
path: [s.path],
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
for (const b of model.boundaries) {
|
|
541
|
+
if (b.drawn) {
|
|
542
|
+
emit("VER03", `${older}: ${b.a} | ${b.b} の line (描かれた線) — koyu 0.5 へ上げます`, {
|
|
543
|
+
line: b.drawn.line,
|
|
544
|
+
file: b.file,
|
|
545
|
+
path: [b.a, b.b],
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
for (const c of model.columns) {
|
|
550
|
+
emit("VER03", `${older}: column (柱) — koyu 0.5 へ上げます`, { line: c.line, file: c.file });
|
|
551
|
+
}
|
|
552
|
+
for (const l of Object.values(model.levels)) {
|
|
553
|
+
if (l.underground) {
|
|
554
|
+
emit("VER03", `${older}: level ${l.name} の underground: — koyu 0.5 へ上げます`, {
|
|
555
|
+
line: l.line,
|
|
556
|
+
file: l.file,
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
/** uid — UID01〜UID03 */
|
|
563
|
+
function checkUids(ctx) {
|
|
564
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
565
|
+
// uid (ADR-0015): 不透明トークン、space/zone横断でモデル全体一意。
|
|
566
|
+
// 数字だけの形は禁じる — parseの数値化で 0123 が 123 になり、書いたトークンの区別が失われる
|
|
567
|
+
const uidOwners = new Map();
|
|
568
|
+
const collectUid = (kind, path, attrs, line, file) => {
|
|
569
|
+
const v = attrs["uid"];
|
|
570
|
+
if (v === undefined)
|
|
571
|
+
return;
|
|
572
|
+
if (typeof v === "number") {
|
|
573
|
+
emit("UID01", `uid は数字だけのトークンにできません: uid:${v} (sp-${v} のような形にします)`, {
|
|
574
|
+
line,
|
|
575
|
+
file,
|
|
576
|
+
path: [path],
|
|
577
|
+
});
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
if (v === "" || /\s/.test(v)) {
|
|
581
|
+
emit("UID02", `uid に空白は使えません: "${v}"`, { line, file, path: [path] });
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
const arr = uidOwners.get(v) ?? [];
|
|
585
|
+
arr.push({ kind, path, line, file });
|
|
586
|
+
uidOwners.set(v, arr);
|
|
587
|
+
};
|
|
588
|
+
for (const s of model.spaces.values())
|
|
589
|
+
collectUid("space", s.path, s.attrs, s.line, s.file);
|
|
590
|
+
for (const z of model.zones.values())
|
|
591
|
+
collectUid("zone", z.path, z.attrs, z.line, z.file);
|
|
592
|
+
for (const [uid, owners] of uidOwners) {
|
|
593
|
+
if (owners.length > 1) {
|
|
594
|
+
emit("UID03", `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)) });
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
/** 境界の妥当性 — VRT / BND03〜06 / OPN / SEG */
|
|
599
|
+
function checkBoundaryValidity(ctx) {
|
|
600
|
+
const { model, emit } = ctx;
|
|
601
|
+
// 境界の妥当性。**一本のループを保つ** — 一つの境界が出す複数のコードは
|
|
602
|
+
// 走査の順に固まって出るので、コードの族で節に割ると並びが崩れる (ADR-0028)。
|
|
603
|
+
// ループの `continue` は「この境界の残りを飛ばす」を意味するので、
|
|
604
|
+
// 段に切り出すときは**呼び出し側の continue として残す** — 判定の綴りを
|
|
605
|
+
// ヘルパの中へ持ち込むと、同じ条件が二箇所に分かれて片方だけ直る
|
|
606
|
+
for (const b of model.boundaries) {
|
|
607
|
+
const sa = model.spaces.get(b.a);
|
|
608
|
+
const sb = model.spaces.get(b.b);
|
|
609
|
+
if (!sa || !sb)
|
|
610
|
+
continue; // 未定義の参照は REF01 が言う — 形の検査には進まない
|
|
611
|
+
const bAt = { line: b.line, file: b.file, path: [b.a, b.b] };
|
|
612
|
+
if (VERTICAL.has(b.kind)) {
|
|
613
|
+
checkVerticalBoundary(ctx, b, sa, sb, bAt);
|
|
614
|
+
continue; // 垂直境界は水平の検査 (線分・開口・seg) を一切受けない
|
|
615
|
+
}
|
|
616
|
+
if (sa.rects.length > 0 && sb.rects.length > 0 && sa.level !== sb.level) {
|
|
617
|
+
emit("BND03", `異なるレベルの空間に壁境界は書けません (垂直は type:stair/shaft/void): ${b.a} | ${b.b}`, bAt);
|
|
618
|
+
continue; // レベルを跨ぐ壁は成立していない — 線分も開口も問わない
|
|
619
|
+
}
|
|
620
|
+
checkBoundarySegments(ctx, b, sa, sb, bAt);
|
|
621
|
+
checkOpenings(ctx, b);
|
|
622
|
+
checkBoundarySegs(ctx, b);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
/** 垂直境界 (stair/shaft/void) — VRT01〜VRT06 */
|
|
626
|
+
function checkVerticalBoundary(ctx, b, sa, sb, bAt) {
|
|
627
|
+
const { emit, levelIndex } = ctx;
|
|
628
|
+
// 垂直境界: 隣り合うレベルの、平面で重なる空間同士にしか張れない
|
|
629
|
+
if (sa.rects.length === 0 || sb.rects.length === 0 || !sa.level || !sb.level) {
|
|
630
|
+
emit("VRT01", `${b.kind} 境界は領域とレベルを持つ空間同士に書きます`, bAt);
|
|
631
|
+
return; // 前提が崩れているので、以降の判定は意味を持たない
|
|
632
|
+
}
|
|
633
|
+
const ia = levelIndex.get(sa.level);
|
|
634
|
+
const ib = levelIndex.get(sb.level);
|
|
635
|
+
if (ia === undefined || ib === undefined || Math.abs(ia - ib) !== 1) {
|
|
636
|
+
emit("VRT02", `${b.kind} 境界は隣り合うレベルの間に書きます: ${b.a} | ${b.b}`, bAt);
|
|
637
|
+
}
|
|
638
|
+
else if (!spacesOverlap(sa, sb)) {
|
|
639
|
+
emit("VRT03", `${b.kind} 境界の空間が平面上で重なっていません: ${b.a} | ${b.b}`, bAt);
|
|
640
|
+
}
|
|
641
|
+
if (b.kind === "void") {
|
|
642
|
+
const upper = (ia ?? 0) > (ib ?? 0) ? sa : sb;
|
|
643
|
+
if (upper.type !== "void") {
|
|
644
|
+
emit("VRT04", `void境界の上側は type:void の空間を想定しています: ${upper.path}`, bAt);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
// 咎めているのは字下げされた door / window / seg の行そのものなので、
|
|
648
|
+
// 親の境界宣言ではなくその行を指す。宣言が複数あれば診断も複数出る
|
|
649
|
+
for (const o of b.openings) {
|
|
650
|
+
emit("VRT05", `垂直境界の${o.kind}は解釈されません`, { line: o.line, file: b.file, path: [b.a, b.b] });
|
|
651
|
+
}
|
|
652
|
+
for (const g of b.segs) {
|
|
653
|
+
emit("VRT06", `垂直境界の seg は解釈されません`, { line: g.line, file: b.file, path: [b.a, b.b] });
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
/** 水平境界の線分がゼロ — BND04 / BND06 */
|
|
657
|
+
function checkBoundarySegments(ctx, b, sa, sb, bAt) {
|
|
658
|
+
const { model, emit } = ctx;
|
|
659
|
+
// 線を持つ境界の線分ゼロは「接していない」ではない — 線が分離していないか
|
|
660
|
+
// 何も切っていないかであり、それは LIN01 / LIN03 が言う
|
|
661
|
+
if (b.drawn)
|
|
662
|
+
return;
|
|
663
|
+
const segs = segmentsFor(model, b);
|
|
664
|
+
if (sa.rects.length > 0 && sb.rects.length > 0 && segs.length === 0) {
|
|
665
|
+
// **線分がゼロの理由は二つある。**接していないか、edge: で絞った先に共有辺が
|
|
666
|
+
// 無いか。前者だと断言すると、実際には接している二室について「割付を直せ」と
|
|
667
|
+
// 言うことになる — 直すべきは方角一語である (N=+Y, S=-Y, E=+X, W=-X)
|
|
668
|
+
const without = b.edge ? segmentsFor(model, { ...b, edge: undefined }) : [];
|
|
669
|
+
if (without.length > 0) {
|
|
670
|
+
const dirs = [...new Set(without.map((g) => g.edgeOfA))].filter((d) => d !== undefined);
|
|
671
|
+
emit("BND04", `edge:${b.edge} に共有辺がありません: ${b.a} | ${b.b} (実際に接しているのは ${dirs.join("・") || "別の辺"} です)`, bAt);
|
|
672
|
+
}
|
|
673
|
+
else {
|
|
674
|
+
emit("BND04", `空間が接していないため境界を導けません: ${b.a} | ${b.b}`, bAt);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
if ((sa.rects.length > 0 ? 1 : 0) + (sb.rects.length > 0 ? 1 : 0) === 1 && segs.length === 0) {
|
|
678
|
+
emit("BND06", `${b.edge ? `edge:${b.edge} の` : ""}外周に残る辺が無く、境界線分がゼロです: ${b.a} | ${b.b}`, bAt);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* 開口 — OPN03 / 配置エラー (OPN04〜08) / OPN01 / OPN02。
|
|
683
|
+
* **一つの関数に保つ** — 配置に失敗した開口は OPN01 も受けず OPN02 の母集団からも外れる。
|
|
684
|
+
* 配置の結果 (placedOnSeg) を跨いで持つのはここだけである
|
|
685
|
+
*/
|
|
686
|
+
function checkOpenings(ctx, b) {
|
|
687
|
+
const { model, emit, loc } = ctx;
|
|
688
|
+
if (b.kind === "open" && b.openings.length > 0) {
|
|
689
|
+
for (const o of b.openings) {
|
|
690
|
+
emit("OPN03", `open境界の${o.kind}は通行に影響しません (常に通れます)`, {
|
|
691
|
+
line: o.line,
|
|
692
|
+
file: b.file,
|
|
693
|
+
path: [b.a, b.b],
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
const placedOnSeg = [];
|
|
698
|
+
for (const o of b.openings) {
|
|
699
|
+
const placed = placeOpening(model, b, o);
|
|
700
|
+
if ("error" in placed && placed.error) {
|
|
701
|
+
emit(placed.code, placed.message, { line: placed.line, file: placed.file, path: [b.a, b.b] });
|
|
702
|
+
continue; // 置けなかった開口は、以降 (hinge の軸・重なり) の対象にならない
|
|
703
|
+
}
|
|
704
|
+
if ("segment" in placed) {
|
|
705
|
+
const s = placed.segment;
|
|
706
|
+
placedOnSeg.push({
|
|
707
|
+
o,
|
|
708
|
+
key: `${s.x1},${s.y1},${s.x2},${s.y2}`,
|
|
709
|
+
c: s.horizontal ? placed.cx : placed.cy,
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
if (o.hinge && "segment" in placed) {
|
|
713
|
+
const okAxis = placed.segment.horizontal
|
|
714
|
+
? o.hinge === "W" || o.hinge === "E"
|
|
715
|
+
: o.hinge === "N" || o.hinge === "S";
|
|
716
|
+
if (!okAxis) {
|
|
717
|
+
emit("OPN01", `hinge:${o.hinge} は${placed.segment.horizontal ? "水平線分 (W/E)" : "垂直線分 (N/S)"}で指定します`, { line: o.line, file: b.file, path: [b.a, b.b] });
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
// 同じ線分の上の開口同士は重なってはならない
|
|
722
|
+
const byKey = new Map();
|
|
723
|
+
for (const p of placedOnSeg) {
|
|
724
|
+
const arr = byKey.get(p.key) ?? [];
|
|
725
|
+
arr.push(p);
|
|
726
|
+
byKey.set(p.key, arr);
|
|
727
|
+
}
|
|
728
|
+
for (const group of byKey.values()) {
|
|
729
|
+
group.sort((p, q) => p.c - q.c);
|
|
730
|
+
for (let k = 0; k + 1 < group.length; k++) {
|
|
731
|
+
const p = group[k];
|
|
732
|
+
const q = group[k + 1];
|
|
733
|
+
const need = (p.o.w + q.o.w) / 2;
|
|
734
|
+
if (q.c - p.c < need - EPS) {
|
|
735
|
+
emit("OPN02", `開口同士が重なっています (${p.o.kind}と${q.o.kind} — 中心間 ${Math.round(q.c - p.c)}mm < 必要 ${Math.round(need)}mm)`, { line: q.o.line, file: b.file, path: [b.a, b.b], related: [loc(p.o.line, b.file)] });
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
/** 数えない分節 (seg) の配置 — SEG03 / SEG04〜08 */
|
|
741
|
+
function checkBoundarySegs(ctx, b) {
|
|
742
|
+
const { model, emit } = ctx;
|
|
743
|
+
for (const g of b.segs) {
|
|
744
|
+
if (b.kind === "open") {
|
|
745
|
+
emit("SEG03", `open境界 (壁が無い) の seg は解釈されません`, { line: g.line, file: b.file, path: [b.a, b.b] });
|
|
746
|
+
continue;
|
|
747
|
+
}
|
|
748
|
+
const placed = placeBand(model, b, g, "seg");
|
|
749
|
+
if ("error" in placed && placed.error) {
|
|
750
|
+
emit(placed.code, placed.message, { line: placed.line, file: placed.file, path: [b.a, b.b] });
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
/** 数えない分節 — SEG01 / SEG02 */
|
|
755
|
+
function checkAreas(ctx) {
|
|
756
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
757
|
+
// 数えない分節 (area) は親の領域に収まっているか
|
|
758
|
+
for (const s of model.spaces.values()) {
|
|
759
|
+
for (const a of s.areas) {
|
|
760
|
+
if (s.rects.length === 0) {
|
|
761
|
+
emit("SEG01", `領域を持たない空間 ${s.path} に area は書けません`, {
|
|
762
|
+
line: a.line,
|
|
763
|
+
file: s.file,
|
|
764
|
+
path: [s.path],
|
|
765
|
+
});
|
|
766
|
+
continue;
|
|
767
|
+
}
|
|
768
|
+
// 内包も導出された形で見る — 割付で見ると、切り落とした側に置いた床材が通ってしまう
|
|
769
|
+
const inside = regionOf(s).some((g) => rectToPoly(a.rect).every((pt) => pointInPolygon(pt, g, EPS)));
|
|
770
|
+
if (!inside) {
|
|
771
|
+
emit("SEG02", `area が ${s.path} の領域からはみ出しています`, { line: a.line, file: s.file, path: [s.path] });
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
/** ゾーン — ZON01 / ZON02 */
|
|
777
|
+
function checkZones(ctx) {
|
|
778
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
779
|
+
// ゾーン: 束ねる空間が実在するか
|
|
780
|
+
for (const z of model.zones.values()) {
|
|
781
|
+
const children = [...model.spaces.keys()].filter((p) => p.startsWith(z.path + "/"));
|
|
782
|
+
if (children.length === 0) {
|
|
783
|
+
emit("ZON01", `ゾーン ${z.path} の下に空間がありません`, { line: z.line, file: z.file, path: [z.path] });
|
|
784
|
+
}
|
|
785
|
+
if (model.spaces.has(z.path)) {
|
|
786
|
+
emit("ZON02", `ゾーンと同じパスの空間があります (どちらかに寄せます): ${z.path}`, {
|
|
787
|
+
line: z.line,
|
|
788
|
+
file: z.file,
|
|
789
|
+
path: [z.path],
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
/** 高さ方向の一貫性 — HGT01〜HGT04 */
|
|
795
|
+
function checkHeights(ctx) {
|
|
796
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
797
|
+
// 高さ方向の一貫性: 下階の空間の天井高 + 上階のslab ≤ 階高
|
|
798
|
+
// 吹抜け (void境界) は宣言的な免除だが、免除が効くのは吹抜けが平面を覆う範囲まで —
|
|
799
|
+
// 部分吹抜けでは下階の天井高は階高内に収める (吹抜け部分の高さは導出) (ADR-0006追記)
|
|
800
|
+
const voidPartners = new Map();
|
|
801
|
+
for (const b of model.boundaries) {
|
|
802
|
+
if (b.kind !== "void")
|
|
803
|
+
continue;
|
|
804
|
+
const sa = model.spaces.get(b.a);
|
|
805
|
+
const sb = model.spaces.get(b.b);
|
|
806
|
+
if (!sa?.level || !sb?.level)
|
|
807
|
+
continue;
|
|
808
|
+
const ia = levelIndex.get(sa.level) ?? 0;
|
|
809
|
+
const ib = levelIndex.get(sb.level) ?? 0;
|
|
810
|
+
const lower = ia < ib ? sa : sb;
|
|
811
|
+
const upper = ia < ib ? sb : sa;
|
|
812
|
+
const key = `${lower.path}|${upper.level}`;
|
|
813
|
+
const arr = voidPartners.get(key) ?? [];
|
|
814
|
+
arr.push(upper);
|
|
815
|
+
voidPartners.set(key, arr);
|
|
816
|
+
}
|
|
817
|
+
const byLevel = new Map();
|
|
818
|
+
for (const s of withRect) {
|
|
819
|
+
if (!s.level)
|
|
820
|
+
continue;
|
|
821
|
+
const arr = byLevel.get(s.level) ?? [];
|
|
822
|
+
arr.push(s);
|
|
823
|
+
byLevel.set(s.level, arr);
|
|
824
|
+
}
|
|
825
|
+
for (let i = 0; i + 1 < levels.length; i++) {
|
|
826
|
+
const lb = levels[i];
|
|
827
|
+
const lu = levels[i + 1];
|
|
828
|
+
const below = byLevel.get(lb.name) ?? [];
|
|
829
|
+
const above = byLevel.get(lu.name) ?? [];
|
|
830
|
+
const pitch = lu.z - lb.z;
|
|
831
|
+
let slabMissing = false;
|
|
832
|
+
for (const s of below) {
|
|
833
|
+
if (isSemiOutdoor(model, s))
|
|
834
|
+
continue; // 屋外・半屋外 (庭・バルコニー等) に天井は無い
|
|
835
|
+
// 縦動線の宣言的免除 (ADR-0021)。void の免除が「床の不在」だったのに対し、
|
|
836
|
+
// こちらは「天井が面でない」— 階段室・斜路の天井は上の走りに沿って傾いている。
|
|
837
|
+
// h を一つの数で語れない以上、この不変量は成立しない。頭上高さの検査は別の問い
|
|
838
|
+
if (runDecls(s).length > 0)
|
|
839
|
+
continue;
|
|
840
|
+
const covered = above.some((u) => spacesOverlap(s, u)) || above.length === 0;
|
|
841
|
+
if (!covered)
|
|
842
|
+
continue;
|
|
843
|
+
if (lu.slab === undefined) {
|
|
844
|
+
slabMissing = true;
|
|
845
|
+
continue;
|
|
846
|
+
}
|
|
847
|
+
const h = heff(model, s);
|
|
848
|
+
if (h === undefined) {
|
|
849
|
+
emit("HGT04", `${s.path} の天井高が不明で、${lu.name} との高さ検査ができません`, {
|
|
850
|
+
line: s.line,
|
|
851
|
+
file: s.file,
|
|
852
|
+
path: [s.path],
|
|
853
|
+
});
|
|
854
|
+
continue;
|
|
855
|
+
}
|
|
856
|
+
if (h + lu.slab > pitch + EPS) {
|
|
857
|
+
const partners = voidPartners.get(`${s.path}|${lu.name}`) ?? [];
|
|
858
|
+
const cover = partners.length ? voidCoverage(s, partners) : 0;
|
|
859
|
+
if (cover >= 0.99)
|
|
860
|
+
continue; // 全面吹抜け — 宣言的免除
|
|
861
|
+
if (partners.length) {
|
|
862
|
+
// 本文は HGT01 と同じ三項を出す — 決め手が上階の slab のとき
|
|
863
|
+
// 「天井高3000は階高3000を超えます」という成り立たない不等式になっていた。
|
|
864
|
+
// 被覆は免除しきい値 (99%) と衝突しないよう小数一桁で言う
|
|
865
|
+
emit("HGT02", `${s.path} が上階に食い込みます: 天井高${h} + ${lu.name}のslab${lu.slab} = ${h + lu.slab} > 階高${pitch}。吹抜けの被覆は${(cover * 100).toFixed(1)}%しかありません — 部分吹抜けでは天井高を階高内に収めます (吹抜け部分の高さは導出)`, { line: s.line, file: s.file, path: [s.path] });
|
|
866
|
+
}
|
|
867
|
+
else {
|
|
868
|
+
emit("HGT01", `${s.path} が上階に食い込みます: 天井高${h} + ${lu.name}のslab${lu.slab} = ${h + lu.slab} > 階高${pitch}`, { line: s.line, file: s.file, path: [s.path] });
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
if (slabMissing) {
|
|
873
|
+
emit("HGT03", `レベル ${lu.name} に slab が未宣言のため、${lb.name} との高さ検査ができません`, {
|
|
874
|
+
line: lu.line,
|
|
875
|
+
file: lu.file,
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
/** レベルに載らない空間 — HGT05 */
|
|
881
|
+
function checkOrphanSpaces(ctx) {
|
|
882
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
883
|
+
// レベルに載らない領域つき空間
|
|
884
|
+
for (const s of withRect) {
|
|
885
|
+
if (!s.level) {
|
|
886
|
+
emit("HGT05", `${s.path} は領域を持ちますが、レベルが特定できません (パス先頭か level: で指定します)`, {
|
|
887
|
+
line: s.line,
|
|
888
|
+
file: s.file,
|
|
889
|
+
path: [s.path],
|
|
890
|
+
});
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
/** 敷地形状 — SIT01〜SIT05 */
|
|
895
|
+
function checkSite(ctx) {
|
|
896
|
+
const { model, emit, loc, withRect, levels, levelIndex } = ctx;
|
|
897
|
+
// 敷地形状 (ADR-0011): 形の妥当性、対応ゾーンの存在、宣言面積との照合、建物のはみ出し検査。
|
|
898
|
+
// はみ出しは四隅の内包に加え、多角形の頂点の入り込みと辺の交差を見る — 凹敷地でも正しい (ADR-0013)。
|
|
899
|
+
// 地上の外部空間タイル (庭・通路) は近似なので検査しない — 面積の真は多角形が持つ
|
|
900
|
+
for (const poly of model.polygons.values()) {
|
|
901
|
+
for (let i = 0; i < poly.points.length; i++) {
|
|
902
|
+
const a = poly.points[i];
|
|
903
|
+
const b = poly.points[(i + 1) % poly.points.length];
|
|
904
|
+
if (Math.hypot(b.x - a.x, b.y - a.y) <= EPS_SITE) {
|
|
905
|
+
emit("SIT01", `敷地形状に重複する頂点があります (${Math.round(a.x)},${Math.round(a.y)})`, {
|
|
906
|
+
line: poly.line,
|
|
907
|
+
file: poly.file,
|
|
908
|
+
path: [poly.path],
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
const selfX = polygonSelfIntersection(poly.points);
|
|
913
|
+
if (selfX) {
|
|
914
|
+
emit("SIT02", `敷地形状が自己交差しています (${Math.round(selfX.x)},${Math.round(selfX.y)} 付近)`, {
|
|
915
|
+
line: poly.line,
|
|
916
|
+
file: poly.file,
|
|
917
|
+
path: [poly.path],
|
|
918
|
+
});
|
|
919
|
+
continue; // 不正な形に対する包含・面積は判定しない
|
|
920
|
+
}
|
|
921
|
+
const zone = model.zones.get(poly.path);
|
|
922
|
+
if (!zone) {
|
|
923
|
+
emit("SIT04", `polygon ${poly.path} に対応するゾーンがありません`, {
|
|
924
|
+
line: poly.line,
|
|
925
|
+
file: poly.file,
|
|
926
|
+
path: [poly.path],
|
|
927
|
+
});
|
|
928
|
+
continue;
|
|
929
|
+
}
|
|
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
|
+
}
|
|
956
|
+
}
|
|
957
|
+
//# sourceMappingURL=check.js.map
|