diff --git a/CoordGeodetic.cpp b/CoordGeodetic.cpp index 9580d9a..151b557 100644 --- a/CoordGeodetic.cpp +++ b/CoordGeodetic.cpp @@ -1,5 +1,8 @@ #include "CoordGeodetic.h" +#include +#include + CoordGeodetic::CoordGeodetic(const CoordGeodetic& b) { latitude = b.latitude; @@ -39,3 +42,13 @@ bool CoordGeodetic::operator !=(const CoordGeodetic& b) const { 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) << geo.latitude; + out << ", Lon: " << std::setw(7) << geo.longitude; + out << ", Alt: " << std::setw(9) << geo.altitude; + stream << out.str(); + return stream; +} diff --git a/CoordGeodetic.h b/CoordGeodetic.h index 50a22db..5060fb4 100644 --- a/CoordGeodetic.h +++ b/CoordGeodetic.h @@ -1,6 +1,8 @@ #ifndef COORDGEODETIC_H_ #define COORDGEODETIC_H_ +#include + struct CoordGeodetic { public: @@ -24,6 +26,8 @@ public: 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) */ diff --git a/CoordTopographic.cpp b/CoordTopographic.cpp index 8e3b6cb..0cc6ac1 100644 --- a/CoordTopographic.cpp +++ b/CoordTopographic.cpp @@ -1,5 +1,8 @@ #include "CoordTopographic.h" +#include +#include + CoordTopographic::CoordTopographic(const CoordTopographic& b) { azimuth = b.azimuth; @@ -44,6 +47,15 @@ bool CoordTopographic::operator !=(const CoordTopographic& b) const { } } - +std::ostream& operator<< (std::ostream& stream, const CoordTopographic& topo) { + std::stringstream out; + out << std::right << std::fixed << std::setprecision(2); + out << "Az: " << std::setw(7) << topo.azimuth; + out << ", El: " << std::setw(7) << topo.elevation; + out << ", Range: " << std::setw(9) << topo.range; + out << ", RangeRate: " << std::setw(6) << topo.range_rate; + stream << out.str(); + return stream; +} diff --git a/CoordTopographic.h b/CoordTopographic.h index 8cfbd68..2004159 100644 --- a/CoordTopographic.h +++ b/CoordTopographic.h @@ -1,6 +1,8 @@ #ifndef COORDTOPOGRAPHIC_H_ #define COORDTOPOGRAPHIC_H_ +#include + struct CoordTopographic { public: @@ -20,6 +22,8 @@ public: CoordTopographic & operator =(const CoordTopographic& b); bool operator ==(const CoordTopographic& b) const; bool operator !=(const CoordTopographic& b) const; + + friend std::ostream& operator<< (std::ostream& stream, const CoordTopographic& topo); /* * radians