forked from joshuaeckroth/cse3521-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
goodale.py
154 lines (144 loc) · 6.55 KB
/
goodale.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
distances = {}
distances.setdefault("High & Goodale", {})
distances.setdefault("Goodale parking lot", {})
distances["High & Goodale"]["Goodale parking lot"] = 0.22
distances["Goodale parking lot"]["High & Goodale"] = 0.22
distances.setdefault("High & 5th", {})
distances.setdefault("High & Goodale", {})
distances["High & 5th"]["High & Goodale"] = 0.93
distances["High & Goodale"]["High & 5th"] = 0.93
distances.setdefault("I-71 5th offramp", {})
distances.setdefault("High & 5th", {})
distances["I-71 5th offramp"]["High & 5th"] = 1.07
distances["High & 5th"]["I-71 5th offramp"] = 1.07
distances.setdefault("I-71 11th offramp", {})
distances.setdefault("I-71 5th offramp", {})
distances["I-71 11th offramp"]["I-71 5th offramp"] = 0.52
distances["I-71 5th offramp"]["I-71 11th offramp"] = 0.52
distances.setdefault("I-71 17th offramp", {})
distances.setdefault("I-71 11th offramp", {})
distances["I-71 17th offramp"]["I-71 11th offramp"] = 0.47
distances["I-71 11th offramp"]["I-71 17th offramp"] = 0.47
distances.setdefault("US-23 & 17th", {})
distances.setdefault("I-71 17th offramp", {})
distances["US-23 & 17th"]["I-71 17th offramp"] = 0.75
distances["I-71 17th offramp"]["US-23 & 17th"] = 0.75
distances.setdefault("US-23 & 15th", {})
distances.setdefault("US-23 & 17th", {})
distances["US-23 & 15th"]["US-23 & 17th"] = 0.12
distances["US-23 & 17th"]["US-23 & 15th"] = 0.12
distances.setdefault("High & 15th", {})
distances.setdefault("US-23 & 15th", {})
distances["High & 15th"]["US-23 & 15th"] = 0.49
distances["US-23 & 15th"]["High & 15th"] = 0.49
distances.setdefault("High & Woodruff", {})
distances.setdefault("High & 15th", {})
distances["High & Woodruff"]["High & 15th"] = 0.26
distances["High & 15th"]["High & Woodruff"] = 0.26
distances.setdefault("Woodruff & Tuttle", {})
distances.setdefault("High & Woodruff", {})
distances["Woodruff & Tuttle"]["High & Woodruff"] = 0.46
distances["High & Woodruff"]["Woodruff & Tuttle"] = 0.46
distances.setdefault("Lane & Tuttle", {})
distances.setdefault("Woodruff & Tuttle", {})
distances["Lane & Tuttle"]["Woodruff & Tuttle"] = 0.17
distances["Woodruff & Tuttle"]["Lane & Tuttle"] = 0.17
distances.setdefault("SR-315 & Lane", {})
distances.setdefault("Lane & Tuttle", {})
distances["SR-315 & Lane"]["Lane & Tuttle"] = 0.74
distances["Lane & Tuttle"]["SR-315 & Lane"] = 0.74
distances.setdefault("SR-315 I-670 offramp", {})
distances.setdefault("SR-315 & Lane", {})
distances["SR-315 I-670 offramp"]["SR-315 & Lane"] = 2.05
distances["SR-315 & Lane"]["SR-315 I-670 offramp"] = 2.05
distances.setdefault("Park & Vine", {})
distances.setdefault("SR-315 I-670 offramp", {})
distances["Park & Vine"]["SR-315 I-670 offramp"] = 0.99
distances["SR-315 I-670 offramp"]["Park & Vine"] = 0.99
distances.setdefault("Park & Goodale", {})
distances.setdefault("Park & Vine", {})
distances["Park & Goodale"]["Park & Vine"] = 0.15
distances["Park & Vine"]["Park & Goodale"] = 0.15
distances.setdefault("Goodale parking lot", {})
distances.setdefault("Park & Goodale", {})
distances["Goodale parking lot"]["Park & Goodale"] = 0.13
distances["Park & Goodale"]["Goodale parking lot"] = 0.13
distances.setdefault("US-23 & Goodale", {})
distances.setdefault("US-23 & 15th", {})
distances["US-23 & Goodale"]["US-23 & 15th"] = 1.76
distances["US-23 & 15th"]["US-23 & Goodale"] = 1.76
distances.setdefault("SR-315 & King", {})
distances.setdefault("SR-315 & Lane", {})
distances["SR-315 & King"]["SR-315 & Lane"] = 1.10
distances["SR-315 & Lane"]["SR-315 & King"] = 1.10
distances.setdefault("High & King", {})
distances.setdefault("SR-315 & King", {})
distances["High & King"]["SR-315 & King"] = 1.02
distances["SR-315 & King"]["High & King"] = 1.02
distances.setdefault("High & 11th", {})
distances.setdefault("I-71 11th offramp", {})
distances["High & 11th"]["I-71 11th offramp"] = 1.15
distances["I-71 11th offramp"]["High & 11th"] = 1.15
distances.setdefault("US-23 & Goodale", {})
distances.setdefault("Goodale parking lot", {})
distances["US-23 & Goodale"]["Goodale parking lot"] = 0.41
distances["Goodale parking lot"]["US-23 & Goodale"] = 0.41
distances.setdefault("High & 15th", {})
distances.setdefault("High & 11th", {})
distances["High & 15th"]["High & 11th"] = 0.37
distances["High & 11th"]["High & 15th"] = 0.37
distances.setdefault("High & 11th", {})
distances.setdefault("High & King", {})
distances["High & 11th"]["High & King"] = 0.31
distances["High & King"]["High & 11th"] = 0.31
distances.setdefault("High & King", {})
distances.setdefault("High & 5th", {})
distances["High & King"]["High & 5th"] = 0.21
distances["High & 5th"]["High & King"] = 0.21
lonlat = {}
lonlat["High & Goodale"] = (-83.00286, 39.97384)
lonlat["High & 5th"] = (-83.00551, 39.98710)
lonlat["I-71 5th offramp"] = (-82.98526, 39.98631)
lonlat["I-71 11th offramp"] = (-82.98519, 39.99394)
lonlat["I-71 17th offramp"] = (-82.98443, 40.00072)
lonlat["US-23 & 17th"] = (-82.99865, 40.00133)
lonlat["US-23 & 15th"] = (-83.00118, 39.99973)
lonlat["High & 15th"] = (-83.00807, 40.00007)
lonlat["High & Woodruff"] = (-83.00888, 40.00409)
lonlat["Woodruff & Tuttle"] = (-83.01748, 40.00400)
lonlat["Lane & Tuttle"] = (-83.01683, 40.00631)
lonlat["SR-315 & Lane"] = (-83.03085, 40.00646)
lonlat["SR-315 I-670 offramp"] = (-83.02120, 39.97749)
lonlat["Park & Vine"] = (-83.00469, 39.97147)
lonlat["Park & Goodale"] = (-83.00453, 39.97362)
lonlat["Goodale parking lot"] = (-83.00649, 39.97372)
lonlat["US-23 & Goodale"] = (-82.99826, 39.97423)
lonlat["SR-315 & King"] = (-83.02511, 39.99084)
lonlat["High & King"] = (-83.00610, 39.99019)
lonlat["High & 11th"] = (-83.00712, 39.99528)
import math
# from: http://www.johndcook.com/python_longitude_latitude.html
def dist(state1, state2):
(long1, lat1) = lonlat[state1]
(long2, lat2) = lonlat[state2]
# Convert latitude and longitude to
# spherical coordinates in radians.
degrees_to_radians = math.pi/180.0
# phi = 90 - latitude
phi1 = (90.0 - lat1)*degrees_to_radians
phi2 = (90.0 - lat2)*degrees_to_radians
# theta = longitude
theta1 = long1*degrees_to_radians
theta2 = long2*degrees_to_radians
# Compute spherical distance from spherical coordinates.
# For two locations in spherical coordinates
# (1, theta, phi) and (1, theta, phi)
# cosine( arc length ) =
# sin phi sin phi' cos(theta-theta') + cos phi cos phi'
# distance = rho * arc length
cos = (math.sin(phi1)*math.sin(phi2)*math.cos(theta1 - theta2) +
math.cos(phi1)*math.cos(phi2))
arc = math.acos( cos )
# Remember to multiply arc by the radius of the earth
# in your favorite set of units to get length.
return (arc * 3960.0)