File size: 2,364 Bytes
3041467 6f2f547 3041467 814e9b0 5b77c7a 238719b 3041467 ef3d72e 6f2f547 3041467 814e9b0 238719b 3041467 ef3d72e 6f2f547 3041467 9d4db86 814e9b0 238719b 3041467 ef3d72e 3041467 |
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 |
import json
from src.io.coordinates_pixel_conversion import _get_latlng2pixel_projection, _get_point_latlng_to_pixel_coordinates, \
get_latlng_to_pixel_coordinates
from src.utilities.type_hints import LatLngDict
from tests import TEST_EVENTS_FOLDER
def test_get_latlng2pixel_projection():
name_fn = "get_latlng2pixel_projection"
with open(TEST_EVENTS_FOLDER / f"{name_fn}.json") as tst_json:
inputs_outputs = json.load(tst_json)
for k, input_output in inputs_outputs.items():
print(f"k:{k}")
current_input = input_output["input"]
latlng_input = LatLngDict.model_validate(current_input["latlng"])
output = _get_latlng2pixel_projection(latlng_input)
assert output == input_output["output"]
def test_get_point_latlng_to_pixel_coordinates():
name_fn = "get_point_latlng_to_pixel_coordinates"
with open(TEST_EVENTS_FOLDER / f"{name_fn}.json") as tst_json:
inputs_outputs = json.load(tst_json)
for k, input_output in inputs_outputs.items():
print(f"k:{k}")
current_input = input_output["input"]
latlng_input = LatLngDict.model_validate(current_input["latlng"])
output = _get_point_latlng_to_pixel_coordinates(latlng=latlng_input, zoom=current_input["zoom"])
assert output == input_output["output"]
def test_get_latlng_to_pixel_coordinates():
name_fn = "get_latlng_to_pixel_coordinates"
with open(TEST_EVENTS_FOLDER / f"{name_fn}.json") as tst_json:
inputs_outputs = json.load(tst_json)
for k, input_output in inputs_outputs.items():
print(f"k:{k}")
current_input = input_output["input"]
zoom = current_input["zoom"]
latlng_origin_ne = LatLngDict.model_validate(current_input["latlng_origin_ne"])
latlng_origin_sw = LatLngDict.model_validate(current_input["latlng_origin_sw"])
latlng_current_point = LatLngDict.model_validate(current_input["latlng_current_point"])
output = get_latlng_to_pixel_coordinates(
latlng_origin_ne=latlng_origin_ne,
latlng_origin_sw=latlng_origin_sw,
latlng_current_point=latlng_current_point,
zoom=zoom,
k=k
)
assert output == input_output["output"]
|