Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test and fix QgsRectangle::isNull #45607

Closed
wants to merge 6 commits into from
Closed

Conversation

strk
Copy link
Contributor

@strk strk commented Oct 21, 2021

Adds tests for QgsRectangle::isNull, improve toString to show the difference between Null and Empty, eventually fix the 0,0,0, rectangle case to still be Empty and NOT Null (to match documentation)

@strk strk self-assigned this Oct 21, 2021
@github-actions github-actions bot added this to the 3.22.0 milestone Oct 21, 2021
Comment on lines +47 to +50
: mXmin( std::numeric_limits<double>::max() )
, mYmin( std::numeric_limits<double>::max() )
, mXmax( -std::numeric_limits<double>::max() )
, mYmax( -std::numeric_limits<double>::max() )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if it's cleaner to just set these all as nan, and adjust the isnull test accordingly. What's your thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it matters, as long as callers all check for isNull

@nyalldawson
Copy link
Collaborator

I think this is heading in the right direction, nice work @strk !

@strk
Copy link
Contributor Author

strk commented Oct 22, 2021

There are 15 failing tests. One of them (testClipRasterByExtent) reports:

Running alg: "gdal:roughness"
Algorithm parameters are {'BAND': 1, 'COMPUTE_EDGES': False, 'INPUT': 'dem_tif_71fcbde4_c812_4dde_bce3_37bf5d741c31', 'OPTIONS': ''n 0.0 0.0 0.0 0.0 -of JPEG /root/QGIS/python/plugins/processing/tests/testdata/dem.tif /tmp/tmp1cjivwli/check.jpg'

  ['gdal_translate',
+  '-projwin 0.0 0.0 0.0 0.0 -of JPEG '
-  '-projwin 1.7976931348623157e+308 -1.7976931348623157e+308 '
-  '-1.7976931348623157e+308 1.7976931348623157e+308 -of JPEG '
   '/root/QGIS/python/plugins/processing/tests/testdata/dem.tif '
   '/tmp/tmp1cjivwli/check.jpg']

I would think -projwin should NOT be passed at all, so the expected result is wrong to me (expects to pass an invalid projwin when the rect is null, am I reading it right ?

The test is in python/plugins/processing/tests/GdalAlgorithmsRasterTest.py

@strk
Copy link
Contributor Author

strk commented Oct 22, 2021

That gdal_translate test is very suspiciou, because it expects gdal_translate being invoked with a -projwin 0.0 0.0 0.0 0.0 parameter but it passes the algorithm an EXTENT value of QgsRectangle(1, 2, 3, 4), so I don't know why it should end up being 0.0.0.0. @m-kuhn the test is documented to be yours. Ideas ?

@m-kuhn
Copy link
Member

m-kuhn commented Oct 22, 2021

Phew, that must be from years ago, do you have a link to the code or the PR that added it?

@strk
Copy link
Contributor Author

strk commented Oct 22, 2021

Phew, that must be from years ago, do you have a link to the code or the PR that added it?

Nope, and the testsuite had a reorganization at some point (2019) which makes it harder to tell.
The question is: does it make sense for -projwin to be 0,0,0,0 when the given extent is Null ? I'd think either NO -projwin should be given OR an error should be thrown (if the argument is mandatory)

@github-actions
Copy link

github-actions bot commented Nov 6, 2021

The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular

    • link to any issues which this pull request fixes

    • add a description of workflows which this pull request fixes

    • add screenshots if applicable

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in a week.

@github-actions github-actions bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Nov 6, 2021
@github-actions
Copy link

While we hate to see this happen, this PR has been automatically closed because it has not had any activity in the last 21 days. If this pull request should be reconsidered, please follow the guidelines in the previous comment and reopen this pull request. Or, if you have any further questions, just ask! We love to help, and if there's anything the QGIS project can do to help push this PR forward please let us know how we can assist.

@github-actions github-actions bot closed this Nov 13, 2021
@strk
Copy link
Contributor Author

strk commented Feb 16, 2022

Reopening as bug #45563 which this PR attempts to address, is still existing

@github-actions github-actions bot removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Feb 16, 2022
@strk
Copy link
Contributor Author

strk commented Feb 16, 2022

Reopening this PR didn't work, so I'm creating a new one replacing this

@strk
Copy link
Contributor Author

strk commented Feb 16, 2022

Superceeded by #47404

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.

3 participants