isce3 0.25.0
Loading...
Searching...
No Matches
Projections.h
1#pragma once
2
3#include <iostream>
4#include <memory>
5
6#include "Constants.h"
7#include "Ellipsoid.h"
8#include "Vector.h"
9
10#include <isce3/except/Error.h>
11
12namespace isce3 { namespace core {
13
23 Ellipsoid _ellipse;
24
31 int _epsgcode;
32
33public:
39 : _ellipse(), _epsgcode(code)
40 {}
41
43 int code() const { return _epsgcode; }
44
46 const Ellipsoid& ellipsoid() const { return _ellipse; }
47
49 virtual void print() const = 0;
50
58 virtual int forward(const Vec3& llh, Vec3& xyz) const = 0;
59
67 Vec3 forward(const Vec3& llh) const
68 {
69 Vec3 xyz;
70 const int ret = forward(llh, xyz);
71 if (ret != 0) {
72 throw isce3::except::RuntimeError(ISCE_SRCINFO(),
73 "Forward projection transformation failed");
74 }
75 return xyz;
76 }
77
85 virtual int inverse(const Vec3& xyz, Vec3& llh) const = 0;
86
94 Vec3 inverse(const Vec3& xyz) const
95 {
96 Vec3 llh;
97 const int ret = inverse(xyz, llh);
98 if (ret != 0) {
99 throw isce3::except::RuntimeError(ISCE_SRCINFO(),
100 "Inverse projection transformation failed");
101 }
102 return llh;
103 }
104
105 virtual ~ProjectionBase() = default;
106};
107
109class LonLat : public ProjectionBase {
110public:
111 LonLat() : ProjectionBase(4326) {}
112
114 void print() const override;
115
116 int forward(const Vec3&, Vec3&) const override;
117
118 int inverse(const Vec3&, Vec3&) const override;
119};
120
121inline void LonLat::print() const
122{
123 std::cout << "Projection: LatLon" << std::endl
124 << "EPSG: " << code() << std::endl;
125}
126
127inline int LonLat::forward(const Vec3& in, Vec3& out) const
128{
129 out[0] = in[0] * 180.0 / M_PI;
130 out[1] = in[1] * 180.0 / M_PI;
131 out[2] = in[2];
132 return 0;
133}
134
135inline int LonLat::inverse(const Vec3& in, Vec3& out) const
136{
137 out[0] = in[0] * M_PI / 180.0;
138 out[1] = in[1] * M_PI / 180.0;
139 out[2] = in[2];
140 return 0;
141}
142
144class Geocent : public ProjectionBase {
145public:
146 Geocent() : ProjectionBase(4978) {}
147
149 void print() const;
150
152 int forward(const Vec3& llh, Vec3& xyz) const;
153
155 int inverse(const Vec3& xyz, Vec3& llh) const;
156};
157
158inline void Geocent::print() const
159{
160 std::cout << "Projection: Geocent" << std::endl
161 << "EPSG: " << code() << std::endl;
162}
163
170class UTM : public ProjectionBase {
171 // Constants related to the projection system
172 double lon0;
173 int zone;
174 bool isnorth;
175
176 // Parameters from Proj.4
177 double cgb[6], cbg[6], utg[6], gtu[6];
178 double Qn, Zb;
179
180public:
181 UTM(int);
182
184 void print() const override;
185
187 int forward(const Vec3& llh, Vec3& xyz) const override;
188
190 int inverse(const Vec3& xyz, Vec3& llh) const override;
191};
192
193inline void UTM::print() const
194{
195 std::cout << "Projection: UTM" << std::endl
196 << "Zone: " << zone << (isnorth ? "N" : "S") << std::endl
197 << "EPSG: " << code() << std::endl;
198}
199
206class PolarStereo : public ProjectionBase {
207 // Constants related to projection system
208 double lat0, lon0, lat_ts, akm1, e;
209 bool isnorth;
210
211public:
212 PolarStereo(int);
213
215 void print() const override;
216
218 int forward(const Vec3&, Vec3&) const override;
219
221 int inverse(const Vec3&, Vec3&) const override;
222};
223
224inline void PolarStereo::print() const
225{
226 std::cout << "Projection: " << (isnorth ? "North" : "South")
227 << " Polar Stereographic" << std::endl
228 << "EPSG: " << code() << std::endl;
229}
230
236class CEA : public ProjectionBase {
237 // Constants related to projection system
238 double apa[3];
239 double lat_ts, k0, e, one_es, qp;
240
241public:
242 CEA();
243
244 void print() const override;
245
247 int forward(const Vec3& llh, Vec3& xyz) const override;
248
250 int inverse(const Vec3& xyz, Vec3& llh) const override;
251};
252
253inline void CEA::print() const
254{
255 std::cout << "Projection: Cylindrical Equal Area" << std::endl
256 << "EPSG: " << code() << std::endl;
257}
258
259// This is to create a projection system from the EPSG code
260ProjectionBase* createProj(int epsg);
261
262inline std::unique_ptr<ProjectionBase> makeProjection(int epsg)
263{
264 return std::unique_ptr<ProjectionBase>(createProj(epsg));
265}
266
267// This is to transform a point from one coordinate system to another
268int projTransform(ProjectionBase* in, ProjectionBase* out, const Vec3& inpts,
269 Vec3& outpts);
270
271}} // namespace isce3::core
void print() const override
Print function for debugging.
Definition Projections.h:253
int forward(const Vec3 &llh, Vec3 &xyz) const override
Transform from llh (rad) to CEA (m)
Definition Projections.cpp:349
int inverse(const Vec3 &xyz, Vec3 &llh) const override
Transform from CEA (m) to LLH (rad)
Definition Projections.cpp:357
Data structure to store Ellipsoid information.
Definition Ellipsoid.h:20
void print() const
Print function for debugging.
Definition Projections.h:158
int forward(const Vec3 &llh, Vec3 &xyz) const
This is same as Ellipsoid::lonLatToXyz.
Definition Projections.cpp:10
int inverse(const Vec3 &xyz, Vec3 &llh) const
This is same as Ellipsoid::xyzToLonLat.
Definition Projections.cpp:18
void print() const override
Print function for debugging.
Definition Projections.h:121
int forward(const Vec3 &, Vec3 &) const override
Function for transforming from LLH.
Definition Projections.h:127
int inverse(const Vec3 &, Vec3 &) const override
Function for transforming to LLH.
Definition Projections.h:135
int inverse(const Vec3 &, Vec3 &) const override
Transform from Polar Stereo (m) to llh (rad)
Definition Projections.cpp:292
int forward(const Vec3 &, Vec3 &) const override
Transform from llh(rad) to Polar Stereo (m)
Definition Projections.cpp:278
void print() const override
Print function for debugging.
Definition Projections.h:224
Abstract base class for individual projections.
Definition Projections.h:21
Vec3 inverse(const Vec3 &xyz) const
Function for transforming to LLH.
Definition Projections.h:94
Vec3 forward(const Vec3 &llh) const
Function for transforming from LLH.
Definition Projections.h:67
virtual int inverse(const Vec3 &xyz, Vec3 &llh) const =0
Function for transforming to LLH.
virtual int forward(const Vec3 &llh, Vec3 &xyz) const =0
Function for transforming from LLH.
int code() const
Return EPSG code.
Definition Projections.h:43
ProjectionBase(int code)
Value constructor with EPSG code as input.
Definition Projections.h:38
const Ellipsoid & ellipsoid() const
Return underlying ellipsoid.
Definition Projections.h:46
virtual void print() const =0
Print function for debugging.
int inverse(const Vec3 &xyz, Vec3 &llh) const override
Transform from UTM(m) to llh (rad)
Definition Projections.cpp:202
int forward(const Vec3 &llh, Vec3 &xyz) const override
Transform from llh (rad) to UTM (m)
Definition Projections.cpp:171
void print() const override
Print function for debugging.
Definition Projections.h:193
base interpolator is an abstract base class
Definition BinarySearchFunc.cpp:5
Abstract base class for individual projections.
Definition gpuProjections.h:23

Generated for ISCE3.0 by doxygen 1.13.2.