diff --git a/odc/stac/_mdtools.py b/odc/stac/_mdtools.py index 9ad538b..4f983a9 100644 --- a/odc/stac/_mdtools.py +++ b/odc/stac/_mdtools.py @@ -255,21 +255,6 @@ def mk_1x1_geobox(g: Geometry) -> GeoBox: return GeoBox((1, 1), Affine((x2 - x1), 0, x1, 0, (y1 - y2), y2), g.crs) -def _gbox_anchor(gbox: GeoBox, tol: float = 1e-3) -> GeoboxAnchor: - def _anchor(px: float, tol: float) -> float: - _, x = split_float(px) # x in (-0.5, +0.5) - x = (1 + x) if x < 0 else x # x in [0, 1) - x = snap_scale(maybe_zero(x, tol), tol) - return 0 if x >= 1 else x - - anchor = tuple(_anchor(px, tol) for px in (~gbox.transform) * (0, 0)) - if anchor == (0, 0): - return AnchorEnum.EDGE - if anchor == (0.5, 0.5): - return AnchorEnum.CENTER - return xy_(anchor) - - def asset_geobox(asset: pystac.asset.Asset) -> GeoBox: """ Compute GeoBox from STAC Asset. @@ -762,10 +747,10 @@ def _most_common_gbox( _gboxes = set(gboxes) if len(_gboxes) == 1: g = _gboxes.pop() - return (g.crs, g.resolution, _gbox_anchor(g), g) + return (g.crs, g.resolution, g.anchor, g) # Most common shared CRS, Resolution, Anchor - gg = [(g.crs, g.resolution, _gbox_anchor(g)) for g in gboxes] + gg = [(g.crs, g.resolution, g.anchor) for g in gboxes] hist = Counter(gg) (best, n), *_ = hist.most_common(1) if n / len(gg) > thresh: diff --git a/setup.cfg b/setup.cfg index 3672700..7b06efe 100644 --- a/setup.cfg +++ b/setup.cfg @@ -37,7 +37,7 @@ tests_require = install_requires = affine - odc-geo>=0.3.0 + odc-geo>=0.4.4 rasterio>=1.0.0,!=1.3.0,!=1.3.1 dask[array] numpy>=1.20.0 diff --git a/tests/test_mdtools.py b/tests/test_mdtools.py index 5c8d5d5..72e6e8b 100644 --- a/tests/test_mdtools.py +++ b/tests/test_mdtools.py @@ -19,7 +19,6 @@ from odc.loader.types import FixedCoord, RasterBandMetadata, RasterGroupMetadata from odc.stac._mdtools import ( _auto_load_params, - _gbox_anchor, _most_common_gbox, _normalize_geometry, asset_geobox, @@ -635,20 +634,6 @@ def test_usgs_v1_1_1_aliases(usgs_landsat_stac_v1_1_1: pystac.Item) -> None: } -@pytest.mark.parametrize( - "gbox", - [ - GeoBox.from_bbox((0, 0, 100, 200), resolution=10, crs=3857), - GeoBox.from_bbox((-10, 0, 100, 200), resolution=10, crs=3857), - ], -) -def test_gbox_anchor(gbox: GeoBox): - assert _gbox_anchor(gbox) == AnchorEnum.EDGE - assert _gbox_anchor(gbox.translate_pix(-1e-5, 1e-5)) == AnchorEnum.EDGE - assert _gbox_anchor(gbox.translate_pix(0.5, 0.5)) == AnchorEnum.CENTER - assert _gbox_anchor(gbox.translate_pix(-1 / 4, -1 / 8)) == xy_(1 / 4, 1 / 8) - - def test_most_common_gbox(): gbox = GeoBox.from_bbox((0, 0, 100, 200), resolution=10, crs=3857) assert _most_common_gbox(