File: inverse_karney.cpp

package info (click to toggle)
boost1.83 1.83.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 545,632 kB
  • sloc: cpp: 3,857,086; xml: 125,552; ansic: 34,414; python: 25,887; asm: 5,276; sh: 4,799; ada: 1,681; makefile: 1,629; perl: 1,212; pascal: 1,139; sql: 810; yacc: 478; ruby: 102; lisp: 24; csh: 6
file content (89 lines) | stat: -rw-r--r-- 2,844 bytes parent folder | download | duplicates (9)
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
// Boost.Geometry
// Unit Test

// Copyright (c) 2016-2021 Oracle and/or its affiliates.

// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle

// Copyright (c) 2018 Adeel Ahmad, Islamabad, Pakistan.

// Contributed and/or modified by Adeel Ahmad, as part of Google Summer of Code 2018 program

// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)


#include <sstream>

#include "test_formula.hpp"
#include "inverse_cases.hpp"
#include "inverse_cases_antipodal.hpp"
#include "inverse_cases_small_angles.hpp"

#include <boost/geometry/formulas/karney_inverse.hpp>

#include <boost/geometry/srs/spheroid.hpp>

#include <boost/geometry/util/math.hpp>

void test_all(expected_results const& results)
{
    double lon1d = results.p1.lon * bg::math::d2r<double>();
    double lat1d = results.p1.lat * bg::math::d2r<double>();
    double lon2d = results.p2.lon * bg::math::d2r<double>();
    double lat2d = results.p2.lat * bg::math::d2r<double>();

    // WGS84
    bg::srs::spheroid<double> spheroid(6378137.0, 6356752.3142451793);

    bg::formula::result_inverse<double> result_k;

    typedef bg::formula::karney_inverse<double, true, true, true, true, true> ka_t;
    result_k = ka_t::apply(lon1d, lat1d, lon2d, lat2d, spheroid);
    result_k.azimuth *= bg::math::r2d<double>();
    result_k.reverse_azimuth *= bg::math::r2d<double>();
    check_inverse("karney", results, result_k, results.vincenty, results.reference, 0.0000001);
}

template <typename ExpectedResults>
void test_karney(ExpectedResults const& results)
{
    double lon1d = results.p1.lon * bg::math::d2r<double>();
    double lat1d = results.p1.lat * bg::math::d2r<double>();
    double lon2d = results.p2.lon * bg::math::d2r<double>();
    double lat2d = results.p2.lat * bg::math::d2r<double>();


    // WGS84
    bg::srs::spheroid<double> spheroid(6378137.0, 6356752.3142451793);

    bg::formula::result_inverse<double> result;

    typedef bg::formula::karney_inverse<double, true, true, true, true, true> ka_t;
    result = ka_t::apply(lon1d, lat1d, lon2d, lat2d, spheroid);
    result.azimuth *= bg::math::r2d<double>();
    result.reverse_azimuth *= bg::math::r2d<double>();
    check_inverse("karney", results, result, results.karney, results.karney, 0.0000001);
}

int test_main(int, char*[])
{
    for (size_t i = 0; i < expected_size; ++i)
    {
        test_all(expected[i]);
    }

    for (size_t i = 0; i < expected_size_antipodal; ++i)
    {
        test_karney(expected_antipodal[i]);
    }

    for (size_t i = 0; i < expected_size_small_angles; ++i)
    {
        test_karney(expected_small_angles[i]);
    }

    return 0;
}