hcarter333 / datasette-haversine-point-path

Datasette plugin that adds a custom SQL function for shortest haversine distances between a point and a path on a sphere
Apache License 2.0
0 stars 0 forks source link

Implement case where perpendicular distance isn't on short side of great circle #7

Closed hcarter333 closed 9 months ago

hcarter333 commented 9 months ago

While the distance returned will always be the perpendicular distance from the location of the ionosonde to the great circle containing the path betwen the two QSO ham radio stations, it might be the distance from the ionosonde to the longer portion of the great circle (i.e. the portion of the great circle that the radio waves did not propogate along. For example, the Alaska ionosonde (Gakona) shown below

image

taken from the maximum usable frequency (MUF) map will not have a perpendicular path to the QSO path used in the original example from San Fancisco to the Netherlands shown below image

Instead, the shorter distance to the path will be to the endpoint in San Francisco.

Modify the code to test which path is shorter, and return the shortest path distance.

hcarter333 commented 9 months ago

Unit testing revealed my assumption about Gakona was incorrect. There is a perpendicular path to the QSO. Let's try Pt. Arguello instead.

image

hcarter333 commented 9 months ago

That worked, even though I didn't think it did at first

FAILED tests/test_haversine_point_path.py::test_hav_not_perp[float-mi-1099.44] - assert 1099.44 == 194.47717229164974 ± 1.9e+00 image

hcarter333 commented 9 months ago

The trick now is to implement the distance test.

and there we go: FAILED tests/test_haversine_point_path.py::test_hav_not_perp[float-mi-1099.44] - assert 1099.44 == 228.7148841456357 ± 2.3e+00

and

image

The test case is intentionally failing to get the ouput of the calculated distance shown in the error message above.

hcarter333 commented 9 months ago

Just to be completely sure, let's also test an ionosonde location past the rx side of the QSO, JULIUSRUH.

But that won't work because image

so.....

How about Sopron image

Yup! FAILED tests/test_haversine_point_path.py::test_hav_not_perp[float-mi-228.7148841] - assert 228.7148841 == 591.9238265165612 ± 5.9e+00