test_geodesic.py
Go to the documentation of this file.
1 import unittest
2 
3 from geographiclib.geodesic import Geodesic
4 from geographiclib.geomath import Math
5 
6 class GeodesicTest(unittest.TestCase):
7 
8  testcases = [
9  [35.60777, -139.44815, 111.098748429560326,
10  -11.17491, -69.95921, 129.289270889708762,
11  8935244.5604818305, 80.50729714281974, 6273170.2055303837,
12  0.16606318447386067, 0.16479116945612937, 12841384694976.432],
13  [55.52454, 106.05087, 22.020059880982801,
14  77.03196, 197.18234, 109.112041110671519,
15  4105086.1713924406, 36.892740690445894, 3828869.3344387607,
16  0.80076349608092607, 0.80101006984201008, 61674961290615.615],
17  [-21.97856, 142.59065, -32.44456876433189,
18  41.84138, 98.56635, -41.84359951440466,
19  8394328.894657671, 75.62930491011522, 6161154.5773110616,
20  0.24816339233950381, 0.24930251203627892, -6637997720646.717],
21  [-66.99028, 112.2363, 173.73491240878403,
22  -12.70631, 285.90344, 2.512956620913668,
23  11150344.2312080241, 100.278634181155759, 6289939.5670446687,
24  -0.17199490274700385, -0.17722569526345708, -121287239862139.744],
25  [-17.42761, 173.34268, -159.033557661192928,
26  -15.84784, 5.93557, -20.787484651536988,
27  16076603.1631180673, 144.640108810286253, 3732902.1583877189,
28  -0.81273638700070476, -0.81299800519154474, 97825992354058.708],
29  [32.84994, 48.28919, 150.492927788121982,
30  -56.28556, 202.29132, 48.113449399816759,
31  16727068.9438164461, 150.565799985466607, 3147838.1910180939,
32  -0.87334918086923126, -0.86505036767110637, -72445258525585.010],
33  [6.96833, 52.74123, 92.581585386317712,
34  -7.39675, 206.17291, 90.721692165923907,
35  17102477.2496958388, 154.147366239113561, 2772035.6169917581,
36  -0.89991282520302447, -0.89986892177110739, -1311796973197.995],
37  [-50.56724, -16.30485, -105.439679907590164,
38  -33.56571, -94.97412, -47.348547835650331,
39  6455670.5118668696, 58.083719495371259, 5409150.7979815838,
40  0.53053508035997263, 0.52988722644436602, 41071447902810.047],
41  [-58.93002, -8.90775, 140.965397902500679,
42  -8.91104, 133.13503, 19.255429433416599,
43  11756066.0219864627, 105.755691241406877, 6151101.2270708536,
44  -0.26548622269867183, -0.27068483874510741, -86143460552774.735],
45  [-68.82867, -74.28391, 93.774347763114881,
46  -50.63005, -8.36685, 34.65564085411343,
47  3956936.926063544, 35.572254987389284, 3708890.9544062657,
48  0.81443963736383502, 0.81420859815358342, -41845309450093.787],
49  [-10.62672, -32.0898, -86.426713286747751,
50  5.883, -134.31681, -80.473780971034875,
51  11470869.3864563009, 103.387395634504061, 6184411.6622659713,
52  -0.23138683500430237, -0.23155097622286792, 4198803992123.548],
53  [-21.76221, 166.90563, 29.319421206936428,
54  48.72884, 213.97627, 43.508671946410168,
55  9098627.3986554915, 81.963476716121964, 6299240.9166992283,
56  0.13965943368590333, 0.14152969707656796, 10024709850277.476],
57  [-19.79938, -174.47484, 71.167275780171533,
58  -11.99349, -154.35109, 65.589099775199228,
59  2319004.8601169389, 20.896611684802389, 2267960.8703918325,
60  0.93427001867125849, 0.93424887135032789, -3935477535005.785],
61  [-11.95887, -116.94513, 92.712619830452549,
62  4.57352, 7.16501, 78.64960934409585,
63  13834722.5801401374, 124.688684161089762, 5228093.177931598,
64  -0.56879356755666463, -0.56918731952397221, -9919582785894.853],
65  [-87.85331, 85.66836, -65.120313040242748,
66  66.48646, 16.09921, -4.888658719272296,
67  17286615.3147144645, 155.58592449699137, 2635887.4729110181,
68  -0.90697975771398578, -0.91095608883042767, 42667211366919.534],
69  [1.74708, 128.32011, -101.584843631173858,
70  -11.16617, 11.87109, -86.325793296437476,
71  12942901.1241347408, 116.650512484301857, 5682744.8413270572,
72  -0.44857868222697644, -0.44824490340007729, 10763055294345.653],
73  [-25.72959, -144.90758, -153.647468693117198,
74  -57.70581, -269.17879, -48.343983158876487,
75  9413446.7452453107, 84.664533838404295, 6356176.6898881281,
76  0.09492245755254703, 0.09737058264766572, 74515122850712.444],
77  [-41.22777, 122.32875, 14.285113402275739,
78  -7.57291, 130.37946, 10.805303085187369,
79  3812686.035106021, 34.34330804743883, 3588703.8812128856,
80  0.82605222593217889, 0.82572158200920196, -2456961531057.857],
81  [11.01307, 138.25278, 79.43682622782374,
82  6.62726, 247.05981, 103.708090215522657,
83  11911190.819018408, 107.341669954114577, 6070904.722786735,
84  -0.29767608923657404, -0.29785143390252321, 17121631423099.696],
85  [-29.47124, 95.14681, -163.779130441688382,
86  -27.46601, -69.15955, -15.909335945554969,
87  13487015.8381145492, 121.294026715742277, 5481428.9945736388,
88  -0.51527225545373252, -0.51556587964721788, 104679964020340.318]]
89 
90  def test_inverse(self):
91  for l in GeodesicTest.testcases:
92  (lat1, lon1, azi1, lat2, lon2, azi2,
93  s12, a12, m12, M12, M21, S12) = l
94  inv = Geodesic.WGS84.Inverse(lat1, lon1, lat2, lon2,
95  Geodesic.ALL | Geodesic.LONG_UNROLL)
96  self.assertAlmostEqual(lon2, inv["lon2"], delta = 1e-13)
97  self.assertAlmostEqual(azi1, inv["azi1"], delta = 1e-13)
98  self.assertAlmostEqual(azi2, inv["azi2"], delta = 1e-13)
99  self.assertAlmostEqual(s12, inv["s12"], delta = 1e-8)
100  self.assertAlmostEqual(a12, inv["a12"], delta = 1e-13)
101  self.assertAlmostEqual(m12, inv["m12"], delta = 1e-8)
102  self.assertAlmostEqual(M12, inv["M12"], delta = 1e-15)
103  self.assertAlmostEqual(M21, inv["M21"], delta = 1e-15)
104  self.assertAlmostEqual(S12, inv["S12"], delta = 0.1)
105 
106  def test_direct(self):
107  for l in GeodesicTest.testcases:
108  (lat1, lon1, azi1, lat2, lon2, azi2,
109  s12, a12, m12, M12, M21, S12) = l
110  dir = Geodesic.WGS84.Direct(lat1, lon1, azi1, s12,
111  Geodesic.ALL | Geodesic.LONG_UNROLL)
112  self.assertAlmostEqual(lat2, dir["lat2"], delta = 1e-13)
113  self.assertAlmostEqual(lon2, dir["lon2"], delta = 1e-13)
114  self.assertAlmostEqual(azi2, dir["azi2"], delta = 1e-13)
115  self.assertAlmostEqual(a12, dir["a12"], delta = 1e-13)
116  self.assertAlmostEqual(m12, dir["m12"], delta = 1e-8)
117  self.assertAlmostEqual(M12, dir["M12"], delta = 1e-15)
118  self.assertAlmostEqual(M21, dir["M21"], delta = 1e-15)
119  self.assertAlmostEqual(S12, dir["S12"], delta = 0.1)
120 
121  def test_arcdirect(self):
122  for l in GeodesicTest.testcases:
123  (lat1, lon1, azi1, lat2, lon2, azi2,
124  s12, a12, m12, M12, M21, S12) = l
125  dir = Geodesic.WGS84.ArcDirect(lat1, lon1, azi1, a12,
126  Geodesic.ALL | Geodesic.LONG_UNROLL)
127  self.assertAlmostEqual(lat2, dir["lat2"], delta = 1e-13)
128  self.assertAlmostEqual(lon2, dir["lon2"], delta = 1e-13)
129  self.assertAlmostEqual(azi2, dir["azi2"], delta = 1e-13)
130  self.assertAlmostEqual(s12, dir["s12"], delta = 1e-8)
131  self.assertAlmostEqual(m12, dir["m12"], delta = 1e-8)
132  self.assertAlmostEqual(M12, dir["M12"], delta = 1e-15)
133  self.assertAlmostEqual(M21, dir["M21"], delta = 1e-15)
134  self.assertAlmostEqual(S12, dir["S12"], delta = 0.1)
135 
136 class GeodSolveTest(unittest.TestCase):
137 
138  def test_GeodSolve0(self):
139  inv = Geodesic.WGS84.Inverse(40.6, -73.8, 49.01666667, 2.55)
140  self.assertAlmostEqual(inv["azi1"], 53.47022, delta = 0.5e-5)
141  self.assertAlmostEqual(inv["azi2"], 111.59367, delta = 0.5e-5)
142  self.assertAlmostEqual(inv["s12"], 5853226, delta = 0.5)
143 
144  def test_GeodSolve1(self):
145  dir = Geodesic.WGS84.Direct(40.63972222, -73.77888889, 53.5, 5850e3)
146  self.assertAlmostEqual(dir["lat2"], 49.01467, delta = 0.5e-5)
147  self.assertAlmostEqual(dir["lon2"], 2.56106, delta = 0.5e-5)
148  self.assertAlmostEqual(dir["azi2"], 111.62947, delta = 0.5e-5)
149 
150  def test_GeodSolve2(self):
151  # Check fix for antipodal prolate bug found 2010-09-04
152  geod = Geodesic(6.4e6, -1/150.0)
153  inv = geod.Inverse(0.07476, 0, -0.07476, 180)
154  self.assertAlmostEqual(inv["azi1"], 90.00078, delta = 0.5e-5)
155  self.assertAlmostEqual(inv["azi2"], 90.00078, delta = 0.5e-5)
156  self.assertAlmostEqual(inv["s12"], 20106193, delta = 0.5)
157  inv = geod.Inverse(0.1, 0, -0.1, 180)
158  self.assertAlmostEqual(inv["azi1"], 90.00105, delta = 0.5e-5)
159  self.assertAlmostEqual(inv["azi2"], 90.00105, delta = 0.5e-5)
160  self.assertAlmostEqual(inv["s12"], 20106193, delta = 0.5)
161 
162  def test_GeodSolve4(self):
163  # Check fix for short line bug found 2010-05-21
164  inv = Geodesic.WGS84.Inverse(36.493349428792, 0,
165  36.49334942879201, 0.0000008)
166  self.assertAlmostEqual(inv["s12"], 0.072, delta = 0.5e-3)
167 
168  def test_GeodSolve5(self):
169  # Check fix for point2=pole bug found 2010-05-03
170  dir = Geodesic.WGS84.Direct(0.01777745589997, 30, 0, 10e6)
171  self.assertAlmostEqual(dir["lat2"], 90, delta = 0.5e-5)
172  if dir["lon2"] < 0:
173  self.assertAlmostEqual(dir["lon2"], -150, delta = 0.5e-5)
174  self.assertAlmostEqual(abs(dir["azi2"]), 180, delta = 0.5e-5)
175  else:
176  self.assertAlmostEqual(dir["lon2"], 30, delta = 0.5e-5)
177  self.assertAlmostEqual(dir["azi2"], 0, delta = 0.5e-5)
178 
179  def test_GeodSolve6(self):
180  # Check fix for volatile sbet12a bug found 2011-06-25 (gcc 4.4.4
181  # x86 -O3). Found again on 2012-03-27 with tdm-mingw32 (g++ 4.6.1).
182  inv = Geodesic.WGS84.Inverse(88.202499451857, 0,
183  -88.202499451857, 179.981022032992859592)
184  self.assertAlmostEqual(inv["s12"], 20003898.214, delta = 0.5e-3)
185  inv = Geodesic.WGS84.Inverse(89.262080389218, 0,
186  -89.262080389218, 179.992207982775375662)
187  self.assertAlmostEqual(inv["s12"], 20003925.854, delta = 0.5e-3)
188  inv = Geodesic.WGS84.Inverse(89.333123580033, 0,
189  -89.333123580032997687,
190  179.99295812360148422)
191  self.assertAlmostEqual(inv["s12"], 20003926.881, delta = 0.5e-3)
192 
193  def test_GeodSolve9(self):
194  # Check fix for volatile x bug found 2011-06-25 (gcc 4.4.4 x86 -O3)
195  inv = Geodesic.WGS84.Inverse(56.320923501171, 0,
196  -56.320923501171, 179.664747671772880215)
197  self.assertAlmostEqual(inv["s12"], 19993558.287, delta = 0.5e-3)
198 
199  def test_GeodSolve10(self):
200  # Check fix for adjust tol1_ bug found 2011-06-25 (Visual Studio
201  # 10 rel + debug)
202  inv = Geodesic.WGS84.Inverse(52.784459512564, 0,
203  -52.784459512563990912,
204  179.634407464943777557)
205  self.assertAlmostEqual(inv["s12"], 19991596.095, delta = 0.5e-3)
206 
207  def test_GeodSolve11(self):
208  # Check fix for bet2 = -bet1 bug found 2011-06-25 (Visual Studio
209  # 10 rel + debug)
210  inv = Geodesic.WGS84.Inverse(48.522876735459, 0,
211  -48.52287673545898293,
212  179.599720456223079643)
213  self.assertAlmostEqual(inv["s12"], 19989144.774, delta = 0.5e-3)
214 
215  def test_GeodSolve12(self):
216  # Check fix for inverse geodesics on extreme prolate/oblate
217  # ellipsoids Reported 2012-08-29 Stefan Guenther
218  # <stefan.gunther@embl.de>; fixed 2012-10-07
219  geod = Geodesic(89.8, -1.83)
220  inv = geod.Inverse(0, 0, -10, 160)
221  self.assertAlmostEqual(inv["azi1"], 120.27, delta = 1e-2)
222  self.assertAlmostEqual(inv["azi2"], 105.15, delta = 1e-2)
223  self.assertAlmostEqual(inv["s12"], 266.7, delta = 1e-1)
224 
225  def test_GeodSolve14(self):
226  # Check fix for inverse ignoring lon12 = nan
227  inv = Geodesic.WGS84.Inverse(0, 0, 1, Math.nan)
228  self.assertTrue(Math.isnan(inv["azi1"]))
229  self.assertTrue(Math.isnan(inv["azi2"]))
230  self.assertTrue(Math.isnan(inv["s12"]))
231 
232  def test_GeodSolve15(self):
233  # Initial implementation of Math::eatanhe was wrong for e^2 < 0. This
234  # checks that this is fixed.
235  geod = Geodesic(6.4e6, -1/150.0)
236  dir = geod.Direct(1, 2, 3, 4, Geodesic.AREA)
237  self.assertAlmostEqual(dir["S12"], 23700, delta = 0.5)
238 
239  def test_GeodSolve17(self):
240  # Check fix for LONG_UNROLL bug found on 2015-05-07
241  dir = Geodesic.WGS84.Direct(40, -75, -10, 2e7,
242  Geodesic.STANDARD | Geodesic.LONG_UNROLL)
243  self.assertAlmostEqual(dir["lat2"], -39, delta = 1)
244  self.assertAlmostEqual(dir["lon2"], -254, delta = 1)
245  self.assertAlmostEqual(dir["azi2"], -170, delta = 1)
246  line = Geodesic.WGS84.Line(40, -75, -10)
247  dir = line.Position(2e7, Geodesic.STANDARD | Geodesic.LONG_UNROLL)
248  self.assertAlmostEqual(dir["lat2"], -39, delta = 1)
249  self.assertAlmostEqual(dir["lon2"], -254, delta = 1)
250  self.assertAlmostEqual(dir["azi2"], -170, delta = 1)
251  dir = Geodesic.WGS84.Direct(40, -75, -10, 2e7)
252  self.assertAlmostEqual(dir["lat2"], -39, delta = 1)
253  self.assertAlmostEqual(dir["lon2"], 105, delta = 1)
254  self.assertAlmostEqual(dir["azi2"], -170, delta = 1)
255  dir = line.Position(2e7)
256  self.assertAlmostEqual(dir["lat2"], -39, delta = 1)
257  self.assertAlmostEqual(dir["lon2"], 105, delta = 1)
258  self.assertAlmostEqual(dir["azi2"], -170, delta = 1)
259 
260  def test_GeodSolve26(self):
261  # Check 0/0 problem with area calculation on sphere 2015-09-08
262  geod = Geodesic(6.4e6, 0)
263  inv = geod.Inverse(1, 2, 3, 4, Geodesic.AREA)
264  self.assertAlmostEqual(inv["S12"], 49911046115.0, delta = 0.5)
265 
266  def test_GeodSolve28(self):
267  # Check for bad placement of assignment of r.a12 with |f| > 0.01 (bug in
268  # Java implementation fixed on 2015-05-19).
269  geod = Geodesic(6.4e6, 0.1)
270  dir = geod.Direct(1, 2, 10, 5e6)
271  self.assertAlmostEqual(dir["a12"], 48.55570690, delta = 0.5e-8)
272 
273  def test_GeodSolve29(self):
274  # Check longitude unrolling with inverse calculation 2015-09-16
275  dir = Geodesic.WGS84.Inverse(0, 539, 0, 181)
276  self.assertAlmostEqual(dir["lon1"], 179, delta = 1e-10)
277  self.assertAlmostEqual(dir["lon2"], -179, delta = 1e-10)
278  self.assertAlmostEqual(dir["s12"], 222639, delta = 0.5)
279  dir = Geodesic.WGS84.Inverse(0, 539, 0, 181,
280  Geodesic.STANDARD | Geodesic.LONG_UNROLL)
281  self.assertAlmostEqual(dir["lon1"], 539, delta = 1e-10)
282  self.assertAlmostEqual(dir["lon2"], 541, delta = 1e-10)
283  self.assertAlmostEqual(dir["s12"], 222639, delta = 0.5)
284 
285  def test_GeodSolve33(self):
286  # Check max(-0.0,+0.0) issues 2015-08-22 (triggered by bugs in
287  # Octave -- sind(-0.0) = +0.0 -- and in some version of Visual
288  # Studio -- fmod(-0.0, 360.0) = +0.0.
289  inv = Geodesic.WGS84.Inverse(0, 0, 0, 179)
290  self.assertAlmostEqual(inv["azi1"], 90.00000, delta = 0.5e-5)
291  self.assertAlmostEqual(inv["azi2"], 90.00000, delta = 0.5e-5)
292  self.assertAlmostEqual(inv["s12"], 19926189, delta = 0.5)
293  inv = Geodesic.WGS84.Inverse(0, 0, 0, 179.5)
294  self.assertAlmostEqual(inv["azi1"], 55.96650, delta = 0.5e-5)
295  self.assertAlmostEqual(inv["azi2"], 124.03350, delta = 0.5e-5)
296  self.assertAlmostEqual(inv["s12"], 19980862, delta = 0.5)
297  inv = Geodesic.WGS84.Inverse(0, 0, 0, 180)
298  self.assertAlmostEqual(inv["azi1"], 0.00000, delta = 0.5e-5)
299  self.assertAlmostEqual(abs(inv["azi2"]), 180.00000, delta = 0.5e-5)
300  self.assertAlmostEqual(inv["s12"], 20003931, delta = 0.5)
301  inv = Geodesic.WGS84.Inverse(0, 0, 1, 180)
302  self.assertAlmostEqual(inv["azi1"], 0.00000, delta = 0.5e-5)
303  self.assertAlmostEqual(abs(inv["azi2"]), 180.00000, delta = 0.5e-5)
304  self.assertAlmostEqual(inv["s12"], 19893357, delta = 0.5)
305  geod = Geodesic(6.4e6, 0)
306  inv = geod.Inverse(0, 0, 0, 179)
307  self.assertAlmostEqual(inv["azi1"], 90.00000, delta = 0.5e-5)
308  self.assertAlmostEqual(inv["azi2"], 90.00000, delta = 0.5e-5)
309  self.assertAlmostEqual(inv["s12"], 19994492, delta = 0.5)
310  inv = geod.Inverse(0, 0, 0, 180)
311  self.assertAlmostEqual(inv["azi1"], 0.00000, delta = 0.5e-5)
312  self.assertAlmostEqual(abs(inv["azi2"]), 180.00000, delta = 0.5e-5)
313  self.assertAlmostEqual(inv["s12"], 20106193, delta = 0.5)
314  inv = geod.Inverse(0, 0, 1, 180)
315  self.assertAlmostEqual(inv["azi1"], 0.00000, delta = 0.5e-5)
316  self.assertAlmostEqual(abs(inv["azi2"]), 180.00000, delta = 0.5e-5)
317  self.assertAlmostEqual(inv["s12"], 19994492, delta = 0.5)
318  geod = Geodesic(6.4e6, -1/300.0)
319  inv = geod.Inverse(0, 0, 0, 179)
320  self.assertAlmostEqual(inv["azi1"], 90.00000, delta = 0.5e-5)
321  self.assertAlmostEqual(inv["azi2"], 90.00000, delta = 0.5e-5)
322  self.assertAlmostEqual(inv["s12"], 19994492, delta = 0.5)
323  inv = geod.Inverse(0, 0, 0, 180)
324  self.assertAlmostEqual(inv["azi1"], 90.00000, delta = 0.5e-5)
325  self.assertAlmostEqual(inv["azi2"], 90.00000, delta = 0.5e-5)
326  self.assertAlmostEqual(inv["s12"], 20106193, delta = 0.5)
327  inv = geod.Inverse(0, 0, 0.5, 180)
328  self.assertAlmostEqual(inv["azi1"], 33.02493, delta = 0.5e-5)
329  self.assertAlmostEqual(inv["azi2"], 146.97364, delta = 0.5e-5)
330  self.assertAlmostEqual(inv["s12"], 20082617, delta = 0.5)
331  inv = geod.Inverse(0, 0, 1, 180)
332  self.assertAlmostEqual(inv["azi1"], 0.00000, delta = 0.5e-5)
333  self.assertAlmostEqual(abs(inv["azi2"]), 180.00000, delta = 0.5e-5)
334  self.assertAlmostEqual(inv["s12"], 20027270, delta = 0.5)
335 
336  def test_GeodSolve55(self):
337  # Check fix for nan + point on equator or pole not returning all nans in
338  # Geodesic::Inverse, found 2015-09-23.
339  inv = Geodesic.WGS84.Inverse(Math.nan, 0, 0, 90)
340  self.assertTrue(Math.isnan(inv["azi1"]))
341  self.assertTrue(Math.isnan(inv["azi2"]))
342  self.assertTrue(Math.isnan(inv["s12"]))
343  inv = Geodesic.WGS84.Inverse(Math.nan, 0, 90, 9)
344  self.assertTrue(Math.isnan(inv["azi1"]))
345  self.assertTrue(Math.isnan(inv["azi2"]))
346  self.assertTrue(Math.isnan(inv["s12"]))
347 
348  def test_GeodSolve59(self):
349  # Check for points close with longitudes close to 180 deg apart.
350  inv = Geodesic.WGS84.Inverse(5, 0.00000000000001, 10, 180)
351  self.assertAlmostEqual(inv["azi1"], 0.000000000000035, delta = 1.5e-14)
352  self.assertAlmostEqual(inv["azi2"], 179.99999999999996, delta = 1.5e-14)
353  self.assertAlmostEqual(inv["s12"], 18345191.174332713, delta = 4e-9)
354 
355  def test_GeodSolve61(self):
356  # Make sure small negative azimuths are west-going
357  dir = Geodesic.WGS84.Direct(45, 0, -0.000000000000000003, 1e7,
358  Geodesic.STANDARD | Geodesic.LONG_UNROLL)
359  self.assertAlmostEqual(dir["lat2"], 45.30632, delta = 0.5e-5)
360  self.assertAlmostEqual(dir["lon2"], -180, delta = 0.5e-5)
361  self.assertAlmostEqual(abs(dir["azi2"]), 180, delta = 0.5e-5)
362  line = Geodesic.WGS84.InverseLine(45, 0, 80, -0.000000000000000003)
363  dir = line.Position(1e7, Geodesic.STANDARD | Geodesic.LONG_UNROLL)
364  self.assertAlmostEqual(dir["lat2"], 45.30632, delta = 0.5e-5)
365  self.assertAlmostEqual(dir["lon2"], -180, delta = 0.5e-5)
366  self.assertAlmostEqual(abs(dir["azi2"]), 180, delta = 0.5e-5)
367 
368  def test_GeodSolve65(self):
369  # Check for bug in east-going check in GeodesicLine (needed to check for
370  # sign of 0) and sign error in area calculation due to a bogus override
371  # of the code for alp12. Found/fixed on 2015-12-19.
372  line = Geodesic.WGS84.InverseLine(30, -0.000000000000000001, -31, 180,
373  Geodesic.ALL)
374  dir = line.Position(1e7, Geodesic.ALL | Geodesic.LONG_UNROLL)
375  self.assertAlmostEqual(dir["lat1"], 30.00000 , delta = 0.5e-5)
376  self.assertAlmostEqual(dir["lon1"], -0.00000 , delta = 0.5e-5)
377  self.assertAlmostEqual(abs(dir["azi1"]), 180.00000, delta = 0.5e-5)
378  self.assertAlmostEqual(dir["lat2"], -60.23169 , delta = 0.5e-5)
379  self.assertAlmostEqual(dir["lon2"], -0.00000 , delta = 0.5e-5)
380  self.assertAlmostEqual(abs(dir["azi2"]), 180.00000, delta = 0.5e-5)
381  self.assertAlmostEqual(dir["s12"] , 10000000 , delta = 0.5)
382  self.assertAlmostEqual(dir["a12"] , 90.06544 , delta = 0.5e-5)
383  self.assertAlmostEqual(dir["m12"] , 6363636 , delta = 0.5)
384  self.assertAlmostEqual(dir["M12"] , -0.0012834, delta = 0.5e7)
385  self.assertAlmostEqual(dir["M21"] , 0.0013749 , delta = 0.5e-7)
386  self.assertAlmostEqual(dir["S12"] , 0 , delta = 0.5)
387  dir = line.Position(2e7, Geodesic.ALL | Geodesic.LONG_UNROLL)
388  self.assertAlmostEqual(dir["lat1"], 30.00000 , delta = 0.5e-5)
389  self.assertAlmostEqual(dir["lon1"], -0.00000 , delta = 0.5e-5)
390  self.assertAlmostEqual(abs(dir["azi1"]), 180.00000, delta = 0.5e-5)
391  self.assertAlmostEqual(dir["lat2"], -30.03547 , delta = 0.5e-5)
392  self.assertAlmostEqual(dir["lon2"], -180.00000, delta = 0.5e-5)
393  self.assertAlmostEqual(dir["azi2"], -0.00000 , delta = 0.5e-5)
394  self.assertAlmostEqual(dir["s12"] , 20000000 , delta = 0.5)
395  self.assertAlmostEqual(dir["a12"] , 179.96459 , delta = 0.5e-5)
396  self.assertAlmostEqual(dir["m12"] , 54342 , delta = 0.5)
397  self.assertAlmostEqual(dir["M12"] , -1.0045592, delta = 0.5e7)
398  self.assertAlmostEqual(dir["M21"] , -0.9954339, delta = 0.5e-7)
399  self.assertAlmostEqual(dir["S12"] , 127516405431022.0, delta = 0.5)
400 
401  def test_GeodSolve66(self):
402  # Check for InverseLine if line is slightly west of S and that s13 is
403  # correctly set.
404  line = Geodesic.WGS84.InverseLine(-5, -0.000000000000002, -10, 180)
405  dir = line.Position(2e7, Geodesic.STANDARD | Geodesic.LONG_UNROLL)
406  self.assertAlmostEqual(dir["lat2"], 4.96445 , delta = 0.5e-5)
407  self.assertAlmostEqual(dir["lon2"], -180.00000, delta = 0.5e-5)
408  self.assertAlmostEqual(dir["azi2"], -0.00000 , delta = 0.5e-5)
409  dir = line.Position(0.5 * line.s13,
410  Geodesic.STANDARD | Geodesic.LONG_UNROLL)
411  self.assertAlmostEqual(dir["lat2"], -87.52461 , delta = 0.5e-5)
412  self.assertAlmostEqual(dir["lon2"], -0.00000 , delta = 0.5e-5)
413  self.assertAlmostEqual(dir["azi2"], -180.00000, delta = 0.5e-5)
414 
415  def test_GeodSolve71(self):
416  # Check that DirectLine sets s13.
417  line = Geodesic.WGS84.DirectLine(1, 2, 45, 1e7)
418  dir = line.Position(0.5 * line.s13,
419  Geodesic.STANDARD | Geodesic.LONG_UNROLL)
420  self.assertAlmostEqual(dir["lat2"], 30.92625, delta = 0.5e-5)
421  self.assertAlmostEqual(dir["lon2"], 37.54640, delta = 0.5e-5)
422  self.assertAlmostEqual(dir["azi2"], 55.43104, delta = 0.5e-5)
423 
424  def test_GeodSolve73(self):
425  # Check for backwards from the pole bug reported by Anon on 2016-02-13.
426  # This only affected the Java implementation. It was introduced in Java
427  # version 1.44 and fixed in 1.46-SNAPSHOT on 2016-01-17.
428  dir = Geodesic.WGS84.Direct(90, 10, 180, -1e6)
429  self.assertAlmostEqual(dir["lat2"], 81.04623, delta = 0.5e-5)
430  self.assertAlmostEqual(dir["lon2"], -170, delta = 0.5e-5)
431  self.assertAlmostEqual(dir["azi2"], 0, delta = 0.5e-5)
432 
433  def test_GeodSolve74(self):
434  # Check fix for inaccurate areas, bug introduced in v1.46, fixed
435  # 2015-10-16.
436  inv = Geodesic.WGS84.Inverse(54.1589, 15.3872, 54.1591, 15.3877,
437  Geodesic.ALL)
438  self.assertAlmostEqual(inv["azi1"], 55.723110355, delta = 5e-9);
439  self.assertAlmostEqual(inv["azi2"], 55.723515675, delta = 5e-9);
440  self.assertAlmostEqual(inv["s12"], 39.527686385, delta = 5e-9);
441  self.assertAlmostEqual(inv["a12"], 0.000355495, delta = 5e-9);
442  self.assertAlmostEqual(inv["m12"], 39.527686385, delta = 5e-9);
443  self.assertAlmostEqual(inv["M12"], 0.999999995, delta = 5e-9);
444  self.assertAlmostEqual(inv["M21"], 0.999999995, delta = 5e-9);
445  self.assertAlmostEqual(inv["S12"], 286698586.30197, delta = 5e-4);
446 
447  def test_GeodSolve76(self):
448  # The distance from Wellington and Salamanca (a classic failure of
449  # Vincenty)
450  inv = Geodesic.WGS84.Inverse(-(41+19/60.0), 174+49/60.0,
451  40+58/60.0, -(5+30/60.0))
452  self.assertAlmostEqual(inv["azi1"], 160.39137649664, delta = 0.5e-11)
453  self.assertAlmostEqual(inv["azi2"], 19.50042925176, delta = 0.5e-11)
454  self.assertAlmostEqual(inv["s12"], 19960543.857179, delta = 0.5e-6)
455 
456  def test_GeodSolve78(self):
457  # An example where the NGS calculator fails to converge
458  inv = Geodesic.WGS84.Inverse(27.2, 0.0, -27.1, 179.5)
459  self.assertAlmostEqual(inv["azi1"], 45.82468716758, delta = 0.5e-11)
460  self.assertAlmostEqual(inv["azi2"], 134.22776532670, delta = 0.5e-11)
461  self.assertAlmostEqual(inv["s12"], 19974354.765767, delta = 0.5e-6)
462 
463 class PlanimeterTest(unittest.TestCase):
464 
465  polygon = Geodesic.WGS84.Polygon(False)
466  polyline = Geodesic.WGS84.Polygon(True)
467 
468  def Planimeter(points):
469  PlanimeterTest.polygon.Clear()
470  for p in points:
471  PlanimeterTest.polygon.AddPoint(p[0], p[1])
472  return PlanimeterTest.polygon.Compute(False, True)
473  Planimeter = staticmethod(Planimeter)
474 
475  def PolyLength(points):
476  PlanimeterTest.polyline.Clear()
477  for p in points:
478  PlanimeterTest.polyline.AddPoint(p[0], p[1])
479  return PlanimeterTest.polyline.Compute(False, True)
480  PolyLength = staticmethod(PolyLength)
481 
482  def test_Planimeter0(self):
483  # Check fix for pole-encircling bug found 2011-03-16
484  points = [[89, 0], [89, 90], [89, 180], [89, 270]]
485  num, perimeter, area = PlanimeterTest.Planimeter(points)
486  self.assertAlmostEqual(perimeter, 631819.8745, delta = 1e-4)
487  self.assertAlmostEqual(area, 24952305678.0, delta = 1)
488  points = [[-89, 0], [-89, 90], [-89, 180], [-89, 270]]
489  num, perimeter, area = PlanimeterTest.Planimeter(points)
490  self.assertAlmostEqual(perimeter, 631819.8745, delta = 1e-4)
491  self.assertAlmostEqual(area, -24952305678.0, delta = 1)
492 
493  points = [[0, -1], [-1, 0], [0, 1], [1, 0]]
494  num, perimeter, area = PlanimeterTest.Planimeter(points)
495  self.assertAlmostEqual(perimeter, 627598.2731, delta = 1e-4)
496  self.assertAlmostEqual(area, 24619419146.0, delta = 1)
497 
498  points = [[90, 0], [0, 0], [0, 90]]
499  num, perimeter, area = PlanimeterTest.Planimeter(points)
500  self.assertAlmostEqual(perimeter, 30022685, delta = 1)
501  self.assertAlmostEqual(area, 63758202715511.0, delta = 1)
502  num, perimeter, area = PlanimeterTest.PolyLength(points)
503  self.assertAlmostEqual(perimeter, 20020719, delta = 1)
504  self.assertTrue(Math.isnan(area))
505 
506  def test_Planimeter5(self):
507  # Check fix for Planimeter pole crossing bug found 2011-06-24
508  points = [[89, 0.1], [89, 90.1], [89, -179.9]]
509  num, perimeter, area = PlanimeterTest.Planimeter(points)
510  self.assertAlmostEqual(perimeter, 539297, delta = 1)
511  self.assertAlmostEqual(area, 12476152838.5, delta = 1)
512 
513  def test_Planimeter6(self):
514  # Check fix for Planimeter lon12 rounding bug found 2012-12-03
515  points = [[9, -0.00000000000001], [9, 180], [9, 0]]
516  num, perimeter, area = PlanimeterTest.Planimeter(points)
517  self.assertAlmostEqual(perimeter, 36026861, delta = 1)
518  self.assertAlmostEqual(area, 0, delta = 1)
519  points = [[9, 0.00000000000001], [9, 0], [9, 180]]
520  num, perimeter, area = PlanimeterTest.Planimeter(points)
521  self.assertAlmostEqual(perimeter, 36026861, delta = 1)
522  self.assertAlmostEqual(area, 0, delta = 1)
523  points = [[9, 0.00000000000001], [9, 180], [9, 0]]
524  num, perimeter, area = PlanimeterTest.Planimeter(points)
525  self.assertAlmostEqual(perimeter, 36026861, delta = 1)
526  self.assertAlmostEqual(area, 0, delta = 1)
527  points = [[9, -0.00000000000001], [9, 0], [9, 180]]
528  num, perimeter, area = PlanimeterTest.Planimeter(points)
529  self.assertAlmostEqual(perimeter, 36026861, delta = 1)
530  self.assertAlmostEqual(area, 0, delta = 1)
531 
532  def test_Planimeter12(self):
533  # Area of arctic circle (not really -- adjunct to rhumb-area test)
534  points = [[66.562222222, 0], [66.562222222, 180]]
535  num, perimeter, area = PlanimeterTest.Planimeter(points)
536  self.assertAlmostEqual(perimeter, 10465729, delta = 1)
537  self.assertAlmostEqual(area, 0, delta = 1)
538 
539  def test_Planimeter13(self):
540  # Check encircling pole twice
541  points = [[89,-360], [89,-240], [89,-120], [89,0], [89,120], [89,240]]
542  num, perimeter, area = PlanimeterTest.Planimeter(points)
543  self.assertAlmostEqual(perimeter, 1160741, delta = 1)
544  self.assertAlmostEqual(area, 32415230256.0, delta = 1)
geographiclib.test.test_geodesic.PlanimeterTest.test_Planimeter6
def test_Planimeter6(self)
Definition: test_geodesic.py:513
geographiclib.test.test_geodesic.GeodesicTest.test_inverse
def test_inverse(self)
Definition: test_geodesic.py:90
geographiclib.test.test_geodesic.GeodSolveTest.test_GeodSolve1
def test_GeodSolve1(self)
Definition: test_geodesic.py:144
geographiclib.test.test_geodesic.GeodSolveTest.test_GeodSolve66
def test_GeodSolve66(self)
Definition: test_geodesic.py:401
geographiclib.test.test_geodesic.GeodSolveTest.test_GeodSolve17
def test_GeodSolve17(self)
Definition: test_geodesic.py:239
staticmethod
Definition: pytypes.h:2265
geographiclib.test.test_geodesic.GeodSolveTest.test_GeodSolve65
def test_GeodSolve65(self)
Definition: test_geodesic.py:368
geographiclib.test.test_geodesic.GeodSolveTest.test_GeodSolve10
def test_GeodSolve10(self)
Definition: test_geodesic.py:199
geographiclib.geomath
Definition: geomath.py:1
geographiclib.test.test_geodesic.GeodSolveTest.test_GeodSolve55
def test_GeodSolve55(self)
Definition: test_geodesic.py:336
geographiclib.test.test_geodesic.PlanimeterTest
Definition: test_geodesic.py:463
geographiclib.test.test_geodesic.GeodSolveTest.test_GeodSolve12
def test_GeodSolve12(self)
Definition: test_geodesic.py:215
geographiclib.test.test_geodesic.GeodSolveTest.test_GeodSolve73
def test_GeodSolve73(self)
Definition: test_geodesic.py:424
geographiclib.test.test_geodesic.GeodSolveTest.test_GeodSolve14
def test_GeodSolve14(self)
Definition: test_geodesic.py:225
geographiclib.test.test_geodesic.PlanimeterTest.test_Planimeter0
def test_Planimeter0(self)
Definition: test_geodesic.py:482
geographiclib.test.test_geodesic.GeodSolveTest.test_GeodSolve28
def test_GeodSolve28(self)
Definition: test_geodesic.py:266
geographiclib.test.test_geodesic.GeodSolveTest.test_GeodSolve76
def test_GeodSolve76(self)
Definition: test_geodesic.py:447
geographiclib.test.test_geodesic.GeodSolveTest.test_GeodSolve11
def test_GeodSolve11(self)
Definition: test_geodesic.py:207
geographiclib.test.test_geodesic.GeodSolveTest.test_GeodSolve74
def test_GeodSolve74(self)
Definition: test_geodesic.py:433
geographiclib.geodesic.Geodesic
Definition: geodesic.py:85
geographiclib.test.test_geodesic.GeodSolveTest.test_GeodSolve5
def test_GeodSolve5(self)
Definition: test_geodesic.py:168
geographiclib.test.test_geodesic.GeodesicTest
Definition: test_geodesic.py:6
geographiclib.test.test_geodesic.GeodSolveTest
Definition: test_geodesic.py:136
geographiclib.test.test_geodesic.GeodesicTest.test_direct
def test_direct(self)
Definition: test_geodesic.py:106
geographiclib.test.test_geodesic.GeodSolveTest.test_GeodSolve2
def test_GeodSolve2(self)
Definition: test_geodesic.py:150
geographiclib.test.test_geodesic.GeodSolveTest.test_GeodSolve61
def test_GeodSolve61(self)
Definition: test_geodesic.py:355
geographiclib.test.test_geodesic.PlanimeterTest.Planimeter
Planimeter
Definition: test_geodesic.py:473
geographiclib.test.test_geodesic.GeodSolveTest.test_GeodSolve71
def test_GeodSolve71(self)
Definition: test_geodesic.py:415
geographiclib.test.test_geodesic.GeodSolveTest.test_GeodSolve78
def test_GeodSolve78(self)
Definition: test_geodesic.py:456
geographiclib.test.test_geodesic.GeodSolveTest.test_GeodSolve15
def test_GeodSolve15(self)
Definition: test_geodesic.py:232
geographiclib.test.test_geodesic.GeodSolveTest.test_GeodSolve26
def test_GeodSolve26(self)
Definition: test_geodesic.py:260
geographiclib.test.test_geodesic.PlanimeterTest.test_Planimeter12
def test_Planimeter12(self)
Definition: test_geodesic.py:532
geographiclib.test.test_geodesic.GeodSolveTest.test_GeodSolve0
def test_GeodSolve0(self)
Definition: test_geodesic.py:138
geographiclib.test.test_geodesic.PlanimeterTest.PolyLength
PolyLength
Definition: test_geodesic.py:480
abs
#define abs(x)
Definition: datatypes.h:17
geographiclib.test.test_geodesic.PlanimeterTest.test_Planimeter5
def test_Planimeter5(self)
Definition: test_geodesic.py:506
geographiclib.test.test_geodesic.PlanimeterTest.test_Planimeter13
def test_Planimeter13(self)
Definition: test_geodesic.py:539
geographiclib.test.test_geodesic.GeodSolveTest.test_GeodSolve9
def test_GeodSolve9(self)
Definition: test_geodesic.py:193
geographiclib.test.test_geodesic.GeodSolveTest.test_GeodSolve4
def test_GeodSolve4(self)
Definition: test_geodesic.py:162
geographiclib.test.test_geodesic.GeodSolveTest.test_GeodSolve33
def test_GeodSolve33(self)
Definition: test_geodesic.py:285
geographiclib.test.test_geodesic.GeodesicTest.test_arcdirect
def test_arcdirect(self)
Definition: test_geodesic.py:121
geographiclib.test.test_geodesic.GeodSolveTest.test_GeodSolve29
def test_GeodSolve29(self)
Definition: test_geodesic.py:273
geographiclib.test.test_geodesic.GeodSolveTest.test_GeodSolve6
def test_GeodSolve6(self)
Definition: test_geodesic.py:179
geographiclib.geodesic
Definition: geodesic.py:1
geographiclib.test.test_geodesic.GeodSolveTest.test_GeodSolve59
def test_GeodSolve59(self)
Definition: test_geodesic.py:348


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:15:58