diff --git a/data/profile_gl_002_draft.csv b/data/profile_gl_002_draft.csv new file mode 100644 index 0000000..ce85a26 --- /dev/null +++ b/data/profile_gl_002_draft.csv @@ -0,0 +1,77 @@ +station_anchor,est_station,across_m,value,x,y +4740,4738.3,-32.81,65.969,150794.75,483555.28 +4740,4738.3,-16.41,50.495,150809.32,483562.8 +4760,4758.4,-31.48,70.818,150805.68,483536.98 +4760,4758.4,-16.41,50.993,150819.07,483543.89 +4780,4778.4,-32.81,72.725,150814.25,483517.47 +4780,4778.4,-15.97,51.492,150829.22,483525.19 +4800,4798.5,-31.48,82.17,150825.19,483499.17 +4800,4798.5,-15.53,51.99,150839.37,483506.48 +4820,4818.5,-32.81,92.372,150833.76,483479.65 +4820,4818.5,-16.86,52.488,150847.94,483486.97 +4840,4838.6,-33.7,100.775,150842.73,483460.34 +4840,4838.6,-16.86,52.986,150857.69,483468.06 +4860,4858.6,-33.26,109.7,150852.87,483441.63 +4860,4858.6,-16.86,53.485,150867.45,483449.15 +4880,4878.6,-32.81,119.9,150863.02,483422.93 +4880,4878.6,-16.86,53.983,150877.2,483430.25 +4900,4898.7,-33.26,130.6,150872.38,483403.82 +4900,4898.7,-15.97,54.481,150887.74,483411.74 +4920,4918.7,-31.93,141.1,150883.32,483385.52 +4920,4918.7,-16.41,54.98,150897.1,483392.63 +4940,4938.8,-34.59,152.277,150890.71,483365.4 +4940,4938.8,-16.86,55.478,150906.46,483373.52 +4960,4958.8,-34.59,155.393,150900.46,483346.49 +4960,4958.8,-16.86,55.976,150916.22,483354.62 +4980,4978.9,-34.14,149.607,150910.61,483327.79 +4980,4978.9,-16.86,56.474,150925.97,483335.71 +5000,4998.9,-33.7,144.2,150920.75,483309.08 +5000,4998.9,-16.86,56.973,150935.72,483316.8 +5020,5019.0,-34.59,145.422,150929.72,483289.77 +5020,5019.0,-15.97,57.471,150946.26,483298.3 +5040,5039.0,-34.59,142.999,150939.47,483270.86 +5040,5039.0,-16.86,57.969,150955.23,483278.99 +5060,5059.0,-34.14,142.606,150949.62,483252.16 +5060,5059.0,-16.86,58.467,150964.98,483260.08 +5080,5079.1,-34.59,142.244,150958.98,483233.05 +5080,5079.1,-16.86,58.966,150974.74,483241.18 +5100,5099.1,-34.59,145.737,150968.73,483214.14 +5100,5099.1,-16.86,59.464,150984.49,483222.27 +5120,5119.2,-32.81,148.1,150980.06,483196.05 +5120,5119.2,-16.86,59.962,150994.24,483203.36 +5140,5139.2,-33.26,146.041,150989.42,483176.94 +5140,5139.2,-15.97,60.46,151004.79,483184.86 +5160,5159.3,-32.81,146.118,150999.57,483158.23 +5160,5159.3,-16.41,60.959,151014.15,483165.75 +5180,5179.3,-34.59,147.947,151007.75,483138.51 +5180,5179.3,-15.97,61.457,151024.29,483147.05 +5200,5199.4,-33.7,152.8,151018.29,483120.01 +5200,5199.4,-15.97,61.955,151034.05,483128.14 +5220,5219.4,-33.7,157.214,151028.04,483101.1 +5220,5219.4,-16.86,62.453,151043.01,483108.83 +5240,5239.5,-33.7,155.7,151037.8,483082.2 +5240,5239.5,-16.86,62.952,151052.77,483089.92 +5260,5259.5,-34.59,146.424,151046.76,483062.88 +5260,5259.5,-16.41,63.45,151062.91,483071.22 +5280,5279.5,-33.7,138.6,151057.3,483044.38 +5280,5279.5,-16.86,63.948,151072.27,483052.11 +5300,5299.6,-33.7,140.039,151067.06,483025.48 +5300,5299.6,-16.86,64.446,151082.03,483033.2 +5320,5319.6,-34.14,130.368,151076.42,483006.37 +5320,5319.6,-16.86,64.933,151091.78,483014.29 +5340,5339.7,-33.26,117.65,151086.96,482987.87 +5340,5339.7,-16.86,65.378,151101.53,482995.38 +5360,5359.7,-33.26,107.3,151096.71,482968.96 +5360,5359.7,-15.97,65.781,151112.07,482976.88 +5380,5379.8,-34.14,103.593,151105.68,482949.65 +5380,5379.8,-15.97,66.142,151121.83,482957.98 +5400,5399.8,-33.7,109.032,151115.83,482930.94 +5400,5399.8,-16.41,66.46,151131.19,482938.87 +5420,5419.9,-32.81,108.108,151126.37,482912.44 +5420,5419.9,-16.86,66.737,151140.55,482919.76 +5440,5439.9,-31.93,98.183,151136.91,482893.94 +5440,5439.9,-16.41,66.97,151150.7,482901.05 +5460,5460.0,-31.93,88.124,151146.66,482875.03 +5460,5460.0,-15.97,67.162,151160.84,482882.35 +5480,5480.0,-30.6,81.014,151157.6,482856.74 +5480,5480.0,-15.08,67.311,151171.38,482863.85 diff --git a/scripts/extract_profile_gl.py b/scripts/extract_profile_gl.py new file mode 100644 index 0000000..eeab445 --- /dev/null +++ b/scripts/extract_profile_gl.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 +"""Task 3 (user-confirmed reading): ground-level and design-grade values per +20 m station from sheet 02-002 (당진방향). + +Confirmed by the user (2026-10-21): decimal texts in CR-TABL-TEX2 are 지반고 (GL), +sheet 002 values used; the ruler 740.00..980.00 is chainage 4+740..4+980, and +0.00 is 5+000 (ruler continues in 20 m steps). +Method: ruler texts give anchors (chainage = 4000+v for 740..980; 5000+v after 0.00). +Each decimal text is projected onto the ruler axis; its station is the nearest anchor. +Two decimal series appear at each station (|across| ~ 17-21 and ~ 32-39 m); +the series names are NOT assigned here (HITL). Checks are reported, not forced.""" +import csv +import math +import re +import sys + +import ezdxf + +SRC, OUT = sys.argv[1], sys.argv[2] +msp = ezdxf.readfile(SRC).modelspace() +texts = [(e.dxf.insert.x, e.dxf.insert.y, e.dxf.text.strip()) + for e in msp.query("TEXT") if e.dxf.layer == "CR-TABL-TEX2"] + +ruler = {} +for x, y, s in texts: + if re.fullmatch(r"\d{1,3}\.00", s): + ruler[int(s.split(".")[0])] = (x, y) +anchors = {} +for v in range(740, 1000, 20): + if v in ruler: + anchors[4000 + v] = ruler[v] +for v in range(0, 1000, 20): + if v in ruler: + anchors[5000 + v] = ruler[v] + else: + break +stas = sorted(anchors) +print("anchors:", len(stas), "range", stas[0], "..", stas[-1]) +gaps = [(stas[i + 1] - stas[i], round(math.dist(anchors[stas[i]], anchors[stas[i + 1]]), 2)) + for i in range(len(stas) - 1)] +print("consecutive (dSTA, chord m):", gaps) + +A0, A1 = anchors[stas[0]], anchors[stas[-1]] +L = math.dist(A0, A1) +u = ((A1[0] - A0[0]) / L, (A1[1] - A0[1]) / L) +v_ = (-u[1], u[0]) +rows = [] +for x, y, s in texts: + if not re.fullmatch(r"\d{1,3}\.\d{3}", s): + continue + dx, dy = x - A0[0], y - A0[1] + along = dx * u[0] + dy * u[1] + across = dx * v_[0] + dy * v_[1] + if not (-5.0 <= along <= L + 5.0 and abs(across) < 60): + continue # outside the ruler band (table noise) + sta_est = stas[0] + along * (stas[-1] - stas[0]) / L + near = min(stas, key=lambda k: abs(k - sta_est)) + rows.append((near, round(sta_est, 1), round(across, 2), float(s), round(x, 2), round(y, 2))) + +with open(OUT, "w", newline="", encoding="utf-8") as fh: + w = csv.writer(fh) + w.writerow(["station_anchor", "est_station", "across_m", "value", "x", "y"]) + w.writerows(sorted(rows)) +per = {} +for near, est, acr, val, _, _ in rows: + per.setdefault(near, []).append((acr, val)) +for k in sorted(per): + print(f"STA {k}: " + " ".join(f"[{a:+.1f}m {val:.3f}]" for a, val in sorted(per[k])))