sgp4/CoordGeodetic.h

103 lines
2.0 KiB
C
Raw Normal View History

2011-04-23 11:18:51 +00:00
#ifndef COORDGEODETIC_H_
#define COORDGEODETIC_H_
2011-12-13 21:23:43 +00:00
#include "Globals.h"
2011-12-13 21:23:43 +00:00
#include <string>
#include <sstream>
#include <iomanip>
2011-04-23 11:18:51 +00:00
2011-12-13 21:23:43 +00:00
struct CoordGeodetic
{
public:
2011-04-23 11:18:51 +00:00
CoordGeodetic()
2011-12-13 21:23:43 +00:00
: latitude(0.0), longitude(0.0), altitude(0.0)
{
2011-04-23 11:18:51 +00:00
}
/*
* radians
*/
2011-05-26 23:10:31 +00:00
CoordGeodetic(double lat, double lon, double alt)
2011-12-13 21:23:43 +00:00
: latitude(lat), longitude(lon), altitude(alt)
{
}
CoordGeodetic(const CoordGeodetic& g)
{
latitude = g.latitude;
longitude = g.longitude;
altitude = g.altitude;
2011-04-23 11:18:51 +00:00
}
2011-12-13 21:23:43 +00:00
virtual ~CoordGeodetic()
{
}
CoordGeodetic& operator=(const CoordGeodetic& g)
{
if (this != &g)
{
latitude = g.latitude;
longitude = g.longitude;
altitude = g.altitude;
}
return *this;
}
2011-04-23 11:18:51 +00:00
2011-12-13 21:23:43 +00:00
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();
}
2011-04-23 11:18:51 +00:00
/*
* radians (north positive, south negative)
*/
2011-05-26 23:10:31 +00:00
double latitude;
2011-04-23 11:18:51 +00:00
/*
* radians (east positive, west negative)
*/
2011-05-26 23:10:31 +00:00
double longitude;
2011-04-23 11:18:51 +00:00
/*
* kilometers
*/
2011-05-26 23:10:31 +00:00
double altitude;
2011-12-13 21:23:43 +00:00
protected:
bool IsEqual(const CoordGeodetic& g) const
{
if (latitude == g.latitude && longitude == g.longitude &&
altitude == g.altitude)
{
return false;
}
else
{
return true;
}
}
2011-04-23 11:18:51 +00:00
};
2011-12-13 21:23:43 +00:00
inline std::ostream& operator<<(std::ostream& strm, const CoordGeodetic& g)
{
return strm << g.ToString();
}
2011-04-23 11:18:51 +00:00
#endif