SatDump 2.0.0-alpha-76a915210
Loading...
Searching...
No Matches
projection.h
Go to the documentation of this file.
1#pragma once
2
6
7#include "common/geodetic/geodetic_coordinates.h"
8#include "nlohmann/json.hpp"
9
10// Needed for projs. Maybe hide later? TBD TODOREWORK
13#include "standard/proj.h"
14#include "tps/latlontps_proj.h"
15
16namespace satdump
17{
18 namespace projection
19 {
33 class Projection
34 {
35 public:
36 enum proj_type_t
37 {
38 PROJ_INVALID = 0,
39 PROJ_STANDARD = 1,
40 PROJ_RAYTRACER = 2,
41 PROJ_THINPLATESPLINE = 3,
42 };
43
48 proj_type_t getFwdType() { return fwd_type; }
49
54 proj_type_t getInvType() { return inv_type; }
55
56 private:
57 nlohmann::json d_cfg;
58 bool fwd_valid = false;
59 bool rev_valid = false;
60 proj_type_t fwd_type = PROJ_INVALID;
61 proj_type_t inv_type = PROJ_INVALID;
62
63 public:
64 int width = -1;
65 int height = -1; // TODOREWORK do we need those?
66
67 private:
68 std::shared_ptr<SatelliteRaytracer> raytracer;
69 ChannelTransform transform;
70 ::proj::projection_t std_proj;
71 std::shared_ptr<satdump::proj::LatLonTpsProjHelper> tps_fwd;
72
73 double proj_timestamp = -1; // Timestamp fed in case standards projs have a timestamp field
74
75 private:
76 bool has_2nd_transform = false;
77 ChannelTransform transform2; // TODO DOCUMENT
78
79 public:
80 Projection();
82
94 bool init(bool fwd, bool inv);
95
104 bool forward(geodetic::geodetic_coords_t pos, double &x, double &y, bool except = true);
105
117 bool inverse(double x, double y, geodetic::geodetic_coords_t &pos, double *otime = nullptr, bool except = true);
118
119 public:
120 void to_json(nlohmann::json &j) const;
121 void from_json(const nlohmann::json &j);
122
123 friend void to_json(nlohmann::json &j, const Projection &v) { v.to_json(j); }
124 friend void from_json(const nlohmann::json &j, Projection &v) { v.from_json(j); }
125 };
126 } // namespace projection
127} // namespace satdump
Class handling 2D transforms, mainly intended for image channels. This covers a simple but pretty imp...
Definition channel_transform.h:39
Extremely generic class to handle projections.
Definition projection.h:34
bool inverse(double x, double y, geodetic::geodetic_coords_t &pos, double *otime=nullptr, bool except=true)
Run forward (X/Y => Lat/Lon) projection.
Definition projection.cpp:139
bool forward(geodetic::geodetic_coords_t pos, double &x, double &y, bool except=true)
Run forward (Lat/Lon => X/Y) projection.
Definition projection.cpp:110
proj_type_t getInvType()
Get inverse (X/Y => Lat/Lon) projection type.
Definition projection.h:54
proj_type_t getFwdType()
Get forward (Lat/Lon => X/Y) projection type.
Definition projection.h:48
bool init(bool fwd, bool inv)
Initialize projection, to allow using it to perform the math :-) Disabling doesn't guarantee they won...
Definition projection.cpp:20
Definition proj.h:36