Skip to content

Commit

Permalink
Add test for hfun fast extent
Browse files Browse the repository at this point in the history
  • Loading branch information
SorooshMani-NOAA committed Oct 6, 2023
1 parent c5ea5c6 commit 187fb0b
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/api/hfun.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,32 @@ def test_add_feature_fast(self):
self.assertTrue(isinstance(hfun_msht, jigsaw_msh_t))


def test_hfun_fast_extent(self):
r_path = self.tdir / 'rast_large.tif'
rast_xy = np.mgrid[-50:50:0.2, 0:50:0.2]
rast_z = np.ones_like(rast_xy[0]) * 100

ocsmesh.utils.raster_from_numpy(
r_path, rast_z, rast_xy, 4326
)

rast = ocsmesh.Raster(r_path)
hfun_coll = ocsmesh.Hfun(
[rast], hmin=10000, hmax=20000, method='fast'
)
hfun_msht = hfun_coll.msh_t()

ocsmesh.utils.reproject(hfun_msht, rast.crs)
rast_box = rast.get_bbox()
hfun_box = ocsmesh.utils.get_mesh_polygons(hfun_msht)

# NOTE: It's good enough if it covers most of it (?)
self.assertTrue(hfun_box.covers(
rast_box.buffer(-0.001 * np.sqrt(rast_box.area))
))



class SizeFromMesh(unittest.TestCase):

def setUp(self):
Expand Down

0 comments on commit 187fb0b

Please sign in to comment.