isce3  0.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Projections.h
1 //
2 // Source Author: Piyush Agram
3 // Co-Author: Joshua Cohen
4 // Copyright 2017
5 //
6 
7 #pragma once
8 
9 #include <iostream>
10 #include <memory>
11 
12 #include "Constants.h"
13 #include "Ellipsoid.h"
14 
15 namespace isce3 { namespace core {
16 
24  Ellipsoid _ellipse;
25 
28  int _epsgcode;
29 
30  public:
31 
34  ProjectionBase(int code) : _ellipse(6378137.,.0066943799901), _epsgcode(code) {}
35 
37  inline int code() const { return _epsgcode; }
38 
40  inline const Ellipsoid& ellipsoid() const { return _ellipse; }
41 
43  virtual void print() const = 0;
44 
49  virtual int forward(const cartesian_t& llh, cartesian_t& xyz) const = 0 ;
50 
55  virtual int inverse(const cartesian_t& xyz, cartesian_t& llh) const = 0 ;
56  inline Vec3 inverse(const Vec3& native) const {
57  Vec3 llh;
58  inverse(native, llh);
59  return llh;
60  }
61 
63  virtual ~ProjectionBase() {}
64  };
65 
67  class LonLat : public ProjectionBase {
68  public:
69  // Value constructor
70  LonLat() : ProjectionBase(4326) {}
71 
72  inline void print() const;
73  // This will be a pass through for Lat/Lon
74  inline int forward(const cartesian_t&, cartesian_t&) const;
75  // This will also be a pass through for Lat/Lon
76  inline int inverse(const cartesian_t&, cartesian_t&) const;
77  };
78 
79  inline void LonLat::print() const {
80  std::cout << "Projection: LatLon" << std::endl << "EPSG: " << code() << std::endl;
81  }
82 
83  inline int LonLat::forward(const cartesian_t &in, cartesian_t &out) const {
84  out[0] = in[0] * 180.0/M_PI;
85  out[1] = in[1] * 180.0/M_PI;
86  out[2] = in[2];
87  return 0;
88  }
89 
90  inline int LonLat::inverse(const cartesian_t &in, cartesian_t &out) const {
91  out[0] = in[0] * M_PI/180.0;
92  out[1] = in[1] * M_PI/180.0;
93  out[2] = in[2];
94  return 0;
95  }
96 
98  class Geocent : public ProjectionBase {
99  public:
100  // Value constructor
101  Geocent() : ProjectionBase(4978) {}
102 
103  inline void print() const;
105  int forward(const cartesian_t& llh,cartesian_t& xyz) const;
106 
108  int inverse(const cartesian_t& xyz,cartesian_t& llh) const;
109  };
110 
111  inline void Geocent::print() const {
112  std::cout << "Projection: Geocent" << std::endl << "EPSG: " << code() << std::endl;
113  }
114 
119  class UTM : public ProjectionBase {
120  // Constants related to the projection system
121  double lon0;
122  int zone;
123  bool isnorth;
124  // Parameters from Proj.4
125  double cgb[6], cbg[6], utg[6], gtu[6];
126  double Qn, Zb;
127 
128  public:
129  // Value constructor
130  UTM(int);
131 
132  inline void print() const;
134  int forward(const cartesian_t& llh, cartesian_t& xyz) const;
135 
137  int inverse(const cartesian_t& xyz, cartesian_t& llh) const;
138  };
139 
140  inline void UTM::print() const {
141  std::cout << "Projection: UTM" << std::endl
142  << "Zone: " << zone << (isnorth ? "N" : "S") << std::endl
143  << "EPSG: " << code() << std::endl;
144  }
145 
150  class PolarStereo : public ProjectionBase {
151  // Constants related to projection system
152  double lat0, lon0, lat_ts, akm1, e;
153  bool isnorth;
154 
155  public:
156  // Value constructor
157  PolarStereo(int);
158 
159  inline void print() const;
161  int forward(const cartesian_t&,cartesian_t&) const;
162 
164  int inverse(const cartesian_t&,cartesian_t&) const;
165  };
166 
167  inline void PolarStereo::print() const {
168  std::cout << "Projection: " << (isnorth ? "North" : "South")
169  << " Polar Stereographic" << std::endl
170  << "EPSG: " << code() << std::endl;
171  }
172 
176  class CEA: public ProjectionBase {
177  // Constants related to projection system
178  double apa[3];
179  double lat_ts, k0, e, one_es, qp;
180 
181  public:
182  // Value constructor
183  CEA();
184 
185  inline void print() const;
186 
188  int forward(const cartesian_t& llh,cartesian_t& xyz) const;
189 
191  int inverse(const cartesian_t& xyz,cartesian_t& llh) const;
192  };
193 
194  inline void CEA::print() const {
195  std::cout << "Projection: Cylindrical Equal Area" << std::endl
196  << "EPSG: " << code() << std::endl;
197  }
198 
199  //This is to create a projection system from the EPSG code
200  ProjectionBase* createProj(int epsg);
201 
202  inline
203  std::unique_ptr<ProjectionBase> makeProjection(int epsg)
204  {
205  return std::unique_ptr<ProjectionBase>(createProj(epsg));
206  }
207 
208  // This is to transform a point from one coordinate system to another
209  int projTransform(ProjectionBase* in, ProjectionBase *out, const Vec3& inpts,
210  Vec3& outpts);
211 }}
Polar stereographic extension of ProjBase.
Definition: Projections.h:150
int code() const
Return EPSG code.
Definition: Projections.h:37
UTM coordinate extension of ProjBase.
Definition: Projections.h:119
Data structure to store Ellipsoid information.
Definition: Ellipsoid.h:20
int forward(const cartesian_t &llh, cartesian_t &xyz) const
Transform from llh (rad) to CEA (m)
Definition: Projections.cpp:336
int inverse(const cartesian_t &, cartesian_t &) const
Function for transforming to LLH.
Definition: Projections.h:90
void print() const
Print function for debugging.
Definition: Projections.h:194
Equal Area Projection extension of ProjBase.
Definition: Projections.h:176
ProjectionBase(int code)
Value constructor with EPSG code as input.
Definition: Projections.h:34
int forward(const cartesian_t &, cartesian_t &) const
Function for transforming from LLH.
Definition: Projections.h:83
virtual int forward(const cartesian_t &llh, cartesian_t &xyz) const =0
Function for transforming from LLH.
virtual void print() const =0
Print function for debugging.
int forward(const cartesian_t &llh, cartesian_t &xyz) const
Transform from llh (rad) to UTM (m)
Definition: Projections.cpp:170
Abstract base class for individual projections.
Definition: Projections.h:22
virtual int inverse(const cartesian_t &xyz, cartesian_t &llh) const =0
Function for transforming to LLH.
Standard WGS84 Lon/Lat Projection extension of ProjBase - EPSG:4326.
Definition: Projections.h:67
const Ellipsoid & ellipsoid() const
Return underlying ellipsoid.
Definition: Projections.h:40
virtual ~ProjectionBase()
Virtual destructor.
Definition: Projections.h:63
int inverse(const cartesian_t &xyz, cartesian_t &llh) const
This is same as Ellipsoid::xyzToLonLat.
Definition: Projections.cpp:35
Standard WGS84 ECEF coordinates extension of ProjBase - EPSG:4978.
Definition: Projections.h:98
void print() const
Print function for debugging.
Definition: Projections.h:79
int inverse(const cartesian_t &xyz, cartesian_t &llh) const
Transform from UTM(m) to llh (rad)
Definition: Projections.cpp:200
void print() const
Print function for debugging.
Definition: Projections.h:140
int forward(const cartesian_t &, cartesian_t &) const
Transfrom from llh(rad) to Polar Stereo (m)
Definition: Projections.cpp:273
int forward(const cartesian_t &llh, cartesian_t &xyz) const
This is same as Ellipsoid::lonLatToXyz.
Definition: Projections.cpp:25
void print() const
Print function for debugging.
Definition: Projections.h:111
void print() const
Print function for debugging.
Definition: Projections.h:167
int inverse(const cartesian_t &xyz, cartesian_t &llh) const
Transform from CEA (m) to LLH (rad)
Definition: Projections.cpp:346
int inverse(const cartesian_t &, cartesian_t &) const
Transform from Polar Stereo (m) to llh (rad)
Definition: Projections.cpp:289

Generated for ISCE3.0 by doxygen 1.8.5.