Skip to content

Commit

Permalink
test: modification of test_compute_dem_intersection_with_poly
Browse files Browse the repository at this point in the history
  • Loading branch information
Tommy committed Nov 18, 2024
1 parent db067f6 commit 8b4fc0e
Showing 1 changed file with 6 additions and 26 deletions.
32 changes: 6 additions & 26 deletions tests/core/test_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,34 +90,12 @@ def test_compute_dem_intersection_with_poly():
)

dem_inter_poly, cover = projection.compute_dem_intersection_with_poly(
absolute_data_path("input/phr_ventoux/srtm"), inter_poly, inter_epsg
)
assert dem_inter_poly.equals(inter_poly)
assert cover == 100.0

# test partial coverage over with several srtm tiles with no data holes
inter_poly = Polygon(
[(4.8, 44.2), (4.8, 44.3), (6.2, 44.3), (6.2, 44.2), (4.8, 44.2)]
)
dem_inter_poly, cover = projection.compute_dem_intersection_with_poly(
absolute_data_path("input/utils_input/srtm_with_hole"),
absolute_data_path("input/phr_ventoux/srtm/N44E005.hgt"),
inter_poly,
inter_epsg,
)

ref_dem_inter_poly = Polygon(
[
(4.999583333333334, 44.3),
(6.2, 44.3),
(6.2, 44.2),
(4.999583333333334, 44.2),
(4.999583333333334, 44.3),
]
)

assert ref_dem_inter_poly.exterior.equals(dem_inter_poly.exterior)
assert len(list(dem_inter_poly.interiors)) == 6
assert cover == 85.72172619047616
assert dem_inter_poly.equals(inter_poly)
assert cover == 100.0

# test no coverage
inter_poly = Polygon(
Expand All @@ -126,7 +104,9 @@ def test_compute_dem_intersection_with_poly():

with pytest.raises(Exception) as intersect_error:
dem_inter_poly, cover = projection.compute_dem_intersection_with_poly(
absolute_data_path("input/phr_ventoux/srtm"), inter_poly, inter_epsg
absolute_data_path("input/phr_ventoux/srtm/N44E005.hgt"),
inter_poly,
inter_epsg,
)
assert (
str(intersect_error.value) == "The input DEM does not intersect "
Expand Down

0 comments on commit 8b4fc0e

Please sign in to comment.