Print out topo and geo struct to stream

feature/19
Daniel Warner 2011-05-27 01:37:10 +01:00
parent 5694ce1ffc
commit 4be78ea488
4 changed files with 34 additions and 1 deletions

View File

@ -1,5 +1,8 @@
#include "CoordGeodetic.h"
#include <sstream>
#include <iomanip>
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;
}

View File

@ -1,6 +1,8 @@
#ifndef COORDGEODETIC_H_
#define COORDGEODETIC_H_
#include <iostream>
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)
*/

View File

@ -1,5 +1,8 @@
#include "CoordTopographic.h"
#include <sstream>
#include <iomanip>
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;
}

View File

@ -1,6 +1,8 @@
#ifndef COORDTOPOGRAPHIC_H_
#define COORDTOPOGRAPHIC_H_
#include <iostream>
struct CoordTopographic {
public:
@ -21,6 +23,8 @@ public:
bool operator ==(const CoordTopographic& b) const;
bool operator !=(const CoordTopographic& b) const;
friend std::ostream& operator<< (std::ostream& stream, const CoordTopographic& topo);
/*
* radians
*/