diff --git a/CHANGELOG.md b/CHANGELOG.md index f754a548f..5ea62562b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - Harden converting sources that report varied tile bands ([#1615](../../pull/1615)) - Harden many of the sources from reading bad files ([#1623](../../pull/1623)) +- Some projected bounds in the rasterio source could be off ([#1624](../../pull/1624)) ## 1.29.6 diff --git a/sources/bioformats/large_image_source_bioformats/__init__.py b/sources/bioformats/large_image_source_bioformats/__init__.py index 04e8a54d1..6fbfee33a 100644 --- a/sources/bioformats/large_image_source_bioformats/__init__.py +++ b/sources/bioformats/large_image_source_bioformats/__init__.py @@ -106,7 +106,7 @@ def _reduceLogging(): 'org/slf4j/LoggerFactory', 'getLogger', '(Ljava/lang/String;)Lorg/slf4j/Logger;', rootLoggerName) logLevel = javabridge.get_static_field( - 'ch/qos/logback/classic/Level', 'ERROR', 'Lch/qos/logback/classic/Level;') + 'ch/qos/logback/classic/Level', 'OFF', 'Lch/qos/logback/classic/Level;') javabridge.call(rootLogger, 'setLevel', '(Lch/qos/logback/classic/Level;)V', logLevel) except Exception: pass diff --git a/sources/gdal/large_image_source_gdal/__init__.py b/sources/gdal/large_image_source_gdal/__init__.py index 3b0438f44..ba484e9e5 100644 --- a/sources/gdal/large_image_source_gdal/__init__.py +++ b/sources/gdal/large_image_source_gdal/__init__.py @@ -494,12 +494,11 @@ def getBounds(self, srs=None): 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): + dx = min(bounds[key]['x'] for key in keys) + if dx < -180 or dx >= 180: + dx = ((dx + 180) % 360 - 180) - dx 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 + bounds[key]['x'] += dx if any(bounds[key]['x'] >= 180 for key in keys): bounds['ul']['x'] = bounds['ll']['x'] = -180 bounds['ur']['x'] = bounds['lr']['x'] = 180 diff --git a/sources/rasterio/large_image_source_rasterio/__init__.py b/sources/rasterio/large_image_source_rasterio/__init__.py index d336ccf78..486a04ea8 100644 --- a/sources/rasterio/large_image_source_rasterio/__init__.py +++ b/sources/rasterio/large_image_source_rasterio/__init__.py @@ -417,15 +417,14 @@ def getBounds(self, crs=None, **kwargs): for k in bounds: bounds[k]['y'] = max(min(bounds[k]['y'], yBounds), -yBounds) - # for each corner rotate longitude until it's within -180, 180 - while any(v['x'] > 180 for v in bounds.values()): + # rotate longitude so the western-most corner is within [-180, 180) + dx = min(v['x'] for v in bounds.values()) + if dx < -180 or dx >= 180: + dx = ((dx + 180) % 360 - 180) - dx for k in bounds: - bounds[k]['x'] -= 180 - while any(v['x'] < -180 for v in bounds.values()): - for k in bounds: - bounds[k]['x'] += 360 + bounds[k]['x'] += dx - # if one of the corner is > 180 set all the corner to world width + # if one of the corner is >= 180 set all the corners to world width if any(v['x'] >= 180 for v in bounds.values()): bounds['ul']['x'] = bounds['ll']['x'] = -180 bounds['ur']['x'] = bounds['lr']['x'] = 180 diff --git a/sources/rasterio/setup.py b/sources/rasterio/setup.py index f9ca4956d..2478a910c 100644 --- a/sources/rasterio/setup.py +++ b/sources/rasterio/setup.py @@ -56,7 +56,9 @@ def prerelease_local_scheme(version): ], install_requires=[ f'large-image{limit_version}', - 'rasterio>=1.3', # to get the statistics attribute (<=> gdalinfo) + 'rasterio>=1.3,<1.3.11 ; python_version < "3.9"', + # We need rasterio > 1.3 to get the statistics attribute (<=> gdalinfo) + 'rasterio>=1.3 ; python_version >= "3.9"', 'packaging', ], extras_require={