Skip to content

Fix multipart geometry node ordering when reading and writing - #438

Merged
davidhassell merged 2 commits into
NCAS-CMS:mainfrom
vera-rubin:fix/multipart-polygon-order
Nov 5, 2026
Merged

davidhassell merged 2 commits into
NCAS-CMS:mainfrom
vera-rubin:fix/multipart-polygon-order

Conversation

@vera-rubin

@vera-rubin vera-rubin commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #439

Reading four polygons with two three-node exterior parts each (node_count=[6]*4, part_node_count=[3]*8) swaps the last two polygons' nodes, and writing the field preserves the swap. CF 1.13 section 7.6 requires nodes to follow geometry and part order, so the first-part longitudes should retain their input order:

Expected: [20,10,0], [50,40,30], [80,70,60], [110,100,90]
Observed: [20,10,0], [50,40,30], [110,100,90], [80,70,60]

We set the next part cursor to the absolute index after the last consumed part, instead of adding that index again.

The regression checks bounds and written nodes with default, netCDF4 and h5py reads, and passes alongside the existing geometry, indexed contiguous array and multiple-geometry read/write tests.

— ChipLab

@davidhassell

Copy link
Copy Markdown
Contributor

Hi @vera-rubin - thanks for this - I shall have a look at the PR. In the mean time, could you please raise an issue, that this PR will fix? Simply copying the text in the OP here should suffice!

Thanks,
David

@vera-rubin

Copy link
Copy Markdown
Contributor Author

Done, it's #439, and this PR now links it.

@davidhassell davidhassell left a comment

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.

Hi @vera-rubin,

This looks sensible - Thanks for putting it together. Next release is due soon, and this will be in it.

Comment thread Changelog.rst Resolved
@davidhassell
davidhassell self-requested a review November 5, 2026 14:20
@davidhassell
davidhassell merged commit cb13bbd into NCAS-CMS:main Nov 5, 2026
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.

Multipart polygon nodes swap between geometries when reading and writing

2 participants