Added some assignment/equality operators to Coord classes

feature/19
Daniel Warner 2011-04-09 19:50:25 +01:00
parent 490f3093ce
commit 9e89b87d31
2 changed files with 105 additions and 7 deletions

View File

@ -1,5 +1,88 @@
#include "Coord.h" #include "Coord.h"
CoordGeodetic::CoordGeodetic(const CoordGeodetic& b) {
lat_ = b.lat_;
lon_ = b.lon_;
alt_ = b.alt_;
}
CoordGeodetic& CoordGeodetic::operator =(const CoordGeodetic& b) {
if (this != &b) {
lat_ = b.lat_;
lon_ = b.lon_;
alt_ = b.alt_;
}
return (*this);
}
bool CoordGeodetic::operator ==(const CoordGeodetic& b) const {
if (lat_ == b.lat_ &&
lon_ == b.lon_ &&
alt_ == b.alt_) {
return true;
} else {
return false;
}
}
bool CoordGeodetic::operator !=(const CoordGeodetic& b) const {
if (lat_ == b.lat_ &&
lon_ == b.lon_ &&
alt_ == b.alt_) {
return false;
} else {
return true;
}
}
CoordTopographic::CoordTopographic(const CoordTopographic& b) {
azimuth_ = b.azimuth_;
elevation_ = b.elevation_;
range_ = b.range_;
range_rate_ = b.range_rate_;
}
CoordTopographic& CoordTopographic::operator =(const CoordTopographic& b) {
if (this != &b) {
azimuth_ = b.azimuth_;
elevation_ = b.elevation_;
range_ = b.range_;
range_rate_ = b.range_rate_;
}
return (*this);
}
bool CoordTopographic::operator ==(const CoordTopographic& b) const {
if (azimuth_ == b.azimuth_ &&
elevation_ == b.elevation_ &&
range_ == b.range_ &&
range_rate_ == b.range_rate_) {
return true;
} else {
return false;
}
}
bool CoordTopographic::operator !=(const CoordTopographic& b) const {
if (azimuth_ == b.azimuth_ &&
elevation_ == b.elevation_ &&
range_ == b.range_ &&
range_rate_ == b.range_rate_) {
return false;
} else {
return true;
}
}

29
Coord.h
View File

@ -8,22 +8,31 @@ public:
: lat_(0.0), lon_(0.0), alt_(0.0) { : lat_(0.0), lon_(0.0), alt_(0.0) {
} }
/*
* radians
*/
CoordGeodetic(double latitude, double longitude, double altitude) CoordGeodetic(double latitude, double longitude, double altitude)
: lat_(latitude), lon_(longitude), alt_(altitude) { : lat_(latitude), lon_(longitude), alt_(altitude) {
} }
CoordGeodetic(const CoordGeodetic& g);
virtual ~CoordGeodetic() { virtual ~CoordGeodetic() {
}; };
void SetLatitude(const double& latitude) { CoordGeodetic & operator =(const CoordGeodetic& b);
bool operator ==(const CoordGeodetic& b) const;
bool operator !=(const CoordGeodetic& b) const;
void SetLatitude(const double latitude) {
lat_ = latitude; lat_ = latitude;
} }
void SetLongitude(const double& longitude) { void SetLongitude(const double longitude) {
lon_ = longitude; lon_ = longitude;
} }
void SetAltitude(const double& altitude) { void SetAltitude(const double altitude) {
alt_ = altitude; alt_ = altitude;
} }
@ -65,22 +74,28 @@ public:
: azimuth_(azimuth), elevation_(elevation), range_(range), range_rate_(range_rate) { : azimuth_(azimuth), elevation_(elevation), range_(range), range_rate_(range_rate) {
} }
CoordTopographic(const CoordTopographic& b);
virtual ~CoordTopographic() { virtual ~CoordTopographic() {
}; };
void SetAzimuth(const double& azimuth) { CoordTopographic & operator =(const CoordTopographic& b);
bool operator ==(const CoordTopographic& b) const;
bool operator !=(const CoordTopographic& b) const;
void SetAzimuth(const double azimuth) {
azimuth_ = azimuth; azimuth_ = azimuth;
} }
void SetElevation(const double& elevation) { void SetElevation(const double elevation) {
elevation_ = elevation; elevation_ = elevation;
} }
void SetRange(const double& range) { void SetRange(const double range) {
range_ = range; range_ = range;
} }
void SetRangeRate(const double& range_rate) { void SetRangeRate(const double range_rate) {
range_rate_ = range_rate; range_rate_ = range_rate;
} }