Skip to content

Commit

Permalink
Merge pull request #639 from girder/better-geospatial-bounds
Browse files Browse the repository at this point in the history
Improve geospatial bounds in some projections.
  • Loading branch information
manthey authored Aug 16, 2021
2 parents 76a4b36 + 7d2ee7f commit 8fe382c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
## Unreleased

### Improvements
- More control over associated image caching
- More control over associated image caching (#638)
- Better handling some geospatial bounds (#639)

## Version 1.7.0

Expand Down
12 changes: 11 additions & 1 deletion sources/gdal/large_image_source_gdal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,18 @@ def getBounds(self, srs=None):
yBound = 90.0
except RuntimeError:
yBound = 89.999999
for key in ('ll', 'ul', 'lr', 'ur'):
keys = ('ll', 'ul', 'lr', 'ur')
for key in keys:
bounds[key]['y'] = max(min(bounds[key]['y'], yBound), -yBound)
while any(bounds[key]['x'] > 180 for key in keys):
for key in keys:
bounds[key]['x'] -= 360
while any(bounds[key]['x'] < -180 for key in keys):
for key in keys:
bounds[key]['x'] += 360
if any(bounds[key]['x'] >= 180 for key in keys):
bounds['ul']['x'] = bounds['ll']['x'] = -180
bounds['ur']['x'] = bounds['lr']['x'] = 180
if srs and srs != nativeSrs:
inProj = self._proj4Proj(nativeSrs)
outProj = self._proj4Proj(srs)
Expand Down
4 changes: 2 additions & 2 deletions test/test_source_gdal.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ def testGuardAgainstBadLatLong():
source = large_image_source_gdal.open(imagePath)
bounds = source.getBounds(srs='EPSG:4326')

assert bounds['xmin'] == -180.00416667
assert bounds['xmax'] == 179.99583333
assert bounds['xmin'] == -180
assert bounds['xmax'] == 180
assert bounds['ymin'] == -89.99583333
assert bounds['ymax'] == 90

Expand Down
4 changes: 2 additions & 2 deletions test/test_source_mapnik.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ def testGuardAgainstBadLatLong():
source = large_image_source_mapnik.open(imagePath)
bounds = source.getBounds(srs='EPSG:4326')

assert bounds['xmin'] == -180.00416667
assert bounds['xmax'] == 179.99583333
assert bounds['xmin'] == -180
assert bounds['xmax'] == 180
assert bounds['ymin'] == -89.99583333
assert bounds['ymax'] == 90

Expand Down

0 comments on commit 8fe382c

Please sign in to comment.