fix: reject incomplete NTv2 bicubic stencils at subgrid edges - #172
Open
timothyanderson096-ocdealcheck wants to merge 1 commit into
Conversation
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.
Problem
Bicubic NTv2 interpolation assumes a complete 4x4 neighbourhood without checking that it stays inside the selected subgrid. Near the edges, this can wrap into another row, interpret header or neighbouring-subgrid bytes as nodes, or read beyond EOF. Issue #170 reports incorrect coordinate shifts and binary read failures.
Change
Validate row and column bounds in SubGrid.ntv2_bicubic before any file access. Incomplete stencils now raise an actionable ValueError directing callers to method='bilinear'. The requested interpolation method is not silently changed. Interior bicubic calculations, subgrid selection and existing north/west extent exclusions are preserved.
Document the boundary behaviour in the interpolation and transformation APIs and the NTv2 guide.
Validation
Validation used synthetic grids. The reporter's real-grid examples and deployed government services were not tested. This fixes invalid stencil reads; it does not implement one-sided bicubic interpolation at boundaries.
Fixes #170
Prepared by Tim Anderson, Spotted Ridge Engineering / OC Labs, Australia, with OpenAI Codex assistance.