-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtest_height_maps.py
66 lines (49 loc) · 2.35 KB
/
test_height_maps.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from pathlib import Path
from srtm.height_maps import Srtm3HeightMap
from srtm.utilities import get_srtm3_file_path
def test_get_altitude_for_pixed():
height_map = Srtm3HeightMap(path=get_srtm3_file_path("N40W008"))
# Values taken from raster parsed by postgis, loaded with raster2pgsql
assert height_map.get_altitude_for_pixel(x=1, y=1) == 1130
assert height_map.get_altitude_for_pixel(x=1, y=2) == 1137
assert height_map.get_altitude_for_pixel(x=1201, y=1) == 317
assert height_map.get_altitude_for_pixel(x=1, y=1201) == 620
assert height_map.get_altitude_for_pixel(x=1201, y=1201) == 390
def test_latitude_and_longitude_to_coordinates_corner1():
height_map = Srtm3HeightMap(path=Path("/dummy/N40W008.hgt.zip"))
# x,y = 1, 1
assert height_map._latitude_and_longitude_to_coordinates(
latitude=41, longitude=-8
) == (1, 1)
def test_latitude_and_longitude_to_coordinates_corner2():
height_map = Srtm3HeightMap(path=Path("/dummy/N40W008.hgt.zip"))
# x,y = 1201, 1201
assert height_map._latitude_and_longitude_to_coordinates(
latitude=40, longitude=-7
) == (1201, 1201)
def test_latitude_and_longitude_to_coordinates_ne():
height_map = Srtm3HeightMap(path=Path("/dummy/N40E015.hgt.zip"))
assert height_map._latitude_and_longitude_to_coordinates(
latitude=40.6208333, longitude=15.101666
) == (123, 456)
def test_latitude_and_longitude_to_coordinates_nw():
height_map = Srtm3HeightMap(path=Path("/dummy/N40W008.hgt.zip"))
assert height_map._latitude_and_longitude_to_coordinates(
latitude=40.6208333, longitude=-7.898333
) == (123, 456)
def test_latitude_and_longitude_to_coordinates_se():
height_map = Srtm3HeightMap(path=Path("/dummy/S34E018.hgt.zip"))
assert height_map._latitude_and_longitude_to_coordinates(
latitude=-33.37916666, longitude=18.1016666
) == (123, 456)
def test_latitude_and_longitude_to_coordinates_sw():
height_map = Srtm3HeightMap(path=Path("/dummy/S08W015.hgt.zip"))
assert height_map._latitude_and_longitude_to_coordinates(
latitude=-7.37916666666667, longitude=-14.8983333333333
) == (123, 456)
def test_get_altitude():
height_map = Srtm3HeightMap(path=get_srtm3_file_path("N40W008"))
assert (
height_map.get_altitude_for_latitude_and_longitude(latitude=40, longitude=-7)
== 390
)