Repository navigation
fix(objects): decode GEODATA as the §20.4.78 object it is (#229) - #295
Merged
Merged
Conversation
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.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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".
# 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.
# Conflicts: # ARCHITECTURE.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 a3RD. Part of #229.Spec reference
§20.4.78 GEODATA (class
AcDbGeoData, after §20.1's common object data):BLobject version,Hhost block,BSdesign 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 (2RDsource,2RDdestination) and the mesh faces (threeBLs). R2007 and earlier files add a civil block.Erratum
North direction 3RD(object version 2 and later)2RD. At bit 566 ofgeoloc.dwg0x241, the twoRDs read (2.4e-16, 1.0), DXF12/22. The next 64 bits, read as a thirdRD, give −3.1e-151. They are actually the scale estimationBL(1, DXF95), the user scale factorBD(1.0,141), the sea-levelB(0,294) andBD(0.0,142), and the first bits of the projection radius. Read as a3RD, 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 a2RD, 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^Jnewlines are decoded first. Reals must agree within 1e-12 relative or 1e-15 absolute, since the export prints at most 16 digits:The 77 values:
303/301chunks in the export);<georss:point>55.8440 -4.2310</georss:point>and three empty observation tags;Comparator check: changing one character of the GeoRSS tag in a copy of the twin is reported as exactly 1 difference.
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_classroutesGEODATA/ACDBGEODATAtoentities::geodata::decode_object, which closes on the data-stream boundary.ObjectType::GeoDatais no longer counted byis_entity.GeoDatais 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 atdwg::entities::geodata, so the public path does not move.Coverage,
../../samplesUnchanged, TOTAL 4256 / 180 / 9 (no GEODATA among the 19 files).
Public corpus:
tools/corpus/baseline.tsv(regenerated, committed)52-file total: 14938 / 831 / 305 → 14939 / 830 / 305, measured against main at dcc29d7.
measure.py checkpasses. spec_examples are unchanged, since §20.4.78 prints no example.Class census and reference closure
Unchanged on all 19 files of
../../samplesand in the baseline's census and closure columns.geoloc.dwgstill declares 2 GEODATA and walks 1. That is #230, which is next.Docs
docs/data/spec-coverage.tsv§20.4.78:partial→closes.docs/spec-coverage.mdregenerated.dispatch.rscomment no longer claims every modern drawing uses the fixed CAMERA/SUN/LIGHT/GEODATA codes, sincegeoloc.dwg's GEODATA does not.Test plan
cargo fmt --all -- --checkcargo clippy --all-targets --all-features -- -D warningsRUSTFLAGS="-D warnings" cargo test --release --all-features(real-file tests ran against../../samples)RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-featurestools/corpus/measure.py checkpasses against the committed baselineentities::geodata::tests::roundtrip_geodata_wgs84round-tripped the invented field list, which the corpus record disproves (it closes only with §20.4.78's list).entities::geodata::tests::rejects_pre_r2010asserted 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:
CLEANROOM.md).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/atc30a97ce, 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.