SatDump 2.0.0-alpha-76a915210
|
Extremely generic class to handle projections. More...
#include <projection.h>
Public Types | |
enum | proj_type_t { PROJ_INVALID = 0 , PROJ_STANDARD = 1 , PROJ_RAYTRACER = 2 , PROJ_THINPLATESPLINE = 3 } |
Public Member Functions | |
proj_type_t | getFwdType () |
Get forward (Lat/Lon => X/Y) projection type. | |
proj_type_t | getInvType () |
Get inverse (X/Y => Lat/Lon) projection type. | |
bool | init (bool fwd, bool inv) |
Initialize projection, to allow using it to perform the math :-) Disabling doesn't guarantee they won't be initialized internally if required to setup the other! You can use getFwdType/getInvType to check they're not invalid if required. | |
bool | forward (geodetic::geodetic_coords_t pos, double &x, double &y, bool except=true) |
Run forward (Lat/Lon => X/Y) projection. | |
bool | inverse (double x, double y, geodetic::geodetic_coords_t &pos, double *otime=nullptr, bool except=true) |
Run forward (X/Y => Lat/Lon) projection. | |
void | to_json (nlohmann::json &j) const |
void | from_json (const nlohmann::json &j) |
Public Attributes | |
int | width = -1 |
int | height = -1 |
Friends | |
void | to_json (nlohmann::json &j, const Projection &v) |
void | from_json (const nlohmann::json &j, Projection &v) |
Extremely generic class to handle projections.
This basically abstracts absolutely everything down to a simple class that can be used in 2 lines of codes from a random projection JSON config. By default, all it will do is simply hide the JSON config internally (especially useful to allow manipulating projs in Lua!), but once init() is called, it allows actually performing the projection transform (meant for images).
Do note this is not really intended (in most cases) for high-performance scenarios, such as reprojections.
bool satdump::projection::Projection::forward | ( | geodetic::geodetic_coords_t | pos, |
double & | x, | ||
double & | y, | ||
bool | except = true ) |
Run forward (Lat/Lon => X/Y) projection.
pos | output geodetic position |
x | pixel position |
y | pixel position |
except | if false, doesn't throw exceptions |
|
inline |
Get forward (Lat/Lon => X/Y) projection type.
|
inline |
Get inverse (X/Y => Lat/Lon) projection type.
bool satdump::projection::Projection::init | ( | bool | fwd, |
bool | inv ) |
Initialize projection, to allow using it to perform the math :-) Disabling doesn't guarantee they won't be initialized internally if required to setup the other! You can use getFwdType/getInvType to check they're not invalid if required.
fwd | init forward proj |
inv | init inverse proj |
bool satdump::projection::Projection::inverse | ( | double | x, |
double | y, | ||
geodetic::geodetic_coords_t & | pos, | ||
double * | otime = nullptr, | ||
bool | except = true ) |
Run forward (X/Y => Lat/Lon) projection.
x | pixel position |
y | pixel position |
pos | output geodetic position |
otime | pixel timestamp, MUST be set to -1 before passing to this function. No guarantee the underlaying projection supports this, must be checked before use |
except | if false, doesn't throw exceptions |