Skip to content

fix(analysis): join layers with different source CRSs - #854

Merged
giswqs merged 1 commit into
opengeos:mainfrom
Mavrick-F:fix/spatial-join-source-crs
Oct 24, 2026
Merged

giswqs merged 1 commit into
opengeos:mainfrom
Mavrick-F:fix/spatial-join-source-crs

Conversation

@Mavrick-F

@Mavrick-F Mavrick-F commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Summary

Spatial Join rejected layers with different source CRSs even though Dataset geometry is already stored in longitude/latitude. Remove that metadata comparison so, for example, a projected-source layer can join a longitude/latitude-source layer. The output retains the target's source CRS for export.

Replace the rejection test with regression coverage for Intersects, Within and Contains, comparing geometry and joined attributes against the existing results. Update the user guide to explain that source CRSs may differ.

Testing

  • Regression failed before the fix with the coordinate-reference-system error and passed afterward.
  • cargo xtask ci passed (fmt, workspace Clippy, workspace tests and layers; serial tests with relay isolation on this host).
  • pre-commit run --all-files passed.
  • cargo build --locked --target wasm32-unknown-unknown -p rustgis-web passed.

Related issue

Prerequisite bug fix described in #851. The new Spatial Join options and merge rules remain separate work.

Summary by CodeRabbit

  • New Features
    • Spatial joins now support target and join layers with different coordinate systems. Geometries are compared in longitude and latitude, and the output retains the target layer’s coordinate system.
  • Documentation
    • Updated the spatial join guide to describe support for differing coordinate systems.

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

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: b45113e8-5b21-4d37-86fc-edc01c081a46
Commits

Reviewing files that changed from the base of the PR and between f3f306b and 93e0499.

Files selected for processing: 2
  • crates/analysis/src/tools.rs
  • docs/user-guide/analysis.md

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

Walkthrough

Spatial Join no longer rejects layers with different CRS metadata. Regression tests check the join results and output metadata. The user guide now describes support for layers with different source coordinate systems.

Changes: Spatial Join CRS handling

Layer / File(s) Summary
Support joins with differing CRS metadata
crates/analysis/src/tools.rs, docs/user-guide/analysis.md
Spatial Join proceeds when the layers have different CRS metadata. Tests compare results with baseline joins and check output metadata. The user guide describes the supported coordinate systems.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

  • opengeos/RustGIS#851 — This PR removes the Spatial Join rejection for layers with differing source CRSs and adds regression coverage.
  • opengeos/RustGIS#748 — This PR adds checks for Spatial Join fields and features, which relate to the issue’s request to test output geometry and attributes.

Suggested reviewers: quanguet0409

Merge Risk: Minimal · up to 93e04

The Spatial Join CRS behavior is consistent with the documented contract, with no identified merge-blocking risk.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title "fix(analysis): join layers with different source CRSs" matches the main change. The raw summary shows spatial_join no longer rejects target and join layers with differing CRS metadata, and …
Description check Passed The description follows the template. It has a Summary section that explains the change, why it is needed (Dataset geometry is already stored as lon/lat), and that the output retains the target's sour…
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.
Full details: Title check

Explanation

The title "fix(analysis): join layers with different source CRSs" matches the main change. The raw summary shows spatial_join no longer rejects target and join layers with differing CRS metadata, and the user guide was updated to match. The title names the fix, the affected area (analysis), and the behavior change. It is specific and concise.

Full details: Description check

Explanation

The description follows the template. It has a Summary section that explains the change, why it is needed (Dataset geometry is already stored as lon/lat), and that the output retains the target's source CRS. It also covers the replaced rejection test and the user guide update. The Testing section lists the regression test before and after the fix, cargo xtask ci, pre-commit, and a wasm build. The Related issue section references #851 as a prerequisite and states that the new Spatial Join options are separate work. The template's required headings are all present and filled in.

Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

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 maps the meadow wide,
With lon and lat as paths to guide.
Two layers meet, though CRSs vary,
Their joined fields are checked with care.
The target’s CRS stays in its place,
Then hops away with measured grace.

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

I found no bugs, security issues or AGENTS.md violations in this PR.

What changed: spatialJoin no longer rejects layers whose source CRS differs. The test and the user guide are updated to match.

What I checked

  • Premise: The Dataset.crs doc in crates/data/src/lib.rs says geometry is always longitude/latitude and crs is only the source or export CRS. Comparing geometry across layers with different crs values is therefore valid, and the removed check was an over-restriction.
  • Output CRS: out.crs = target.crs (tools.rs:1335) keeps the target's source CRS for export. source is cleared, and the new test asserts both.
  • Consistency with other tools: Kriging still rejects non-LonLat layers (tools.rs:1009). That is a different case, because it needs degree-based distances, so it isn't inconsistent.
  • Never-crash rules: The new unwrap() calls are all in #[cfg(test)] code, which the rules allow. The change adds no panicking paths to non-test code.
  • Tests: The test now covers Intersects, Within and Contains with mismatched CRSs. It asserts that the fields and features match the same-CRS baselines (ds1, ds5, ds4).
  • Docs: docs/user-guide/analysis.md is updated.

Nits (low confidence, optional)

  • Quality: The test's m_crs.0.get(params["target"].as_str().unwrap()).unwrap() could name the target layer in the tuple instead of looking it up from the JSON.
  • Quality: The new doc comment on spatial_join says "retaining the target's source CRS for export". The user guide doesn't tell users that the output keeps the target's CRS, so one sentence there could help.

Change size

Compared: the whole PR against main (merge base d76e1fc to PR head 93e0499).

Metric Value
Files changed 2 (added 0, modified 2, removed 0, renamed 0)
Size before 188.6 KB
Size after 189.1 KB
Total size change +535 B
File Before After Change
crates/analysis/src/tools.rs 146.3 KB 146.8 KB +448 B
docs/user-guide/analysis.md 42.3 KB 42.3 KB +87 B

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-854/
Web app https://preview.rustgis.app/pr-854/app/
Commit 93e0499

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).

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