SatDump
2.0.0-alpha-76a915210
Loading...
Searching...
No Matches
proj.h
1
#pragma once
2
3
#include <cmath>
4
#define M_HALFPI M_PI_2
5
#define M_TWOPI (M_PI * 2)
6
7
#define DEG2RAD ((2.0 * M_PI) / 360.0)
8
#define RAD2DEG (360.0 / (2.0 * M_PI))
9
10
#include <cstdio>
11
12
namespace
proj
13
{
14
enum
projection_type_t
15
{
16
ProjType_Invalid,
17
ProjType_Equirectangular,
18
ProjType_Stereographic,
19
ProjType_UniversalTransverseMercator,
20
ProjType_Geos,
21
ProjType_Tpers,
22
ProjType_WebMerc,
23
};
24
25
struct
projection_setup_t
26
{
27
int
zone = -1;
// For UTM
28
bool
south =
false
;
// For UTM
29
bool
sweep_x =
false
;
// For GEOS
30
double
altitude = 0;
// For GEOS, TPERS
31
double
tilt = 0;
// For TPERS
32
double
azimuth = 0;
// For TPERS
33
};
34
35
struct
projection_t
36
{
37
// Core
38
projection_type_t type = ProjType_Invalid;
// Projection type
39
projection_setup_t
params;
// Other setup parameters
40
void
*proj_dat =
nullptr
;
// Opaque pointer holding projection-specific info
41
42
// Offsets & Scalars.
43
double
proj_offset_x = 0;
// False Easting
44
double
proj_offset_y = 0;
// False Northing
45
double
proj_scalar_x = 1;
// X Scalar
46
double
proj_scalar_y = 1;
// Y Scalar
47
48
// Internal Offsets & Scalars
49
double
lam0 = 0;
// Central Meridian
50
double
phi0 = 0;
// Central Parrallel
51
double
k0 = 1;
// General scaling factor - e.g. the 0.9996 of UTM
52
double
x0 = 0;
// False Easting
53
double
y0 = 0;
// False Northing
54
55
// Ellispoid definition
56
double
a;
57
double
e;
58
double
es;
59
double
n;
60
double
one_es;
61
double
rone_es;
62
};
63
64
/*
65
Setup a projection. This expects the struct to already
66
be pre-configured by the user and takes care of
67
allocations and setting the ellispoid.
68
*/
69
bool
projection_setup(
projection_t
*proj);
70
71
/*
72
Free allocated memory, by projection_setup.
73
*/
74
void
projection_free(
projection_t
*proj);
75
76
/*
77
Perform a forward projection.
78
This converts Lat/Lon into X/Y in the projected plane.
79
Lat/Lon should be in degrees.
80
Returns true if an error occurred, false on success.
81
*/
82
bool
projection_perform_fwd(
const
projection_t
*proj,
double
lon,
double
lat,
double
*x,
double
*y);
83
84
/*
85
Perform an inverse projection.
86
This converts X/Y from the projected plane into Lat/Lon.
87
Lat/Lon will be in degrees.
88
Returns true if an error occurred, false on success.
89
*/
90
bool
projection_perform_inv(
const
projection_t
*proj,
double
x,
double
y,
double
*lon,
double
*lat);
91
}
proj::projection_setup_t
Definition
proj.h:26
proj::projection_t
Definition
proj.h:36
src-core
projection
standard
proj.h
Generated by
1.14.0