hcarter333 / datasette-haversine-point-path Goto Github PK
View Code? Open in Web Editor NEWDatasette plugin that adds a custom SQL function for shortest haversine distances between a point and a path on a sphere
License: Apache License 2.0
Datasette plugin that adds a custom SQL function for shortest haversine distances between a point and a path on a sphere
License: Apache License 2.0
Getting the following from pytest:
Traceback (most recent call last):
File "/home/hcarter333/datasette-haversine-point-path/datasette_haversine_point_path/__init__.py", line 36, in haversine_point_path_sql
tx_x = cartesian_x(lat1,lon1)
File "/home/hcarter333/datasette-haversine-point-path/datasette_haversine_point_path/__init__.py", line 7, in cartesian_x
return (math.cos(f*deg2rad)*math.cos(l*deg2rad))
NameError: name 'math' is not defined
I'll add the path and I'll also add the dependeny to pyproject.toml.
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
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
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.
As soon as I ran the unit tests on this package, they popped up an error
and while I was there looking at the issue,
https://github.com/hcarter333/datasette-haversine-point-path/issues
(there are two few argoments defined in the seoncd argument of the create_function method), I notoiced that I hadn't renamed the methods to haversine_point_path.
All this debug, relatively speaking for free!
In case the database hands in floats coded as strings, they need to be cast back to floats. This same issue occurred in datasette-haversine which is where the test case for this package originated. Here's the error message
Traceback (most recent call last):
File "/home/hcarter333/datasette-haversine-point-path/datasette_haversine_point_path/__init__.py", line 39, in haversine_point_path_sql
tx_x = cartesian_x(lat1,lon1)
File "/home/hcarter333/datasette-haversine-point-path/datasette_haversine_point_path/__init__.py", line 10, in cartesian_x
return (math.cos(f*deg2rad)*math.cos(l*deg2rad))
TypeError: can't multiply sequence by non-int of type 'float'
the fix will be to convert the inputs into floats.
The comparisions did not pass to one part in a million:
FAILED tests/test_haversine_point_path.py::test_haversine[float-ft-5805047] - assert 5805047 == 5796584.922005589 ± 5.8e+00
FAILED tests/test_haversine_point_path.py::test_haversine[float-m-1769378.36] - assert 1769378.36 == 1766799.08422737 ± 1.8e+00
FAILED tests/test_haversine_point_path.py::test_haversine[float-in-69660567] - assert 69660567 == 69559019.06407061 ± 7.0e+01
This is due entirely to the fact that I measured the distance by hand using google maps. I'm goin to turn the rel value down to 1e-3.
Add the units
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.