Skip to content

Commit c5b684f

Browse files
committed
[tests]: Add test for small angles for Kayney's inverse method
1 parent 9885d3b commit c5b684f

File tree

3 files changed

+129
-42
lines changed

3 files changed

+129
-42
lines changed

test/formulas/inverse.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "test_formula.hpp"
1717
#include "inverse_cases.hpp"
1818
#include "inverse_cases_antipodal.hpp"
19+
#include "inverse_cases_small_angles.hpp"
1920

2021
#include <boost/geometry/formulas/vincenty_inverse.hpp>
2122
#include <boost/geometry/formulas/thomas_inverse.hpp>
@@ -107,6 +108,23 @@ void test_karney_antipodal(expected_results_antipodal const& results)
107108
check_inverse("karney", results, result, results.karney, results.karney, 0.0000001);
108109
}
109110

111+
void test_karney_small_angles(expected_results_small_angles const& results)
112+
{
113+
double lon1d = results.p1.lon;
114+
double lat1d = results.p1.lat;
115+
double lon2d = results.p2.lon;
116+
double lat2d = results.p2.lat;
117+
118+
// WGS84
119+
bg::srs::spheroid<double> spheroid(6378137.0, 6356752.3142451793);
120+
121+
bg::formula::result_inverse<double> result;
122+
123+
typedef bg::formula::karney_inverse<double, true, true, true, true, true, 8> ka_t;
124+
result = ka_t::apply(lon1d, lat1d, lon2d, lat2d, spheroid);
125+
check_inverse("karney", results, result, results.karney, results.karney, 0.0000001);
126+
}
127+
110128
int test_main(int, char*[])
111129
{
112130
for (size_t i = 0; i < expected_size; ++i)
@@ -119,5 +137,10 @@ int test_main(int, char*[])
119137
test_karney_antipodal(expected_antipodal[i]);
120138
}
121139

140+
for (size_t i = 0; i < expected_size_small_angles; ++i)
141+
{
142+
test_karney_small_angles(expected_small_angles[i]);
143+
}
144+
122145
return 0;
123146
}

test/formulas/inverse_cases.hpp

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -41,48 +41,6 @@ struct expected_results
4141
expected_results expected[] =
4242
{
4343
{
44-
{ 180, 0 },{ 0, 0 },
45-
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
46-
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
47-
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
48-
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
49-
},{
50-
{ 180, 0 },{ 1e-300, 0 },
51-
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
52-
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
53-
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
54-
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
55-
},{
56-
{ 180, 0 },{ 1e-200, 0 },
57-
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
58-
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
59-
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
60-
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
61-
},{
62-
{ 180, 0 },{ 1e-100, 0 },
63-
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
64-
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
65-
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
66-
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
67-
},{
68-
{ 180, 0 },{ 1e-50, 0 },
69-
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
70-
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
71-
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
72-
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
73-
},{
74-
{ 180, 0 },{ 1e-20, 0 },
75-
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
76-
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
77-
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
78-
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
79-
},{
80-
{ 180, 0 },{ 1e-10, 0 },
81-
{ 20003931.45862544700503349304, -9.501793528220011062168943853e-09, -179.9999999904981962117744843, 67125.61229850351810455322266, -1 },
82-
{ 20003931.45862544700503349304, -9.501793528220011062168943853e-09, -179.9999999904981962117744843, 67125.61229850351810455322266, -1 },
83-
{ 20003931.45862544700503349304, -9.501793528220011062168943853e-09, -179.9999999904981962117744843, 67125.61229850351810455322266, -1 },
84-
{ 20003931.45862544700503349304, -9.501793528220011062168943853e-09, -179.9999999904981962117744843, 67125.61229850351810455322266, -1 }
85-
},{
8644
{ 0, 0 },{ 2, 0 },
8745
{ 222638.98158654713188298047, 90.00000000000000000000, 90.00000000000000000000, 222593.46652303214068524539, 0.99938672191946420487 },
8846
{ 222638.98158645280636847019, 90.00000000000000000000, 90.00000000000000000000, 222593.46652303214068524539, 0.99938672191946420487 },
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
// Boost.Geometry
2+
// Unit Test
3+
4+
// Copyright (c) 2018 Adeel Ahmad, Islamabad, Pakistan.
5+
6+
// Contributed and/or modified by Adeel Ahmad, as part of Google Summer of Code 2018 program.
7+
8+
// Use, modification and distribution is subject to the Boost Software License,
9+
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
10+
// http://www.boost.org/LICENSE_1_0.txt)
11+
12+
#ifndef BOOST_GEOMETRY_TEST_INVERSE_CASES_SMALL_ANGLES_HPP
13+
#define BOOST_GEOMETRY_TEST_INVERSE_CASES_SMALL_ANGLES_HPP
14+
15+
#include "inverse_cases.hpp"
16+
17+
struct expected_results_small_angles
18+
{
19+
coordinates p1;
20+
coordinates p2;
21+
expected_result karney;
22+
};
23+
24+
/*
25+
These values are collected from GeodTest which is associated with GeographicLib:
26+
https://zenodo.org/record/32156
27+
28+
The conversion to C++ array format is done using this Python script:
29+
https://github.com/adl1995/boost-geometry-extra/blob/master/geographiclib-dataset-parse-inverse.py
30+
31+
Geodesic scale (M12) is absent from the GeodTest dataset, so it is manually generated
32+
using GeographicLib using this C++ script:
33+
https://github.com/adl1995/boost-geometry-extra/blob/master/geographicLib-direct-small_angles.cpp
34+
*/
35+
expected_results_small_angles expected_small_angles[] =
36+
{
37+
{
38+
{ 180, 0 },{ 0, 0 },
39+
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
40+
},{
41+
{ 180, 0 },{ 1e-300, 0 },
42+
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
43+
},{
44+
{ 180, 0 },{ 1e-200, 0 },
45+
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
46+
},{
47+
{ 180, 0 },{ 1e-100, 0 },
48+
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
49+
},{
50+
{ 180, 0 },{ 1e-50, 0 },
51+
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
52+
},{
53+
{ 180, 0 },{ 1e-20, 0 },
54+
{ 20003931.45862544700503349304, -0.00000000000000000000, 180.00000000000000000000, 67125.61229850351810455322266, -1.00000000000000000000 },
55+
},{
56+
{ 180, 0 },{ 1e-10, 0 },
57+
{ 20003931.45862544700503349304, -9.501793528220011062168943853e-09, -179.9999999904981962117744843, 67125.61229850351810455322266, -1 },
58+
},{
59+
{ 0, 1e-100 },{ 170, 1e-200},
60+
{ 18924313.43485650792717933655, 90, 90, 1041298.808552250848151743412, -0.9864919282563420210863114335 },
61+
},{
62+
{ 0, 1e-300 },{ 170, 1e-50},
63+
{ 18924313.43485650792717933655, 90, 90, 1041298.808552250848151743412, -0.9864919282563420210863114335 },
64+
},{
65+
{ 0, 1e-300 },{ 170, 1e-10},
66+
{ 18924313.43485650792717933655, 89.99999999939157646622334141, 90.00000000060019544889655663, 1041298.80855225014965981245, -0.9864919282563420210863114335 },
67+
},{
68+
{ 0, 1e-100 },{ 170, 1e-50},
69+
{ 18924313.43485650792717933655, 90, 90, 1041298.808552250848151743412, -0.9864919282563420210863114335 },
70+
},{
71+
{ 0, 1e-200 },{ 170, 1e-50},
72+
{ 18924313.43485650792717933655, 90, 90, 1041298.808552250848151743412, -0.9864919282563420210863114335 },
73+
},{
74+
{ 0, 0.0 },{ 170, 1e-10},
75+
{ 18924313.43485650792717933655, 89.99999999939157646622334141, 90.00000000060019544889655663, 1041298.80855225014965981245, -0.9864919282563420210863114335 },
76+
},{
77+
{ 0, 1e-20 },{ 170, 1e-100},
78+
{ 18924313.43485650792717933655, 90, 90, 1041298.808552250848151743412, -0.9864919282563420210863114335 },
79+
},{
80+
{ 0, 1e-100 },{ 170, 0.0},
81+
{ 18924313.43485650792717933655, 90, 90, 1041298.808552250848151743412, -0.9864919282563420210863114335 },
82+
},{
83+
{ 0, 1e-10 },{ 170, 1e-300},
84+
{ 18924313.43485650792717933655, 89.99999999939980455110344337, 90.00000000060842353377665859, 1041298.80855225014965981245, -0.9864919282563420210863114335 },
85+
},{
86+
{ 0, 1e-300 },{ 170, 1e-100},
87+
{ 18924313.43485650792717933655, 90, 90, 1041298.808552250848151743412, -0.9864919282563420210863114335 },
88+
},{
89+
{ 0, 1e-200 },{ 170, 1e-100},
90+
{ 18924313.43485650792717933655, 90, 90, 1041298.808552250848151743412, -0.9864919282563420210863114335 },
91+
},{
92+
{ 0, 1e-10 },{ 170, 1e-50},
93+
{ 18924313.43485650792717933655, 89.99999999939980455110344337, 90.00000000060842353377665859, 1041298.80855225014965981245, -0.9864919282563420210863114335 },
94+
},{
95+
{ 0, 0.0 },{ 170, 1e-200},
96+
{ 18924313.43485650792717933655, 90, 90, 1041298.808552250848151743412, -0.9864919282563420210863114335 },
97+
},{
98+
{ 0, 0.0 },{ 170, 1e-10},
99+
{ 18924313.43485650792717933655, 89.99999999939157646622334141, 90.00000000060019544889655663, 1041298.80855225014965981245, -0.9864919282563420210863114335 },
100+
}
101+
};
102+
103+
104+
size_t const expected_size_small_angles = sizeof(expected_small_angles) / sizeof(expected_results_small_angles);
105+
106+
#endif // BOOST_GEOMETRY_TEST_INVERSE_CASES_SMALL_ANGLES_HPP

0 commit comments

Comments
 (0)