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

Add geospatial property #818

Merged
merged 2 commits into from
Jul 29, 2022
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
2 changes: 1 addition & 1 deletion large_image/tilesource/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def getSourceNameFromDict(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
banesullivan marked this conversation as resolved.
Show resolved Hide resolved
_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):
banesullivan marked this conversation as resolved.
Show resolved Hide resolved
"""
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