Skip to content

fix(objects): decode GEODATA as the §20.4.78 object it is (#229) - #295

Merged
DrunkOnJava merged 6 commits into
mainfrom
fix/229-geodata
Oct 26, 2026
Merged

DrunkOnJava merged 6 commits into
mainfrom
fix/229-geodata

Conversation

@DrunkOnJava

Copy link
Copy Markdown
Owner

Summary

Decode GEODATA as the non-entity object §20.4.78 describes. The crate had an entity decoder with an invented field list (an origin, two axis vectors, two scales, five strings), keyed on a fixed code 0x4FB. The corpus's one GEODATA record carries a class number, so it was never routed. It is now routed by its DXF class name to a §20.4.78 decoder that reads after the common object data, and it closes. All 77 values the new probe compares equal AutoCAD's DXF export of the drawing. The one departure from the spec is that the north direction is a 2RD, not a 3RD. Part of #229.

Spec reference

§20.4.78 GEODATA (class AcDbGeoData, after §20.1's common object data): BL object version, H host block, BS design coordinate type. For object version 2 and later it then reads the design and reference points, both unit scales and units, the up direction, the north direction, the scale estimation, the sea-level fields, the projection radius, the coordinate system definition and the GeoRSS tag. Object version 1 has its own block. Every version then has the three observation tags, the mesh points (2RD source, 2RD destination) and the mesh faces (three BLs). R2007 and earlier files add a civil block.

Erratum

Where What the spec prints What the record says
§20.4.78, p194 North direction 3RD (object version 2 and later) a 2RD. At bit 566 of geoloc.dwg 0x241, the two RDs read (2.4e-16, 1.0), DXF 12/22. The next 64 bits, read as a third RD, give −3.1e-151. They are actually the scale estimation BL (1, DXF 95), the user scale factor BD (1.0, 141), the sea-level B (0, 294) and BD (0.0, 142), and the first bits of the projection radius. Read as a 3RD, the radius becomes −288,169,236 against DXF's 6,362,228.65, the mesh-point count 50 against DXF's 12, and the record overruns its 3,859-bit boundary. Read as a 2RD, it ends exactly on that boundary.

Measured against AutoCAD's DXF

examples/probe_geodata.rs (new) matches each GEODATA record by handle to the twin's record and compares every value with its group. The caret-escaped ^J newlines are decoded first. Reals must agree within 1e-12 relative or 1e-15 absolute, since the export prints at most 16 digits:

0x241: object version 3, 12 mesh points, 0 faces: 77 values compared, 0 differ
geoloc.dwg (AC1032 (2018)): 1 GEODATA, 0 not decoded, 77 values compared, 0 differ
RESULT: every compared value equals the twin

The 77 values:

  • object version 3 and design coordinate type 1;
  • the design point (11.25, 17.27, 0) and the reference point (−315,551.02, 4,702,004.17, 50);
  • the unit scales 0.0254 / 0.0254 and units inches / inches;
  • the up direction (0, 0, 1), the north direction (2.4e-16, 1), scale estimation 1, user scale 1.0, no sea-level correction, elevation 0;
  • the projection radius 6,362,228.65;
  • the 3,195-character MapGuide XML coordinate system definition (13 303/301 chunks in the export);
  • the GeoRSS tag <georss:point>55.8440 -4.2310</georss:point> and three empty observation tags;
  • all 12 mesh points (48 reals) and 0 faces.

Comparator check: changing one character of the GeoRSS tag in a copy of the twin is reported as exactly 1 difference.

C=~/Library/Caches/dwg-corpus/acadsharp
cargo run --release --example probe_geodata -- $C/geoloc.dwg $C/geoloc.dxf
cargo run --release --example probe_field_list -- $C/geoloc.dwg 577 BL,BS,3*BD,3*BD,BD,BL,BD,BL,3*BD,2*RD,BL,BD,B,BD,BD,TV,TV,TV,TV,TV,BL,48*RD,BL   # delta 0

The object version 1 (AutoCAD 2009) layout and the civil block of R2007 and earlier files are read as §20.4.78 prints them. The corpus has neither, so both are unmeasured. A record they do not fit fails the boundary check rather than decoding to invented values.

Routing

  • dispatch_object_class routes GEODATA / ACDBGEODATA to entities::geodata::decode_object, which closes on the data-stream boundary.
  • The fixed code 0x4FB goes to the object path instead of the entity path. ObjectType::GeoData is no longer counted by is_entity.
  • GeoData is now the §20.4.78 record (object version, design and reference points, units, directions, scale and sea-level fields, the strings, mesh points and faces). The invented fields are gone. It stays at dwg::entities::geodata, so the public path does not move.

Coverage, ../../samples

Unchanged, TOTAL 4256 / 180 / 9 (no GEODATA among the 19 files).

Public corpus: tools/corpus/baseline.tsv (regenerated, committed)

geoloc.dwg   144 6 0  →  145 5 0

52-file total: 14938 / 831 / 305 → 14939 / 830 / 305, measured against main at dcc29d7. measure.py check passes. spec_examples are unchanged, since §20.4.78 prints no example.

Class census and reference closure

Unchanged on all 19 files of ../../samples and in the baseline's census and closure columns. geoloc.dwg still declares 2 GEODATA and walks 1. That is #230, which is next.

Docs

  • ARCHITECTURE.md: new §7x (a provisional letter; the train renumbers it), with the erratum in §7k's table format.
  • docs/data/spec-coverage.tsv §20.4.78: partial → closes. docs/spec-coverage.md regenerated.
  • The dispatch.rs comment no longer claims every modern drawing uses the fixed CAMERA/SUN/LIGHT/GEODATA codes, since geoloc.dwg's GEODATA does not.

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • RUSTFLAGS="-D warnings" cargo test --release --all-features (real-file tests ran against ../../samples)
  • RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features
  • tools/corpus/measure.py check passes against the committed baseline
  • Removes 2 existing unit tests; adds none. entities::geodata::tests::roundtrip_geodata_wgs84 round-tripped the invented field list, which the corpus record disproves (it closes only with §20.4.78's list). entities::geodata::tests::rejects_pre_r2010 asserted that GEODATA is refused before R2010, but §20.4.78 defines the object version 1 layout and the R2007-and-earlier civil block.

Source-provenance declaration

By submitting this PR I certify that my contribution does not incorporate executable code from any source whose license is incompatible with Apache-2.0. Specifically:

  • No Autodesk DWG SDK source (RealDWG, ObjectARX, ObjectDBX) or NDA-protected Autodesk documentation was consulted or imported.
  • No Open Design Alliance Teigha / Drawings SDK source was consulted or imported. The ODA's public Open Design Specification for .dwg files PDF is explicitly allowed (see CLEANROOM.md).
  • No GPL-licensed DWG implementation source (LibreDWG, etc.) was consulted or imported.

My contribution is based on §20.1 and §20.4.78 of the ODA's freely-redistributable Open Design Specification for .dwg files (v5.4.1). It also uses the corpus bytes and AutoCAD's DXF export of the same drawing, read as a data file (ACadSharp samples/ at c30a97ce, MIT, pinned by #225). No third-party code or comments were read.

Developer Certificate of Origin

By submitting this PR, I certify that the contribution complies with the Developer Certificate of Origin 1.1.

GEODATA had an entity decoder with an invented field list, keyed on a
fixed code the corpus never uses: geoloc.dwg's record carries a class
number. Route the class name to a decoder that reads §20.4.78 after the
common object data. The record closes on its string stream and all 77
values examples/probe_geodata.rs compares equal AutoCAD's DXF export.
The north direction is a 2RD, not the 3RD §20.4.78 prints.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T18:02:41.120384Z 8dfa810 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a4528c4c6d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread examples/probe_geodata.rs Resolved
# Conflicts:
#	ARCHITECTURE.md
#	docs/spec-coverage.md
#	tools/corpus/baseline.tsv
…ecord

A record whose handle the DXF lacks (the wrong drawing's export, say) was
skipped without counting, so the probe could pass with nothing compared.
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.

1 participant