feat: draft main-line centreline stations from plan sheets (Task 3, HITL)

extract_alignment_plan.py takes the midpoint of each station's two side
ticks (CA-ALGN-STSM) as the centreline point. Sheet 001 gives 4+700..5+500
with consecutive residual <= 0.02 m. Sheet 002 gives identical output, so
the duplicate question is left to HITL. Profile EL is not yet extracted.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A5Cun3RHQKna9qxE6ybZ4A
This commit is contained in:
Claude committed 2026-10-20 23:46:44 +00:00
1 parent 14a4c4a37a
commit f144d53f79
5 files changed
+193

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
#!/usr/bin/env python3
"""Task 3 exploration: layer usage and long polylines / text clusters in a
plan-profile DXF, to locate the tunnel centreline (본선 축선) candidates."""
import collections
import json
import sys
import ezdxf
path = sys.argv[1]
doc = ezdxf.readfile(path)
msp = doc.modelspace()
by_layer = collections.Counter(e.dxf.layer for e in msp)
print("layers used:", len(by_layer))
for name, n in by_layer.most_common(25):
print(f" {n:6d} {name}")
# long polylines = candidate alignment / outline strings
polys = []
for e in msp:
if e.dxftype() == "LWPOLYLINE":
pts = list(e.get_points("xy"))
if len(pts) >= 20:
xs = [p[0] for p in pts]; ys = [p[1] for p in pts]
polys.append({"layer": e.dxf.layer, "n": len(pts),
"x": [round(min(xs), 1), round(max(xs), 1)],
"y": [round(min(ys), 1), round(max(ys), 1)]})
polys.sort(key=lambda d: -d["n"])
print("long LWPOLYLINE (>=20 vertices):", len(polys))
for p in polys[:12]:
print(" ", p)
# text that looks like station (STA) or level (EL) labels
import re
pat = re.compile(r"(STA|No\.?|EL|E\.L|\d+\+\d+|\+\d{2,3}\.\d{3}|\d{2,3}\.\d{2,3})", re.I)
hits = []
for e in msp:
if e.dxftype() in ("TEXT", "MTEXT"):
s = e.dxf.text if e.dxftype() == "TEXT" else e.plain_text()
if s and pat.search(s):
loc = e.dxf.insert if e.dxftype() == "TEXT" else e.dxf.insert
hits.append((round(loc.x, 1), round(loc.y, 1), s.strip()[:40]))
print("station/level-like texts:", len(hits))
for h in sorted(hits)[:25]:
print(" ", h)