-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_proxy.py
More file actions
74 lines (69 loc) · 2.12 KB
/
Copy pathtest_proxy.py
File metadata and controls
74 lines (69 loc) · 2.12 KB
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
67
68
69
70
71
72
73
74
import math
import pytest
from pypsdm.db.weather.models import Coordinate
from pypsdm.db.weather.utils import weighted_interpolation_coordinates
@pytest.mark.docker_required
def test_weighted_interpolation_coordinates():
nearest_coordinates = [
(
Coordinate.from_hex(
id=13890,
wkb_hex="0101000020E610000000000000008026400000000000E04A40",
),
15336.967985536437,
),
(
Coordinate.from_hex(
id=13891,
wkb_hex="0101000020E610000000000000000027400000000000E04A40",
),
15741.508288878984,
),
(
Coordinate.from_hex(
id=14079,
wkb_hex="0101000020E610000000000000008026400000000000C04A40",
),
16606.405396805483,
),
(
Coordinate.from_hex(
id=14080,
wkb_hex="0101000020E610000000000000000027400000000000C04A40",
),
16982.92952636213,
),
(
Coordinate.from_hex(
id=13889,
wkb_hex="0101000020E610000000000000000026400000000000E04A40",
),
27650.80452994915,
),
(
Coordinate.from_hex(
id=13892,
wkb_hex="0101000020E610000000000000008027400000000000E04A40",
),
28324.62399357631,
),
(
Coordinate.from_hex(
id=14078,
wkb_hex="0101000020E610000000000000000026400000000000C04A40",
),
28429.952194089583,
),
(
Coordinate.from_hex(
id=14081,
wkb_hex="0101000020E610000000000000008027400000000000C04A40",
),
29089.579082292785,
),
]
long, lat = 11.3692, 53.6315
closest = weighted_interpolation_coordinates((long, lat), nearest_coordinates)
closest_ids = [c[0].id for c in closest]
assert closest_ids == [13890, 13891, 14079, 14080]
assert math.isclose(sum([c[1] for c in closest]), 1)