Skip to content

test(engine): cover Shapefile Z/M reader losses - #2420

Merged
Mavrick-F merged 1 commit into
opengeos:mainfrom
Mavrick-F:t3/shapefile-zm-loss-fixtures
Nov 18, 2026
Merged

Mavrick-F merged 1 commit into
opengeos:mainfrom
Mavrick-F:t3/shapefile-zm-loss-fixtures

Conversation

@Mavrick-F

@Mavrick-F Mavrick-F commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Summary

Extend the reader-loss corpus through layer.addData with four independently byte-encoded Shapefile pairs: PointZ height, PointM measure, PolylineZ arrays without optional M, and PolylineZ with Z/M arrays. Each valid lossy input must import and report Z or M; each clean XY partner must import without that loss notice. Check exact XY geometry and ID attributes through both the native reader and the engine command.

Allow binary, pair-specific sidecars in the existing harness so each input gets a matching .shx; retain MapInfo coverage. The binary files total 1,784 bytes. Document their byte layout and attribution and narrow the roadmap remainder. No production reader or encoding changes, new dependencies, or command interfaces.

Surface coverage: exercises the shared native engine command used by desktop, CLI and Python. Browser Services/file upload, touch UI, ribbon/shortcuts/search, Assistant/MCP and plugins are unchanged and are not exercised by this filesystem corpus. No new state or action needs undo/removal/reopening behavior. These tiny fixtures exercise whole-file imports (io::read_shapefile_parts), not the size-triggered in-place ShpSource reader. Large-file/in-place coverage and other Shapefile loss kinds remain outside this slice.

Testing

  • Local cargo fmt --all, cargo test -p rustgis-engine --test never_silent_reading and cargo clippy -p rustgis-engine --test never_silent_reading -- -D warnings passed through the host wrapper and queue.
  • Private submission preflight passed. Binary layouts, full diff and all fixture sizes inspected.
  • Full fork CI passed on 2679ffb2c: Linux tests, schema, pre-commit lint, wasm32 and licences. Browser build validation is supplied there; the new integration cases use native filesystem paths.
  • ci:windows requests Windows validation of the file fixtures.

UI evidence

No visible UI change.

Related issue

Continues the Correct results roadmap's per-format reader-loss corpus after #2387, #2404 and #2412. This is limited to Shapefile Z/M fixtures; #2325, #2396 and #2389 retain their existing scope.

Summary by CodeRabbit

  • Documentation

    • Added documentation for Shapefile fixtures covering point and line Z/M data, expected imported geometry, and reported ordinate loss.
    • Updated the roadmap and fixture notes to reflect Shapefile coverage and clarify the sample data.
  • Tests

    • Added checks for Shapefile imports with Z/M data, including retained XY geometry and feature attributes, and reporting when Z or M values are dropped.

@Mavrick-F Mavrick-F added the ci:windows Run the Windows CI jobs on this pull request label Nov 18, 2026
@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The reading-loss test harness now supports separate byte sidecars for clean and lossy inputs. It adds Shapefile point and line Z/M fixtures, checks imported XY features and loss notices, and documents the fixture data and coverage.

Changes: Shapefile Reader-Loss Coverage

Layer / File(s) Summary
Input-specific sidecars
crates/engine/tests/never_silent_reading.rs
The test harness stores sidecars as bytes and assigns separate sidecar sets to clean and lossy inputs. Existing MapInfo and KMZ cases use the updated setup.
Shapefile fixtures and import checks
crates/engine/tests/never_silent_reading.rs, crates/engine/testdata/reading-losses/*, ROADMAP.md, ATTRIBUTION.md
Four Shapefile fixture pairs cover point Z, point M, line Z, and line ZM. Checks verify XY geometry, feature ID, loss status, notices, skipped records, and imported layer count. The fixture documentation, roadmap, and attribution table describe the coverage.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Other

Possibly related PRs

Suggested reviewers: giswqs, flight1973

Merge Risk: Minimal · up to 2679f

This change adds Shapefile Z/M reading-loss test coverage and documentation without touching production code, so the risk of merging it is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "test(engine): cover Shapefile Z/M reader losses" matches the main change. The PR adds four Shapefile PointZ, PointM, and PolylineZ/ZM reader-loss fixtures, with harness support and checks t…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description supplies a clear Summary of the four Shapefile Z/M fixture pairs, the harness change, byte total, attribution, and scope limits. It also gives test results and a related-issue referenc…
Full details: Title check

Explanation

The title "test(engine): cover Shapefile Z/M reader losses" matches the main change. The PR adds four Shapefile PointZ, PointM, and PolylineZ/ZM reader-loss fixtures, with harness support and checks that lossy inputs report Z or M. The title is concise, specific, and follows a conventional commit style.

Full details: Description check

Explanation

The description supplies a clear Summary of the four Shapefile Z/M fixture pairs, the harness change, byte total, attribution, and scope limits. It also gives test results and a related-issue reference. The Testing section is detailed. The UI evidence section states 'No visible UI change.', which matches the template's permitted wording. The Related issue section names the roadmap and linked issues. The description is complete against the template, so it passes.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks each point and line,
Through bytes that keep their sides in line.
Z and M may leave the view,
Yet XY and ID come through.
The fixtures hop into the test.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 73a03f3e-822f-4900-a53c-0ff63149b74b
Commits

Reviewing files that changed from the base of the PR and between 8b9900a and 2679ffb.

Files selected for processing: 18

  • ATTRIBUTION.md
  • ROADMAP.md
  • crates/engine/testdata/reading-losses/README.md
  • crates/engine/testdata/reading-losses/SHAPEFILE.md
  • crates/engine/testdata/reading-losses/shp-line-xy.shp
  • crates/engine/testdata/reading-losses/shp-line-xy.shx
  • crates/engine/testdata/reading-losses/shp-line-z.shp
  • crates/engine/testdata/reading-losses/shp-line-z.shx
  • crates/engine/testdata/reading-losses/shp-line-zm.shp
  • crates/engine/testdata/reading-losses/shp-line-zm.shx
  • crates/engine/testdata/reading-losses/shp-point-m.shp
  • crates/engine/testdata/reading-losses/shp-point-m.shx
  • crates/engine/testdata/reading-losses/shp-point-xy.shp
  • crates/engine/testdata/reading-losses/shp-point-xy.shx
  • crates/engine/testdata/reading-losses/shp-point-z.shp
  • crates/engine/testdata/reading-losses/shp-point-z.shx
  • crates/engine/testdata/reading-losses/shp-row.dbf
  • crates/engine/tests/never_silent_reading.rs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.

Imported("Z or M"),
),
]);
// Independently encoded shapes: scalar Z, scalar M, and arrays with/without optional M.

Copy link
Copy Markdown
Contributor

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.addData takes the whole-file path (io::read_shapefile_parts). Files over the size threshold go through ShpSource::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.

Copy link
Copy Markdown
Member Author

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 ShpSource path. 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.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

Bugs: None found. I traced the new cases through the reader code and they check out:

  • The whole-file reader (io::read_shapefile_parts) counts PointM, PointZ, PolylineZ and PolylineM shapes as Z/M and reports them through drop_zm, so the lossy fixtures should produce the notice and the clean ones should not.
  • The byte counts in SHAPEFILE.md match stats.json: the six .shp files total 1,068 B, the six .shx files 648 B, and the .dbf 68 B, for 1,784 B in all.
  • Harness changes (beside as a per-input pair, MapInfo and KMZ updated) are consistent. The clean and lossy reads each get their own .shx.
  • Not verified: I had no shell, so I did not compile or run the tests. The PR says fork CI passed on 2679ffb, which I could not check.

Security: None. Only test fixtures and documentation changed, with no parsing or input-handling changes.

Performance: None.

Quality:

  • Coverage gap, medium confidence (inline comment posted at never_silent_reading.rs:423). The fixtures are small, so they never reach the in-place ShpSource path that handles large files. That path decides Z/M loss from the header type, and only PointZ is covered there today. Either add in-place cases for types 13 and 21, or state in SHAPEFILE.md that large-file reading is out of scope.
  • Nit, low confidence. read() derives the expected Z/M state from the raw byte at offset 32 (never_silent_reading.rs:582). The same magic numbers (11 | 13 | 21, 1 | 11 | 21, 3 | 13) appear in check_shapefile_xy at line 526 and in the case list. A small helper that reads the little-endian i32 shape type, with named constants, would make this easier to follow. A truncated file also gets the misleading message "wrong geometry type".
  • Nit, low confidence. SHAPEFILE.md says "no generator is needed," but nothing in the repo records how the bytes were produced beyond the prose layout. The harness does not check the .shp header's file-length word or the .shx length, so a corrupted fixture would only be caught indirectly. One extra assertion would pin the documented layout.

AGENTS.md: Compliant on everything I checked. Both ways are tested; the lossy fixtures produce the notice and the clean ones do not. Every new binary file is covered by the shp-* row in ATTRIBUTION.md. No new dependencies, no change to what projects save, and the PR body covers the surfaces it reaches.

Already raised: 0. prior-reviews.json has no threads, so I left nothing out.

Change size

Compared with main (merge base 8b9900a to PR head 2679ffb), the whole PR.

Measure Value
Files changed 18 (14 added, 4 modified, 0 removed, 0 renamed)
Size before 60.7 KB (62,143 B)
Size after 69.5 KB (71,175 B)
Total size change +8.8 KB (+9,032 B)
Path Before After Change
crates/engine/tests/never_silent_reading.rs 27.7 KB 32.0 KB +4.3 KB
crates/engine/testdata/reading-losses/SHAPEFILE.md 0 B 2.3 KB +2.3 KB
ATTRIBUTION.md 11.4 KB 11.7 KB +308 B
crates/engine/testdata/reading-losses/shp-line-zm.shp 0 B 252 B +252 B
crates/engine/testdata/reading-losses/shp-line-z.shp 0 B 220 B +220 B
crates/engine/testdata/reading-losses/shp-line-xy.shp 0 B 188 B +188 B
crates/engine/testdata/reading-losses/shp-point-z.shp 0 B 144 B +144 B
crates/engine/testdata/reading-losses/shp-point-m.shp 0 B 136 B +136 B
crates/engine/testdata/reading-losses/shp-point-xy.shp 0 B 128 B +128 B
crates/engine/testdata/reading-losses/shp-line-xy.shx 0 B 108 B +108 B
crates/engine/testdata/reading-losses/shp-line-z.shx 0 B 108 B +108 B
crates/engine/testdata/reading-losses/shp-line-zm.shx 0 B 108 B +108 B
crates/engine/testdata/reading-losses/shp-point-m.shx 0 B 108 B +108 B
crates/engine/testdata/reading-losses/shp-point-xy.shx 0 B 108 B +108 B
crates/engine/testdata/reading-losses/shp-point-z.shx 0 B 108 B +108 B
crates/engine/testdata/reading-losses/README.md 2.0 KB 2.1 KB +106 B
crates/engine/testdata/reading-losses/shp-row.dbf 0 B 68 B +68 B
ROADMAP.md 19.6 KB 19.7 KB +18 B

@Mavrick-F

Copy link
Copy Markdown
Member Author

The PR description now explicitly limits this slice to whole-file imports; in-place coverage is deferred as noted inline. Consolidating fixture shape-type decoding/names and adding layout assertions for these fixed valid fixtures are also left for the release quality pass. The independently encoded layout and exact XY/ID results have already been checked; no production reader behavior changes here.

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-2420/
Web app https://preview.rustgis.app/pr-2420/app/
Commit 2679ffb

GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the preview label (once per commit).

@Mavrick-F
Mavrick-F added this pull request to the merge queue Nov 18, 2026
Merged via the queue into opengeos:main with commit dea552c Nov 18, 2026
47 checks passed
@Mavrick-F
Mavrick-F deleted the t3/shapefile-zm-loss-fixtures branch November 18, 2026 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:windows Run the Windows CI jobs on this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant