Repository navigation
test(engine): cover Shapefile Z/M reader losses #2420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Mavrick-F
merged 1 commit into
opengeos:main
from
Mavrick-F:t3/shapefile-zm-loss-fixtures
Nov 18, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # Shapefile Z/M pairs | ||
|
|
||
| Made-up data, independently encoded as bytes for RustGIS (Apache-2.0), following | ||
| [Shapefile Technical Description](https://content.esri.com/support/whitepapers/ao_/shapefile.pdf), | ||
| file headers and Tables 4, 6, 8, 12 and 14. No production writer or third-party | ||
| code generated these fixtures; no generator is needed to run the tests. | ||
|
|
||
| Every `.shp` contains one record. Point XY is `(1, 2)`; the single-part line's XY | ||
| vertices are `(1, 2), (3, 4)`. Both clean and lossy inputs must import this geometry | ||
| and the one `ID=1` attribute row unchanged. All four lossy inputs currently import | ||
| and report dropping Z or M; clean inputs do not report that loss. | ||
|
|
||
| | Stem (`shp-`) | Shape type | Extra ordinates | `.shp` bytes | | ||
| | --- | --- | --- | --- | | ||
| | `point-xy` | 1, Point | None; clean partner for both points | 128 | | ||
| | `point-z` | 11, PointZ | Z=3; M=-1e39 (no-data sentinel) | 144 | | ||
| | `point-m` | 21, PointM | M=7 | 136 | | ||
| | `line-xy` | 3, PolyLine | None; clean partner for both lines | 188 | | ||
| | `line-z` | 13, PolyLineZ | Z=[5,9]; optional M section absent | 220 | | ||
| | `line-zm` | 13, PolyLineZ | Z=[5,9], M=[7,11] | 252 | | ||
|
|
||
| The first 100 bytes are the format's header: file code 9994 and file length in | ||
| big-endian 16-bit words, version 1000 and shape type in little endian, then XY, | ||
| Z and M bounds as little-endian float64. Record number 1 and content length are | ||
| big endian; record contents are little endian. Each matching `.shx` is 108 bytes: | ||
| the same header with file length 54 words, then offset 50 words and the record's | ||
| content length. Line contents have one part starting at vertex 0, the XY array, | ||
| and (for type 13) the Z bounds and array, followed by M bounds and array only in | ||
| `line-zm`. The PointZ M sentinel is below the specification's -1e38 no-data limit, | ||
| so this case exercises a height without a real measure. | ||
|
|
||
| The shared `shp-row.dbf` is 68 bytes: dBASE III, date 2026-11-18, one row, a | ||
| 65-byte header and two-byte record; one numeric field `ID`, width 1, no decimals, | ||
| header terminator 0x0d, undeleted row ` 1`, EOF 0x1a. The harness supplies identical | ||
| WGS 84 `.prj` and UTF-8 `.cpg` text beside both files. This isolates ordinate loss | ||
| from coordinate-system assumptions and DBF encoding behavior. The corpus checks | ||
| the native reader first and then `layer.addData`, so external fallbacks or empty | ||
| imports cannot stand in for valid XY geometry. |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test coverage (medium confidence): these fixtures are small, so
layer.addDatatakes the whole-file path (io::read_shapefile_parts). Files over the size threshold go throughShpSource::open_path(crates/data/src/source/mod.rs:439), which decides Z/M loss from the header's shape type (crates/data/src/source/shp.rs:211), not from each record. None of the four new cases reaches that path, and the only existing in-place Z/M check (crates/data/src/io.rs, ~line 5055) covers PointZ alone. Line-Z, PointM and PolylineZM are not tested on the in-place path.Either add an in-place case for types 13 and 21, or say in
SHAPEFILE.md/ the ROADMAP line that the large-file reader is out of scope for this corpus. This is not a blocker for the PR as written.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed: these tiny fixtures exercise whole-file imports, not the size-triggered in-place
ShpSourcepath. The PR description now states that limit explicitly. The in-place header logic includes types 13 and 21, but this corpus does not test that path; additional in-place cases and fixture-note clarification are left for the release quality pass.