Skip to content

Commit

Permalink
Merge pull request #564 from girder/girder-geospatial-preference
Browse files Browse the repository at this point in the history
Prefer geospatial sources for geospatial data.
  • Loading branch information
manthey authored Mar 11, 2021
2 parents 25df815 + 9b10580 commit 97d099e
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 97d099e

Please sign in to comment.