Skip to content

Commit

Permalink
Merge pull request #818 from girder/patch/geospatial-attr
Browse files Browse the repository at this point in the history
Add `geospatial` property
  • Loading branch information
manthey authored Jul 29, 2022
2 parents e6cb017 + a026d9e commit 4d3ba5e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion large_image/tilesource/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def getSortedSourceList(availableSources, pathOrUri, *args, **kwargs):
isLargeImageUri = str(pathOrUri).startswith('large_image://')
extensions = [ext.lower() for ext in os.path.basename(uriWithoutProtocol).split('.')[1:]]
properties = {
'geospatial': isGeospatial(pathOrUri),
'_geospatial_source': isGeospatial(pathOrUri),
}
sourceList = []
for sourceName in availableSources:
Expand Down
2 changes: 2 additions & 0 deletions large_image/tilesource/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class TileSource:
None: SourcePriority.FALLBACK
}

geospatial = False

def __init__(self, encoding='JPEG', jpegQuality=95, jpegSubsampling=0,
tiffCompression='raw', edge=False, style=None, *args,
**kwargs):
Expand Down
19 changes: 13 additions & 6 deletions sources/gdal/large_image_source_gdal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class GDALFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
'image/tiff': SourcePriority.LOW,
'image/x-tiff': SourcePriority.LOW,
}
geospatial = True
_geospatial_source = True

def __init__(self, path, projection=None, unitsPerPixel=None, **kwargs):
"""
Expand Down Expand Up @@ -601,14 +601,21 @@ def getBandInformation(self, statistics=True, dataset=None, **kwargs):
self._bandInfo = infoSet
return self._bandInfo

@property
def geospatial(self):
"""
This is true if the source has geospatial information.
"""
return bool(
self.dataset.GetProjection() or
(self.dataset.GetGCPProjection() and self.dataset.GetGCPs()) or
self.dataset.GetGeoTransform(can_return_null=True) or
hasattr(self, '_netcdf'))

def getMetadata(self):
with self._getDatasetLock:
metadata = {
'geospatial': bool(
self.dataset.GetProjection() or
(self.dataset.GetGCPProjection() and self.dataset.GetGCPs()) or
self.dataset.GetGeoTransform(can_return_null=True) or
hasattr(self, '_netcdf')),
'geospatial': self.geospatial,
'levels': self.levels,
'sizeX': self.sizeX,
'sizeY': self.sizeY,
Expand Down
1 change: 0 additions & 1 deletion sources/mapnik/large_image_source_mapnik/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class MapnikFileTileSource(GDALFileTileSource, metaclass=LruCacheMetaclass):
'image/tiff': SourcePriority.LOWER,
'image/x-tiff': SourcePriority.LOWER,
}
geospatial = True

def __init__(self, path, projection=None, unitsPerPixel=None, **kwargs):
"""
Expand Down

0 comments on commit 4d3ba5e

Please sign in to comment.