From 4dd780dab814b5da88107d42d206a87fc96a1551 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Tue, 5 Nov 2024 16:11:26 -0500 Subject: [PATCH 1/3] Better detect files with geotransform data that aren't geospatial gdalwarp and gdal_translate can be used to transform images in pixel space. If such an image has no projection specified and cannot be interpreted as latitude and longitude, assume it is not geospatial. --- CHANGELOG.md | 1 + sources/gdal/large_image_source_gdal/__init__.py | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3608d6a9..53e282653 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Format dates in item lists ([#1707](../../pull/1707)) - Guard dtype types ([#1711](../../pull/1711), [#1714](../../pull/1714), [#1716](../../pull/1716)) - Better handle IndicaLabs tiff files ([#1717](../../pull/1717)) +- Better detect files with geotransform data that aren't geospatial ([#1718](../../pull/1718)) ### Changes diff --git a/sources/gdal/large_image_source_gdal/__init__.py b/sources/gdal/large_image_source_gdal/__init__.py index 2033eeb5e..25c99d7ae 100644 --- a/sources/gdal/large_image_source_gdal/__init__.py +++ b/sources/gdal/large_image_source_gdal/__init__.py @@ -979,7 +979,13 @@ def isGeospatial(path): if ds.GetProjection(): return True if ds.GetGeoTransform(can_return_null=True): - return True + w = ds.RasterXSize + h = ds.RasterYSize + trans = ds.GetGeoTransform(can_return_null=True) + cornersy = [trans[3] + x * trans[4] + y * trans[5] + for x, y in {(0, 0), (0, h), (w, 0), (w, h)}] + if min(cornersy) >= -90 and max(cornersy) <= 90: + return True if ds.GetDriver().ShortName in {'NITF', 'netCDF'}: return True return False From c0edded5512126ea3dd9ad5d8d8ee1353499928f Mon Sep 17 00:00:00 2001 From: David Manthey Date: Mon, 11 Nov 2024 10:53:08 -0500 Subject: [PATCH 2/3] Reduce the size of the test docker image. Strip libraries; don't include python static libraries --- test.Dockerfile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test.Dockerfile b/test.Dockerfile index 5008877d5..452293ed4 100644 --- a/test.Dockerfile +++ b/test.Dockerfile @@ -74,16 +74,20 @@ RUN apt-get update && \ curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash && \ find / -xdev -name __pycache__ -type d -exec rm -r {} \+ && \ rm -r /etc/ssh/ssh_host* && \ + rm -rf /usr/share/vim/vim91/{doc,tutor}/* /usr/share/doc && \ apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /var/cache/* RUN git clone "https://github.com/universal-ctags/ctags.git" "./ctags" && \ cd ./ctags && \ ./autogen.sh && \ ./configure && \ + export CFLAGS="-g0 -Os -DNDEBUG" && \ + export LDFLAGS="-Wl,--strip-debug,--strip-discarded,--discard-locals" && \ make -j `nproc` && \ make install -j `nproc` && \ cd .. && \ - rm -rf ./ctags + rm -rf ./ctags && \ + rdfind -minsize 32768 -makehardlinks true -makeresultsfile false /usr/local/bin RUN pyenv update && \ pyenv install --list && \ @@ -95,7 +99,9 @@ RUN pyenv update && \ find $PYENV_ROOT/versions -type f '(' -name '*.py[co]' -o -name '*.exe' ')' -exec rm -fv '{}' + >/dev/null && \ echo $PYTHON_VERSIONS | tr " " "\n" > $PYENV_ROOT/version && \ find / -xdev -name __pycache__ -type d -exec rm -r {} \+ && \ - rm -rf /tmp/* /var/tmp/* && \ + rm -rf /tmp/* /var/tmp/* /root/.cache/* && \ + find /.pyenv -name '*.so' -o -name '*.a' -o -name '*.so.*' -exec strip --strip-unneeded -p -D {} \; && \ + find /.pyenv -name 'libpython*.a' -delete && \ # This makes duplicate python library files hardlinks of each other \ rdfind -minsize 32768 -makehardlinks true -makeresultsfile false /.pyenv @@ -118,6 +124,7 @@ RUN . ~/.bashrc && \ nvm install 14 && \ nvm alias default 14 && \ nvm use default && \ + rm -rf /root/.nvm/.cache && \ ln -s $(dirname `which npm`) /usr/local/node ENV PATH="/usr/local/node:$PATH" From 6b135be07b43aff56eb209906e7150ba9a61ba59 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Tue, 12 Nov 2024 15:03:19 -0500 Subject: [PATCH 3/3] Fix an issue searching for annotation metadata If a user has permission to view an annotation but not the item, a 403 was percolated to the UI --- CHANGELOG.md | 4 ++++ girder/girder_large_image/__init__.py | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53e282653..e9fc22261 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ - Openslide now requires the binary wheel on appropriate platforms ([#1709](../../pull/1709), [#1710](../../pull/1710)) +### Bug Fixes + +- Fix an issue searching for annotation metadata on items that a user doesn't have permissions to view ([#1723](../../pull/1723)) + ## 1.30.2 ### Features diff --git a/girder/girder_large_image/__init__.py b/girder/girder_large_image/__init__.py index fcf98ae5d..95891c2a4 100644 --- a/girder/girder_large_image/__init__.py +++ b/girder/girder_large_image/__init__.py @@ -428,7 +428,12 @@ def metadataSearchHandler( # noqa if id in foundIds: continue foundIds.add(id) - entry = resultModelInst.load(id=id, user=user, level=level, exc=False) + try: + entry = resultModelInst.load(id=id, user=user, level=level, exc=False) + except Exception: + # We might have permission to view an annotation but not + # the item + continue if entry is not None and offset: offset -= 1 continue