siderust-cpp 0.8.0
Header-only C++ wrapper for siderust
Loading...
Searching...
No Matches
oem.hpp
Go to the documentation of this file.
1#pragma once
2
27#include "ffi_core.hpp"
28
29#include <array>
30#include <string>
31#include <string_view>
32#include <vector>
33
34namespace siderust {
35
38namespace oem {
39
40namespace detail {
41
43 SiderustOemState *ptr = nullptr;
44 unsigned long count = 0;
45
46 ~OemStatesGuard() { siderust_oem_states_free(ptr, count); }
47
48 OemStatesGuard() = default;
49 OemStatesGuard(const OemStatesGuard &) = delete;
53};
54
55} // namespace detail
56
59 double epoch_jd;
60 std::array<double, 3> pos_km;
61 std::array<double, 3> vel_kms;
62};
63
75inline std::vector<StateVector> parse(std::string_view text) {
76 const std::string buf{text};
77 SiderustOemState *raw_ptr = nullptr;
78 unsigned long count = 0;
79
80 check_status(siderust_oem_parse_str(buf.c_str(), &raw_ptr, &count), "oem::parse");
81
83 guard.ptr = raw_ptr;
84 guard.count = count;
85
86 std::vector<StateVector> result;
87 result.reserve(static_cast<std::size_t>(count));
88 for (unsigned long i = 0; i < count; ++i) {
89 const auto &s = raw_ptr[i];
90 result.push_back({s.epoch_jd,
91 {s.pos_km[0], s.pos_km[1], s.pos_km[2]},
92 {s.vel_kms[0], s.vel_kms[1], s.vel_kms[2]}});
93 }
94
95 return result;
96}
97
98} // namespace oem
100
101} // namespace siderust
Error handling and utility base for the siderust C++ wrapper.
std::vector< StateVector > parse(std::string_view text)
Parse a CCSDS OEM (KVN) document from a string.
Definition oem.hpp:75
void check_status(siderust_status_t status, const char *operation)
Definition ffi_core.hpp:111
A single spacecraft state vector from a CCSDS OEM file.
Definition oem.hpp:58
std::array< double, 3 > pos_km
Position [x, y, z] in km.
Definition oem.hpp:60
std::array< double, 3 > vel_kms
Velocity [vx, vy, vz] in km/s.
Definition oem.hpp:61
double epoch_jd
Epoch as Julian Date.
Definition oem.hpp:59
OemStatesGuard(const OemStatesGuard &)=delete
OemStatesGuard & operator=(const OemStatesGuard &)=delete
OemStatesGuard & operator=(OemStatesGuard &&)=delete
OemStatesGuard(OemStatesGuard &&)=delete