siderust-cpp 0.8.0
Header-only C++ wrapper for siderust
Loading...
Searching...
No Matches
geodetic.hpp
Go to the documentation of this file.
1#pragma once
2
9#include "../centers.hpp"
10#include "../ffi_core.hpp"
11#include "../frames.hpp"
12
13#include <qtty/qtty.hpp>
14
15#include <ostream>
16
17namespace siderust {
18namespace cartesian {
19template <typename C, typename F, typename U> struct Position;
20}
21
29struct Geodetic {
30 qtty::Degree lon;
31 qtty::Degree lat;
32 qtty::Meter height;
33
34 Geodetic() : lon(qtty::Degree(0)), lat(qtty::Degree(0)), height(qtty::Meter(0)) {}
35
36 Geodetic(qtty::Degree lon_, qtty::Degree lat_, qtty::Meter h = qtty::Meter(0))
37 : lon(lon_), lat(lat_), height(h) {}
38
40 Geodetic(double lon_deg, double lat_deg, double height_m = 0.0)
41 : lon(qtty::Degree(lon_deg)), lat(qtty::Degree(lat_deg)), height(qtty::Meter(height_m)) {}
42
44 siderust_geodetic_t to_c() const { return {lon.value(), lat.value(), height.value()}; }
45
47 static Geodetic from_c(const siderust_geodetic_t &c) {
48 return Geodetic(c.lon_deg, c.lat_deg, c.height_m);
49 }
50
56 template <typename U = qtty::Meter>
58};
59
60// ============================================================================
61// Stream operators
62// ============================================================================
63
67inline std::ostream &operator<<(std::ostream &os, const Geodetic &geo) {
68 return os << "Geodetic (lon=" << geo.lon << ", lat=" << geo.lat << ", h=" << geo.height << ')';
69}
70
71} // namespace siderust
std::ostream & operator<<(std::ostream &os, AzimuthExtremumKind kind)
Stream operator for AzimuthExtremumKind.
Definition azimuth.hpp:395
Geodetic position (WGS84 ellipsoid).
Definition geodetic.hpp:29
qtty::Degree lon
Longitude (east positive).
Definition geodetic.hpp:30
cartesian::Position< centers::Geocentric, frames::ECEF, U > to_cartesian() const
Convert geodetic (WGS84/ECEF) to cartesian position.
Geodetic(qtty::Degree lon_, qtty::Degree lat_, qtty::Meter h=qtty::Meter(0))
Definition geodetic.hpp:36
qtty::Degree lat
Latitude (north positive).
Definition geodetic.hpp:31
Geodetic(double lon_deg, double lat_deg, double height_m=0.0)
Raw-double convenience constructor (degrees, metres).
Definition geodetic.hpp:40
qtty::Meter height
Height above ellipsoid.
Definition geodetic.hpp:32
siderust_geodetic_t to_c() const
Convert to C FFI struct.
Definition geodetic.hpp:44
static Geodetic from_c(const siderust_geodetic_t &c)
Create from C FFI struct.
Definition geodetic.hpp:47
A 3D Cartesian position, compile-time tagged by center, frame, unit.