Line |
Branch |
Exec |
Source |
1 |
|
|
// This file is part of INSTINCT, the INS Toolkit for Integrated |
2 |
|
|
// Navigation Concepts and Training by the Institute of Navigation of |
3 |
|
|
// the University of Stuttgart, Germany. |
4 |
|
|
// |
5 |
|
|
// This Source Code Form is subject to the terms of the Mozilla Public |
6 |
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this |
7 |
|
|
// file, You can obtain one at https://mozilla.org/MPL/2.0/. |
8 |
|
|
|
9 |
|
|
#include "readAscii2Matrix.hpp" |
10 |
|
|
|
11 |
|
|
#include <iostream> |
12 |
|
|
#include <fstream> |
13 |
|
|
#include <string> |
14 |
|
|
#include <Eigen/Dense> |
15 |
|
|
#include <filesystem> |
16 |
|
|
|
17 |
|
|
#include "util/Logger.hpp" |
18 |
|
|
#include "util/StringUtil.hpp" |
19 |
|
|
|
20 |
|
✗ |
Eigen::MatrixXd NAV::internal::readAscii2Matrix() |
21 |
|
|
{ |
22 |
|
✗ |
std::string line; |
23 |
|
✗ |
std::ifstream myfileN("resources/data/egm96_to360.ascii"); |
24 |
|
✗ |
std::ifstream myfile("resources/data/egm96_to360.ascii"); |
25 |
|
|
|
26 |
|
✗ |
char delimiter = ' '; |
27 |
|
✗ |
size_t pos = 0; |
28 |
|
✗ |
std::string token; |
29 |
|
✗ |
uint32_t nmbrOfLines = static_cast<uint32_t>(std::count(std::istreambuf_iterator<char>(myfileN), std::istreambuf_iterator<char>(), '\n')); |
30 |
|
|
|
31 |
|
|
LOG_DATA("Number of lines in 'egm96_to360.ascii':_{}", nmbrOfLines); |
32 |
|
|
|
33 |
|
✗ |
int i = 0; |
34 |
|
✗ |
int j = 0; |
35 |
|
✗ |
Eigen::MatrixXd coeffs(nmbrOfLines, 6); |
36 |
|
|
|
37 |
|
✗ |
if (myfile.good()) |
38 |
|
|
{ |
39 |
|
✗ |
while (getline(myfile, line)) |
40 |
|
|
{ |
41 |
|
✗ |
while ((pos = line.find(delimiter)) != std::string::npos) |
42 |
|
|
{ |
43 |
|
✗ |
if (line.substr(0, 1) == " ") |
44 |
|
|
{ |
45 |
|
✗ |
NAV::str::ltrim(line); |
46 |
|
|
} |
47 |
|
|
else |
48 |
|
|
{ |
49 |
|
✗ |
token = line.substr(0, pos); |
50 |
|
✗ |
coeffs(i, j) = std::strtod(token.c_str(), nullptr); |
51 |
|
|
|
52 |
|
✗ |
line.erase(0, pos + 1); |
53 |
|
|
|
54 |
|
✗ |
if (j < 5) |
55 |
|
|
{ |
56 |
|
✗ |
j++; |
57 |
|
|
} |
58 |
|
|
} |
59 |
|
|
} |
60 |
|
✗ |
coeffs(i, 5) = std::strtod(line.c_str(), nullptr); |
61 |
|
✗ |
j = 0; |
62 |
|
✗ |
if (static_cast<uint32_t>(i + 1) < nmbrOfLines) |
63 |
|
|
{ |
64 |
|
✗ |
i++; |
65 |
|
|
} |
66 |
|
|
} |
67 |
|
|
} |
68 |
|
|
else |
69 |
|
|
{ |
70 |
|
✗ |
LOG_CRITICAL("Unable to open file 'egm96_to360.ascii' --> gravity vector compensation not trustworthy"); |
71 |
|
|
coeffs = Eigen::MatrixXd::Zero(1, 6); |
72 |
|
|
} |
73 |
|
✗ |
return coeffs; |
74 |
|
✗ |
} |
75 |
|
|
|