CppEphem
CEObservation.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * CEObservation.cpp: CppEphem *
3  * ----------------------------------------------------------------------- *
4  * Copyright © 2016-2019 JCardenzana *
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 
29 #include <stdio.h>
30 
31 #include "CEObservation.h"
32 
33 
34 /**********************************************************************/
38 {
39  init_members();
40 }
41 
42 /**********************************************************************/
50 {
51  init_members();
52 
53  // Set the objects
54  SetObserver(observer);
55  SetBody(body);
56  SetDate(date);
57 }
58 
59 
60 /**********************************************************************/
66 {
67  init_members();
68  copy_members(other);
69 }
70 
71 
72 /**********************************************************************/
76 {
77  free_members();
78 }
79 
80 
81 /**********************************************************************/
88 {
89  if (this != &other) {
90  free_members();
91  init_members();
92  copy_members(other);
93  }
94  return *this;
95 }
96 
97 
98 /**********************************************************************/
106 void CEObservation::GetAzimuthZenith_Rad(double *azimuth, double *zenith)
107 {
108  *azimuth = GetAzimuth_Rad() ;
109  *zenith = GetZenith_Rad() ;
110 }
111 
112 /**********************************************************************/
120 void CEObservation::GetAzimuthZenith_Deg(double *azimuth, double *zenith)
121 {
122  GetAzimuthZenith_Rad(azimuth, zenith) ;
123  *azimuth *= DR2D ;
124  *zenith *= DR2D ;
125 }
126 
127 /**********************************************************************/
136 void CEObservation::GetApparentXYCoordinate_Rad(double *apparent_X, double *apparent_Y)
137 {
138  *apparent_X = GetApparentXCoordinate_Rad() ;
139  *apparent_Y = cached_apparentycoord_ ;
140 }
141 
142 /**********************************************************************/
151 void CEObservation::GetApparentXYCoordinate_Deg(double *apparent_X, double *apparent_Y)
152 {
153  GetApparentXYCoordinate_Rad(apparent_X, apparent_Y) ;
154  *apparent_X *= DR2D ;
155  *apparent_Y *= DR2D ;
156 }
157 
158 
159 /**********************************************************************/
165 {
166  if (NeedsUpdate()) {
167  // Get the coordinates and date
169  cached_date_ = *date_;
170  }
171  return true ;
172 }
173 
174 
175 /**********************************************************************/
181 {
182  // Copy the pointers (this object does not own them)
183  body_ = other.body_;
184  date_ = other.date_;
185  observer_ = other.observer_;
186 
187  // Copy the cached values
188  cached_date_ = other.cached_date_;
193 }
194 
195 
196 /**********************************************************************/
200 {
201  // Copy the pointers (this object does not own them)
202  body_ = nullptr;
203  date_ = nullptr;
204  observer_ = nullptr;
205 
206  // Copy the cached values
207  cached_date_ = 0.0;
209 
210  // Note that these are not filled at the moment
211  cached_hour_angle_ = 0.0;
214 }
215 
216 
217 /**********************************************************************/
221 {
222  // This object is not responsible for its objects
223 }
224 
225 
226 /**********************************************************************/
232 {
233  // Make sure the date object isnt nullptr
234  if (date_ == nullptr) {
235  return false ;
236  }
237  // Check if the date object has changed since the last time we querried it
238  else if ((*date_) != cached_date_) {
239  return true ;
240  }
241  // Otherwise we want to return false
242  else {
243  return false ;
244  }
245 }
CEObservation::observer_
CEObserver * observer_
Definition: CEObservation.h:101
CEObservation::date_
CEDate * date_
Definition: CEObservation.h:100
CEObservation::operator=
CEObservation & operator=(const CEObservation &other)
Copy assignment operator.
Definition: CEObservation.cpp:86
CEObservation::SetObserver
virtual void SetObserver(CEObserver *new_observer)
Set underlying CEObserver object.
Definition: CEObservation.h:135
CEObservation::GetApparentXCoordinate_Rad
virtual double GetApparentXCoordinate_Rad()
Definition: CEObservation.h:250
CEObservation::free_members
void free_members(void)
Deallocate memory.
Definition: CEObservation.cpp:219
CEDate
Definition: CEDate.h:43
CEObservation::GetAzimuthZenith_Deg
virtual void GetAzimuthZenith_Deg(double *azimuth, double *zenith)
Returns both the azimuth and zenith angle of a given 'body_' as observed by 'observer_' on the date g...
Definition: CEObservation.cpp:119
CEObservation::cached_apparentycoord_
double cached_apparentycoord_
Definition: CEObservation.h:112
CESkyCoord
Definition: CESkyCoord.h:49
CEObservation::init_members
void init_members(void)
Initialize the data members.
Definition: CEObservation.cpp:198
CEObservation::~CEObservation
virtual ~CEObservation()
Destructor.
Definition: CEObservation.cpp:74
CEObservation::GetApparentXYCoordinate_Deg
virtual void GetApparentXYCoordinate_Deg(double *apparent_X, double *apparent_Y)
Returns both the observed x,y coordinates of a given 'body_' as observed by 'observer_' on the date g...
Definition: CEObservation.cpp:150
CEObservation::UpdateCoordinates
bool UpdateCoordinates()
Update the stored coordinates.
Definition: CEObservation.cpp:163
CEObservation::cached_date_
double cached_date_
Definition: CEObservation.h:106
CEObservation::CEObservation
CEObservation()
Default constructor.
Definition: CEObservation.cpp:36
CEBody::ObservedCoords
virtual CESkyCoord ObservedCoords(const CEDate &date, const CEObserver &observer) const
Computes the observed coordinates for this object based.
Definition: CEBody.cpp:129
CEObservation.h
CEObservation::NeedsUpdate
bool NeedsUpdate(void)
Check whether the date has changed since the last time all of the parameters were updated (i....
Definition: CEObservation.cpp:230
CEObservation::copy_members
void copy_members(const CEObservation &other)
Copy data members from another object.
Definition: CEObservation.cpp:179
CEObservation::cached_apparentxcoord_
double cached_apparentxcoord_
Definition: CEObservation.h:111
CEObservation::GetAzimuth_Rad
virtual double GetAzimuth_Rad()
Definition: CEObservation.h:167
CEObservation::cached_coords_
CESkyCoord cached_coords_
Definition: CEObservation.h:107
CEObservation::GetAzimuthZenith_Rad
virtual void GetAzimuthZenith_Rad(double *azimuth, double *zenith)
Returns both the azimuth and zenith angle of a given 'body_' as observed by 'observer_' on the date g...
Definition: CEObservation.cpp:105
CEObserver
Definition: CEObserver.h:28
CEObservation
Definition: CEObservation.h:33
CEObservation::cached_hour_angle_
double cached_hour_angle_
Definition: CEObservation.h:110
CEBody
Definition: CEBody.h:39
CEObservation::SetBody
virtual void SetBody(CEBody *new_body)
Set underlying CEBody object.
Definition: CEObservation.h:146
CEObservation::GetZenith_Rad
virtual double GetZenith_Rad()
Definition: CEObservation.h:188
CEObservation::body_
CEBody * body_
Definition: CEObservation.h:99
CEObservation::SetDate
virtual void SetDate(CEDate *new_date)
Set underlying CEDate object.
Definition: CEObservation.h:157
CEObservation::GetApparentXYCoordinate_Rad
virtual void GetApparentXYCoordinate_Rad(double *apparent_X, double *apparent_Y)
Returns both the observed x,y coordinates of a given 'body_' as observed by 'observer_' on the date g...
Definition: CEObservation.cpp:135