Updated CoordGeodetic
parent
01f34d0529
commit
74ac17ff42
|
@ -1,56 +0,0 @@
|
|||
#include "CoordGeodetic.h"
|
||||
|
||||
#include "Globals.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
CoordGeodetic::CoordGeodetic(const CoordGeodetic& b) {
|
||||
|
||||
latitude = b.latitude;
|
||||
longitude = b.longitude;
|
||||
altitude = b.altitude;
|
||||
}
|
||||
|
||||
CoordGeodetic& CoordGeodetic::operator =(const CoordGeodetic& b) {
|
||||
|
||||
if (this != &b) {
|
||||
latitude = b.latitude;
|
||||
longitude = b.longitude;
|
||||
altitude = b.altitude;
|
||||
}
|
||||
|
||||
return (*this);
|
||||
}
|
||||
|
||||
bool CoordGeodetic::operator ==(const CoordGeodetic& b) const {
|
||||
|
||||
if (latitude == b.latitude &&
|
||||
longitude == b.longitude &&
|
||||
altitude == b.altitude) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CoordGeodetic::operator !=(const CoordGeodetic& b) const {
|
||||
|
||||
if (latitude == b.latitude &&
|
||||
longitude == b.longitude &&
|
||||
altitude == b.altitude) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
std::ostream& operator<< (std::ostream& stream, const CoordGeodetic& geo) {
|
||||
std::stringstream out;
|
||||
out << std::right << std::fixed << std::setprecision(2);
|
||||
out << "Lat: " << std::setw(7) << RadiansToDegrees(geo.latitude);
|
||||
out << ", Lon: " << std::setw(7) << RadiansToDegrees(geo.longitude);
|
||||
out << ", Alt: " << std::setw(9) << geo.altitude;
|
||||
stream << out.str();
|
||||
return stream;
|
||||
}
|
|
@ -1,33 +1,70 @@
|
|||
#ifndef COORDGEODETIC_H_
|
||||
#define COORDGEODETIC_H_
|
||||
|
||||
#include <iostream>
|
||||
#include "Globals.h"
|
||||
|
||||
struct CoordGeodetic {
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
struct CoordGeodetic
|
||||
{
|
||||
public:
|
||||
|
||||
CoordGeodetic()
|
||||
: latitude(0.0), longitude(0.0), altitude(0.0) {
|
||||
: latitude(0.0), longitude(0.0), altitude(0.0)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* radians
|
||||
*/
|
||||
CoordGeodetic(double lat, double lon, double alt)
|
||||
: latitude(lat), longitude(lon), altitude(alt) {
|
||||
: latitude(lat), longitude(lon), altitude(alt)
|
||||
{
|
||||
}
|
||||
|
||||
CoordGeodetic(const CoordGeodetic& g);
|
||||
CoordGeodetic(const CoordGeodetic& g)
|
||||
{
|
||||
latitude = g.latitude;
|
||||
longitude = g.longitude;
|
||||
altitude = g.altitude;
|
||||
}
|
||||
|
||||
virtual ~CoordGeodetic() {
|
||||
};
|
||||
virtual ~CoordGeodetic()
|
||||
{
|
||||
}
|
||||
|
||||
CoordGeodetic& operator=(const CoordGeodetic& g)
|
||||
{
|
||||
if (this != &g)
|
||||
{
|
||||
latitude = g.latitude;
|
||||
longitude = g.longitude;
|
||||
altitude = g.altitude;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(const CoordGeodetic& g) const
|
||||
{
|
||||
return IsEqual(g);
|
||||
}
|
||||
|
||||
bool operator!=(const CoordGeodetic& g) const
|
||||
{
|
||||
return !IsEqual(g);
|
||||
}
|
||||
|
||||
std::string ToString() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << std::right << std::fixed << std::setprecision(2);
|
||||
ss << "Lat: " << std::setw(6) << RadiansToDegrees(latitude);
|
||||
ss << ", Lon: " << std::setw(7) << RadiansToDegrees(longitude);
|
||||
ss << ", Alt: " << std::setw(9) << altitude;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
CoordGeodetic & operator =(const CoordGeodetic& b);
|
||||
bool operator ==(const CoordGeodetic& b) const;
|
||||
bool operator !=(const CoordGeodetic& b) const;
|
||||
|
||||
friend std::ostream& operator<< (std::ostream& stream, const CoordGeodetic& geo);
|
||||
|
||||
/*
|
||||
* radians (north positive, south negative)
|
||||
*/
|
||||
|
@ -40,7 +77,26 @@ public:
|
|||
* kilometers
|
||||
*/
|
||||
double altitude;
|
||||
|
||||
protected:
|
||||
bool IsEqual(const CoordGeodetic& g) const
|
||||
{
|
||||
if (latitude == g.latitude && longitude == g.longitude &&
|
||||
altitude == g.altitude)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& strm, const CoordGeodetic& g)
|
||||
{
|
||||
return strm << g.ToString();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue