Closed dmahr1 closed 3 years ago
Man that's so much easier in Numpy :smile:
@geospatial-jeff I have very little experience contributing back to open source so please let me know if I'm not following decorum or best practices.
As discussed in the cogeotiff Slack, this is a work in progress PR for picking the closest overview level in a more reliable way. I would love to add some tests, but I am getting a large number of failures when I run pytest tests/
in a dedicated virtual environment. I think it has to do with accessing data via s3://
style links. I'm kind of a noob with boto (I use Google Cloud day-to-day) so perhaps there's some kind of initialization I'm neglecting?
Also, is there any way to run CI on PRs or is it only for builds of master?
Also, is there any way to run CI on PRs or is it only for builds of master?
I think now that we've switched to github actions this might run CI on your next commit. But I'm not 100% sure. If it doesn't i'll have to take a deeper look.
I would love to add some tests, but I am getting a large number of failures when I run
pytest tests/
in a dedicated virtual environment.
It should be easier now that we are using tox (thanks @vincentsarago ). I think you do need aws credentials configured in your environment or via aws configure
(otherwise boto is unhappy), but it doesn't matter what your creds are as its accessing data in a public bucket. With #98 we can remove this dependency.
this might run CI on your next commit
I think you need to merge master into your branch
@geospatial-jeff @kylebarron Thanks for the suggestions! I pulled upstream, got my aws
CLI configured, and on the master branch all tests are now passing. A few tests are failing on my PR branch but they are related to my change, so I'll fix them up and add some new tests as needed.
The CI did run but it ran into the same S3 credentials issue. It looks like @vincentsarago is looking into that in #100.
Really appreciate your help and patience here. 👍
@geospatial-jeff I've refactored this PR such that the ZOOM_LEVEL_STRATEGY
environment variable controls the behavior. The business logic is not quite as elegantly simple as it was with np.argmin
but it's a lot more flexible now. I put an explanation in the README (below) but I am open to other suggestions.
- ZOOM_LEVEL_STRATEGY - mimics GDAL's
ZOOM_LEVEL_STRATEGY
creation option:
AUTO
or50
(default) upsamples or downsamples the zoom level whose resolution is closest to the desired resolution.LOWER
or100
always upsamples the zoom level immediately below the desired resolution (requesting less data).UPPER
or0
always downsamples the zoom level immediately above the desired resoluion (requesting more data).- Another integer from
0
through100
: if the desired resolution more this percentage of the way from the zoom level immediately below to the zoom level immediately above, then upsample the zoom level immediately below, else downsample the zoom level immediately above. For example,1
is the same asUPPER
unless the COG's resolution is very close to the zoom level below e.g. due to floating point imprecision.
Also all tests are succeeding for me locally, but they are always failing in CI. Do you or @vincentsarago have any suggestions to fix the CI stuff?
P.S. Happy new year!
@dmahr1 I think the CI is falling because of how actions works (and because we are not yet using moto to mock boto3).
Yes @vincentsarago is correct
Work done
ZOOM_LEVEL_STRATEGY
environment variable that is intended to mimics theZOOM_LEVEL_STRATEGY
creation option in GDAL's COG driverAUTO
(default) upsamples or downsamples the zoom level whose resolution is closest to the desired resolution.LOWER
always upsamples the zoom level immediately below the desired resolution (requesting less data).UPPER
always downsamples the zoom level immediately above the desired resoluion (requesting more data).0
through100
: if the desired resolution is more than this percentage of the way from the zoom level immediately below to the zoom level immediately above, then upsample the zoom level immediately below, else downsample the zoom level immediately above.AUTO
andLOWER
andUPPER
are just shorthand for50
and100
and0
, respectively.0.597000001
and1.1940000001
, respectively.UPPER
/0
strategy, the request would be fulfilled by heaving downsampling the zoom level 18 tiles because1.194 < 1.1940000001
. For all practical purposes, this quadrupling of the requested data is wasteful and unnecessary.1
strategy, the threshold is computed as 1% of the way from the zoom level 17 res to the zoom level 18 res or1.1940000001 - (1.1940000001 - 0.597000001) * (1 / 100) = 1.188030000109
. Since1.194 >= 1.188030000109
then the request would be fulfilled by slightly upsampling zoom level 17 tiles.Links