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

Allow GDAL to read non-geospatial files. #655

Merged
merged 1 commit into from
Sep 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion girder/test_girder/test_tiles_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,8 @@ def testTilesFromGreyscale(boundServer, admin, fsAssetstore, girderWorker):
file = utilities.uploadTestFile('grey10kx5k.tif', admin, fsAssetstore)
itemId = str(file['itemId'])
fileId = str(file['_id'])
tileMetadata = _postTileViaHttp(boundServer, admin, itemId, fileId)
boundServer.request(path='/item/%s/tiles' % itemId, method='DELETE', user=admin)
tileMetadata = _postTileViaHttp(boundServer, admin, itemId, fileId, data={'force': True})
assert tileMetadata['tileWidth'] == 256
assert tileMetadata['tileHeight'] == 256
assert tileMetadata['sizeX'] == 10000
Expand Down
6 changes: 4 additions & 2 deletions sources/gdal/large_image_source_gdal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,12 @@ def __init__(self, path, projection=None, unitsPerPixel=None, **kwargs):
scale = self.getPixelSizeInMeters()
except RuntimeError:
raise TileSourceException('File cannot be opened via GDAL.')
if not scale and not is_netcdf:
if (self.projection or self._getDriver() in {
'PNG',
}) and not scale and not is_netcdf:
raise TileSourceException(
'File does not have a projected scale, so will not be '
'opened via GDAL.')
'opened via GDAL with a projection.')
self.sourceLevels = self.levels = int(max(0, math.ceil(max(
math.log(float(self.sizeX) / self.tileWidth),
math.log(float(self.sizeY) / self.tileHeight)) / math.log(2))) + 1)
Expand Down
3 changes: 2 additions & 1 deletion sources/openjpeg/large_image_source_openjpeg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import math
import multiprocessing
import queue
import struct
import warnings
from xml.etree import ElementTree

Expand Down Expand Up @@ -90,7 +91,7 @@ def __init__(self, path, **kwargs):
self._pixelInfo = {}
try:
self._openjpeg = glymur.Jp2k(largeImagePath)
except glymur.jp2box.InvalidJp2kError:
except (glymur.jp2box.InvalidJp2kError, struct.error):
raise TileSourceException('File cannot be opened via Glymur and OpenJPEG.')
glymur.set_option('lib.num_threads', multiprocessing.cpu_count())
self._openjpegHandles = queue.LifoQueue()
Expand Down