-
Notifications
You must be signed in to change notification settings - Fork 0
/
starfixdata_sea_3.py
54 lines (44 loc) · 2.03 KB
/
starfixdata_sea_3.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
''' Simple sample representing a trip at sea with supporting celestial navigation
© August Linnman, 2024, email: [email protected]
MIT License (see LICENSE file)
'''
from time import time
from starfix import LatLon, get_representation,\
get_great_circle_route, Circle, CircleCollection, get_intersections,\
get_line_of_sight, nm_to_km, km_to_nm
def main ():
''' Main body of script '''
starttime = time ()
# We are sailing from point s1
# We have a good estimate of an initial position. (A previous fix)
s1 = LatLon (57.662, 18.263)
# We start out at a course of 350 degrees
c_course = 350
course_gc = get_great_circle_route (s1, c_course)
# This is a position of a lighthouse
light_house = LatLon (58.739, 17.865)
# This is the elevation of the light source (m)
light_house_elevation = 44.5
# This is the maximum reach in nm
light_house_max_visibility_nm = 22
light_house_max_visibility_m = nm_to_km (light_house_max_visibility_nm) * 1000
# This is the elevation of the observer (in the ship)
observer_elevation = 3
# Calculate the max line of sight
line_of_sight = get_line_of_sight (light_house_elevation, observer_elevation)
# The actual line of sight is the minimum of max reach and line of sight
actual_line_of_sight = min (line_of_sight, light_house_max_visibility_m)
actual_line_of_sight_nm = km_to_nm (actual_line_of_sight/1000)
light_house_circle = Circle (light_house, actual_line_of_sight_nm/60)
# Get the intersections
intersections = get_intersections (course_gc, light_house_circle)
endtime = time ()
assert isinstance (intersections, tuple)
print (get_representation(intersections[0],1))
# Check the circles
c_c = CircleCollection ([course_gc, light_house_circle, Circle(s1, 1/60)])
print ("MD = " + c_c.get_map_developers_string())
taken_ms = round((endtime-starttime)*1000,2)
print ("Time taken = " +str(taken_ms)+" ms")
if __name__ == '__main__':
main()