Skip to content

GDALSuggestedWarpOutput2: error out when computed dimensions are zero (fixes #15266) - #15274

Open
farzinashouri wants to merge 1 commit into
OSGeo:masterfrom
farzinashouri:fix-15266-degenerate-warped-vrt
Open

farzinashouri wants to merge 1 commit into
OSGeo:masterfrom
farzinashouri:fix-15266-degenerate-warped-vrt

Conversation

@farzinashouri

Copy link
Copy Markdown

What does this PR do?

When a source crosses the antimeridian, PROJ wraps longitudes past 180 to the far side of the globe, so the computed X extent becomes globe-wide while the Y extent stays small. The square-pixel heuristic in GDALSuggestedWarpOutput2 then picks a pixel height larger than the whole Y span, and the line count rounds down to zero.

AutoCreateWarpedVRT returned a 23x0 dataset instead of failing, and the problem only surfaced later as "Attempt to create 23x0 dataset is illegal".

This adds a check for a zero or negative computed width or height, mirroring the existing check for dimensions that come out too large a few lines above. The failure now happens where the bad dimensions are computed.

What are related issues/pull requests?

Fixes #15266

AI tool usage

I reported the issue and diagnosed the cause, and used an AI assistant to write the patch and the test. I reviewed the change, built it locally and ran the test suite.

Tasklist

  • Make sure code is correctly formatted
  • Add test case(s)
  • Add documentation
  • Updated Python API documentation (swig/include/python/docs/)
  • Review
  • Adjust for comments
  • All CI builds and checks have passed

Environment

  • OS: macOS 15.5 (arm64)
  • Compiler: AppleClang 17.0.0

…fixes OSGeo#15266)

When a source crosses the antimeridian, PROJ wraps longitudes past 180 to
the far side of the globe, so the computed X extent becomes globe-wide
while the Y extent stays small. The square-pixel heuristic then picks a
pixel height larger than the whole Y span, and the line count rounds down
to zero. AutoCreateWarpedVRT returned a 23x0 dataset instead of failing.

This mirrors the existing check for dimensions that come out too large.

This branch has not been deployed

No deployments
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.

AutoCreateWarpedVRT returns a zero-height dataset for an antimeridian-crossing source

2 participants