"""D2 sole plate TABLE -> params.json `sole_plates` (existing keys unchanged). Rules (HITL 2026-10-08): bearing = (L-100) x (W-100) box, height h3, black; sole plate L x W, bottom flat on the bearing, top sloped S(%) along the bridge axis (= h2 pad long axis), centre thickness T; thicker end T1 at the front (-Y) side. L is along the pad's long axis, W across (L = A+100, W = B+100). """ import json from collections import defaultdict from pathlib import Path HERE = Path(__file__).resolve().parent COLS = {"NO": 2584, "S": 3378, "L": 4582, "W": 5482, "T": 6433, "T1": 7333, "T2": 8233} def main(): texts = json.loads((HERE / "판독" / "2_survey.json").read_text(encoding="utf-8"))["texts"] rows = defaultdict(dict) for t in texts: if 1000 < t["x"] < 9000 and 7000 < t["y"] < 12400: col = min(COLS, key=lambda c: abs(COLS[c] - t["x"])) if abs(COLS[col] - t["x"]) < 150: rows[round(t["y"])][col] = t["text"] table = [] for y in sorted(rows, reverse=True): r = rows[y] table.append(dict(no=int(r["NO"]), S=float(r["S"]), L=int(r["L"]), W=int(r["W"]), T=int(r["T"]), T1=int(r["T1"]), T2=int(r["T2"]), src_y=y)) assert [r["no"] for r in table] == list(range(1, 11)) pp = HERE / "params.json" params = json.loads(pp.read_text(encoding="utf-8")) bear = {b["no"]: b for b in params["bearing_seats"]["bearings"]} checks = [] for r in table: b = bear[r["no"]] e = r["T"] - r["S"] / 100 * r["L"] / 2 # thickness at the front (-along) end checks.append(dict(no=r["no"], L_eq_A100=r["L"] == b["A"] + 100, W_eq_B100=r["W"] == b["B"] + 100, end_thick=[round(e, 2), round(2 * r["T"] - e, 2)], T1T2=[r["T1"], r["T2"]])) params["sole_plates"] = dict( table=table, bearing_height="h3 (D2 ELEVATION TABLE, 181)", bearing_shrink=100, slope_dir="thicker at -along (front, -Y) [HITL]", colours=dict(bearing=[0, 0, 0], sole_plate=[150, 150, 150]), checks=checks, src="D2 솔플레이트 상세 TABLE (NO., S(%), L, W, T, T1, T2); ELEVATION TABLE h3; 사용자 지시 2026-10-08") pp.write_text(json.dumps(params, ensure_ascii=False, indent=2), encoding="utf-8") print(json.dumps(checks, ensure_ascii=False)) if __name__ == "__main__": main()