Skip to content

Civil read ops: civil_station_offset and civil_surface_stats - #3413

Merged
HakanSeven12 merged 2 commits into
HakanSeven12:mainfrom
schoeller:feature/civil-read-ops
Nov 22, 2026
Merged

HakanSeven12 merged 2 commits into
HakanSeven12:mainfrom
schoeller:feature/civil-read-ops

Conversation

@schoeller

Copy link
Copy Markdown
Contributor

What

Two read-only query ops on the existing op/query surface (the family query, measure, records and the merged civil class-name filter #3389 live in), served by the headless automation server, the versioned control envelope, and the MCP ocs_read facade:

  • {"op":"civil_station_offset","handle":"<hex>","station":<number>,"offset_distance":<number, optional, default 0>}
    → {"ok":true,"handle","station","offset","raw_station","point":[x,y]}
    The point at an alignment's station, offset perpendicular across it. The station is the one Civil 3D shows — past a station equation it runs on from the station ahead (inverted from the codec's display_station). Curves are measured and interpolated along their arcs at the curvature the codec solves (the same accounting as the codec's own station runs); spirals read from the codec's solved points. offset_distance is signed across the alignment, positive right of travel, so the pagination keyword offset stays untouched.
  • {"op":"civil_surface_stats","handle":"<hex>"}
    → {"ok":true,"handle","min_elevation","max_elevation","vertices","triangles","visible_triangles"}
    A TIN surface's elevation bounds over the vertices its visible triangles draw (hidden/deleted triangles and the four bounding-corner vertices carry no drawn elevation), falling back to the stored snapshot triangulation.

Both answer from already-decoded ArchEntityData only — nothing writes, selects or rebuilds, and the new code lives in one module (src/app/civil_query.rs) with unit tests for the geometry (line/arc interpolation, piece joins, station-equation inversion, drawn-triangle bounds).

Verification (read-only, DE_Busbucht_2023.dwg)

Fresh API oracle captured live via the AEC Pilot bridge (open_drawing readOnly:true → Alignment.PointLocation / TinSurface enumeration → get_civil_context before/after identical → close without saving), then the same file driven through a host built from this branch over the MCP bridge (scratch copy, no save):

probe (alignment 202BBA5 "Blumenstrasse") Civil 3D PointLocation this PR (live host)
station 0 495330.0386289693, 574839.0004751141 identical (all digits)
station 100 495420.008059484, 574795.3484239269 identical (all digits)
station 970.101725083677 (end) 496031.1747677915, 575126.6318720841 identical (all digits)
station 250.5 495555.41546008503, 574729.659131778 495555.41546042333, 574729.6591321499 (Δ 3.8e-7 m)
station 300 495601.58857968904, 574712.0157706364 495601.58858285844, 574712.0157697564 (Δ 3.2e-6 m)
station 500 495795.4310297726, 574734.1790888207 495795.43103266164, 574734.1790903932 (Δ 2.9e-6 m)
station 900 496006.2516172638, 575061.1102082813 496006.25162135944, 575061.1102190485 (Δ 4.6e-9 m)
station 500, offset +10 495800.2117452225, 574725.395879852 495800.21174822224, 574725.3958814848 (Δ 3.0e-6 m)
station 500, offset −7.5 495791.8454931852, 574740.7664955471 495791.8454959912, 574740.7664970745 (Δ 2.8e-6 m)

Straights and the alignment end are exact; the residual ≤ 3e-6 m on curve stations is the codec's own solved-geometry sampling, the same geometry the app draws. On the offset alignment 202BC2F ("Blumenstrasse-Links-3.750") the op returns the codec's solved geometry faithfully, which drifts from the API by up to ~4 cm toward the far end — that divergence is in the codec's solve of that record (its solved length is 963.1486 vs the API's 963.1012), reported here for the codec-tracking ledger, not hidden.

Surface 202B9DF "1. Urgelände": the op returns min 474.73, max 487.36 — exactly the live API values — with visible_triangles 1106 exactly the API's triangle count. vertices 573 / triangles 1140 are the codec's decoded totals (the known +4 corner-vertex / +34 hidden-triangle divergence row).

Read-only proof: after running every op on the opened drawing, the class census (query type:"AECC_ALIGNMENT" 6 / type:"AECC_TIN_SURFACE" 1) is identical before/after, total entities stay 12,870 (722 Extended), and document revision (0) and geometry_revision (14) are unchanged — no decode drift, no mutation.

Notes

  • TOOL_SCHEMA_DIGEST re-pinned for the two new read ops (deliberate, per the test's instruction); station and offset_distance join the ocs_read parameter schema, offset stays pagination-only.
  • Full cargo test --workspace --locked green (7,591 passed / 0 failed).

Worker-OCS-OPS added 2 commits November 21, 2026 15:07
Two read-only query ops over the decoded civil records, in the same
op/query family the MCP ocs_read facade and the headless automation
server serve:

- civil_station_offset: the point at an alignment's station, offset
  perpendicular across it (positive right of travel, the way Civil 3D
  offsets run). The station is the one Civil 3D shows — past a station
  equation it runs on from the station ahead. Curves read along their
  arcs at the curvature the codec solved; spirals read from the codec's
  solved points.
- civil_surface_stats: a TIN surface's elevation bounds and
  triangulation counts, over the vertices its visible triangles draw.

Both answer from already-decoded data; nothing writes, selects or
rebuilds.
"offset" is a pagination keyword across the read surface; the civil op
takes its own "offset_distance" so the two never share a key. Also pin
the tool-schema digest for the two new read ops.
@HakanSeven12
HakanSeven12 merged commit 5a7a540 into HakanSeven12:main Nov 22, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants