Skip to content

Commit

Permalink
Prefer geospatial sources for geospatial data.
Browse files Browse the repository at this point in the history
Apply the same logic to prefer geospatial sources in Girder as we do in
core.
  • Loading branch information
manthey committed Mar 11, 2021
1 parent 25df815 commit 9b10580
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## Unreleased

### Improvements
- In Girder, prefer geospatial sources for geospatial data

## Version 1.4.2

### Features
Expand Down
14 changes: 12 additions & 2 deletions girder/girder_large_image/girder_tilesource.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,14 @@ def getGirderTileSourceName(item, file=None, *args, **kwargs):
loadGirderTileSources()
if not file:
file = File().load(item['largeImage']['fileId'], force=True)
try:
localPath = File().getLocalFilePath(file)
except (FilePathException, AttributeError):
localPath = None
extensions = [entry.lower().split()[0] for entry in file['exts'] if entry]
properties = {}
if localPath:
properties['geospatial'] = tilesource.isGeospatial(localPath)
sourceList = []
for sourceName in AvailableGirderTileSources:
if not getattr(AvailableGirderTileSources[sourceName], 'girderSource', False):
Expand All @@ -160,8 +167,11 @@ def getGirderTileSourceName(item, file=None, *args, **kwargs):
priority = min(priority, sourceExtensions[ext])
if priority >= SourcePriority.MANUAL:
continue
sourceList.append((priority, sourceName))
for _priority, sourceName in sorted(sourceList):
propertiesClash = any(
getattr(AvailableGirderTileSources[sourceName], k, False) != v
for k, v in properties.items())
sourceList.append((propertiesClash, priority, sourceName))
for _clash, _priority, sourceName in sorted(sourceList):
if AvailableGirderTileSources[sourceName].canRead(item):
return sourceName

Expand Down

0 comments on commit 9b10580

Please sign in to comment.