GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GWcsGLS.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GWcsGLS.cpp - Global Sinusoidal (GLS) projection class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2017-2018 by Juergen Knoedlseder *
5  * ----------------------------------------------------------------------- *
6  * *
7  * This program is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19  * *
20  ***************************************************************************/
21 /**
22  * @file GWcsGLS.cpp
23  * @brief Global Sinusoidal (GLS) projection class implementation
24  * @author Juergen Knoedlseder
25  */
26 
27 /* __ Includes ___________________________________________________________ */
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 #include "GException.hpp"
32 #include "GMath.hpp"
33 #include "GWcsGLS.hpp"
34 #include "GWcsRegistry.hpp"
35 
36 /* __ Method name definitions ____________________________________________ */
37 
38 /* __ Macros _____________________________________________________________ */
39 
40 /* __ Coding definitions _________________________________________________ */
41 
42 /* __ Debug definitions __________________________________________________ */
43 
44 /* __ Local prototypes ___________________________________________________ */
45 
46 /* __ Constants __________________________________________________________ */
47 
48 /* __ Globals ____________________________________________________________ */
50 const GWcsRegistry g_wcs_gls_registry(&g_wcs_gls_seed);
51 
52 
53 /*==========================================================================
54  = =
55  = Constructors/destructors =
56  = =
57  ==========================================================================*/
58 
59 /***********************************************************************//**
60  * @brief Void constructor
61  ***************************************************************************/
63 {
64  // Initialise class members
65  init_members();
66 
67  // Return
68  return;
69 }
70 
71 
72 /***********************************************************************//**
73  * @brief Projection constructor
74  *
75  * @param[in] coords Coordinate system.
76  * @param[in] crval1 X value of reference pixel.
77  * @param[in] crval2 Y value of reference pixel.
78  * @param[in] crpix1 X index of reference pixel (starting from 1).
79  * @param[in] crpix2 Y index of reference pixel (starting from 1).
80  * @param[in] cdelt1 Increment in x direction at reference pixel [deg].
81  * @param[in] cdelt2 Increment in y direction at reference pixel [deg].
82  ***************************************************************************/
83 GWcsGLS::GWcsGLS(const std::string& coords,
84  const double& crval1, const double& crval2,
85  const double& crpix1, const double& crpix2,
86  const double& cdelt1, const double& cdelt2) :
87  GWcsSFL(coords, crval1, crval2, crpix1, crpix2, cdelt1, cdelt2)
88 {
89  // Initialise class members
90  init_members();
91 
92  // Setup WCS derived parameters
93  wcs_set();
94 
95  // Return
96  return;
97 }
98 
99 
100 /***********************************************************************//**
101  * @brief Copy constructor
102  *
103  * @param[in] wcs World Coordinate System.
104  ***************************************************************************/
105 GWcsGLS::GWcsGLS(const GWcsGLS& wcs) : GWcsSFL(wcs)
106 {
107  // Initialise class members for clean destruction
108  init_members();
109 
110  // Copy members
111  copy_members(wcs);
112 
113  // Return
114  return;
115 }
116 
117 
118 /***********************************************************************//**
119  * @brief Destructor
120  ***************************************************************************/
122 {
123  // Free members
124  free_members();
125 
126  // Return
127  return;
128 }
129 
130 
131 /*==========================================================================
132  = =
133  = Operators =
134  = =
135  ==========================================================================*/
136 
137 /***********************************************************************//**
138  * @brief Assignment operator
139  *
140  * @param[in] wcs World Coordinate System.
141  * @return World Coordinate System.
142  ***************************************************************************/
144 {
145  // Execute only if object is not identical
146  if (this != &wcs) {
147 
148  // Copy base class members
149  this->GWcsSFL::operator=(wcs);
150 
151  // Free members
152  free_members();
153 
154  // Initialise private members for clean destruction
155  init_members();
156 
157  // Copy members
158  copy_members(wcs);
159 
160  } // endif: object was not identical
161 
162  // Return this object
163  return *this;
164 }
165 
166 
167 /*==========================================================================
168  = =
169  = Public methods =
170  = =
171  ==========================================================================*/
172 
173 /***********************************************************************//**
174  * @brief Clear Global Sinusoidal projection
175  *
176  * Resets the Global Sinusoidal projection to an clean initial state.
177  ***************************************************************************/
178 void GWcsGLS::clear(void)
179 {
180  // Free class members (base and derived classes, derived class first)
181  free_members();
182  this->GWcsSFL::free_members();
183  this->GWcs::free_members();
185 
186  // Initialise members
188  this->GWcs::init_members();
189  this->GWcsSFL::init_members();
190  init_members();
191 
192  // Return
193  return;
194 }
195 
196 
197 /***********************************************************************//**
198  * @brief Clone Global Sinusoidal projection
199  *
200  * @return Pointer to deep copy of Global Sinusoidal projection.
201  ***************************************************************************/
203 {
204  return new GWcsGLS(*this);
205 }
206 
207 
208 /***********************************************************************//**
209  * @brief Print Global Sinusoidal projection information
210  *
211  * @param[in] chatter Chattiness.
212  * @return String containing Global Sinusoidal projection information.
213  ***************************************************************************/
214 std::string GWcsGLS::print(const GChatter& chatter) const
215 {
216  // Initialise result string
217  std::string result;
218 
219  // Continue only if chatter is not silent
220  if (chatter != SILENT) {
221 
222  // Append header
223  result.append("=== GWcsGLS ===");
224 
225  // Append information
226  result.append(wcs_print(chatter));
227 
228  } // endif: chatter was not silent
229 
230  // Return result
231  return result;
232 }
233 
234 
235 /*==========================================================================
236  = =
237  = Private methods =
238  = =
239  ==========================================================================*/
240 
241 /***********************************************************************//**
242  * @brief Initialise class members
243  ***************************************************************************/
245 {
246  // Return
247  return;
248 }
249 
250 
251 /***********************************************************************//**
252  * @brief Copy class members
253  *
254  * @param[in] wcs World Coordinate System.
255  ***************************************************************************/
257 {
258  // Return
259  return;
260 }
261 
262 
263 /***********************************************************************//**
264  * @brief Delete class members
265  ***************************************************************************/
267 {
268  // Return
269  return;
270 }
virtual GWcsGLS * clone(void) const
Clone Global Sinusoidal projection.
Definition: GWcsGLS.cpp:202
void init_members(void)
Initialise class members.
Definition: GWcs.cpp:949
GWcsGLS(void)
Void constructor.
Definition: GWcsGLS.cpp:62
Interface definition for the WCS registry class.
void init_members(void)
Initialise class members.
Definition: GWcsSFL.cpp:244
Global Sinusoidal (GLS) projection class definition.
GWcsGLS & operator=(const GWcsGLS &wcs)
Assignment operator.
Definition: GWcsGLS.cpp:143
void free_members(void)
Delete class members.
Definition: GWcs.cpp:1053
void copy_members(const GWcsGLS &wcs)
Copy class members.
Definition: GWcsGLS.cpp:256
Sanson-Flamsteed (SFL) projection class definition.
Definition: GWcsSFL.hpp:43
World Coordinate Projection registry class interface definition.
void wcs_set(void) const
Setup of World Coordinate System.
Definition: GWcs.cpp:1249
virtual ~GWcsGLS(void)
Destructor.
Definition: GWcsGLS.cpp:121
const GWcsGLS g_wcs_gls_seed
Definition: GWcsGLS.cpp:49
GChatter
Definition: GTypemaps.hpp:33
std::string wcs_print(const GChatter &chatter=NORMAL) const
Print WCS information.
Definition: GWcs.cpp:1602
GWcsSFL & operator=(const GWcsSFL &wcs)
Assignment operator.
Definition: GWcsSFL.cpp:145
void free_members(void)
Delete class members.
virtual void clear(void)
Clear Global Sinusoidal projection.
Definition: GWcsGLS.cpp:178
Global Sinusoidal (GLS) projection class definition.
Definition: GWcsGLS.hpp:45
void init_members(void)
Initialise class members.
Definition: GWcsGLS.cpp:244
Exception handler interface definition.
void init_members(void)
Initialise class members.
void free_members(void)
Delete class members.
Definition: GWcsGLS.cpp:266
void free_members(void)
Delete class members.
Definition: GWcsSFL.cpp:266
virtual std::string print(const GChatter &chatter=NORMAL) const
Print Global Sinusoidal projection information.
Definition: GWcsGLS.cpp:214
Mathematical function definitions.