// Metar station implementation code
+#include <simgear/compiler.h>
+
+#include STL_IOSTREAM
#include <stdio.h>
#include "MetarStation.h"
#include <algorithm>
-#include <simgear/misc/fgpath.hxx>
+SG_USING_STD(ostream);
+SG_USING_STD(cout);
+SG_USING_STD(endl);
double CMetarStation::decodeDMS( char *b )
// Direction (E W N S)
if ( *b == 'W' || *b == 'S' ) r = -r;
}
- return r * DEG_TO_RAD;
+ return r * SGD_DEGREES_TO_RADIANS;
}
// Constructor
s = t; t = strchr( s, ';' ); *t = 0; t++;
double ulongitude = decodeDMS( s );
s = t; t = strchr( s, ';' ); *t = 0; t++;
- double altitude = atoi( s ) * FEET_TO_METER;
- m_altitude = altitude;
+ double altitude = atoi( s ) * SG_FEET_TO_METER;
+ m_altitude = (int)altitude;
s = t; t = strchr( s, ';' ); *t = 0; t++;
- double ualtitude = atoi( s ) * FEET_TO_METER;
- Point3D p( longitude, latitude, altitude+EQUATORIAL_RADIUS_M );
+ double ualtitude = atoi( s ) * SG_FEET_TO_METER;
+ Point3D p( longitude, latitude, altitude+SG_EQUATORIAL_RADIUS_M );
m_locationPolar = p;
m_locationCart = sgPolarToCart3d( p );
- Point3D up( ulongitude, ulatitude, ualtitude+EQUATORIAL_RADIUS_M );
+ Point3D up( ulongitude, ulatitude, ualtitude+SG_EQUATORIAL_RADIUS_M );
m_upperLocationPolar = up;
m_upperLocationCart = sgPolarToCart3d( up );
s = t;
void CMetarStation::dump()
{
- std::cout << "ID:" << ID();
- std::cout << std::endl;
- std::cout << "number:" << number();
- std::cout << std::endl;
- std::cout << "name:" << name();
- std::cout << std::endl;
- std::cout << "state:" << state();
- std::cout << std::endl;
- std::cout << "country:" << country();
- std::cout << std::endl;
- std::cout << "region:" << region();
- std::cout << std::endl;
- std::cout << "Location (cart):" << locationCart();
- std::cout << std::endl;
- std::cout << "Location (polar):" << locationPolar();
- std::cout << std::endl;
- std::cout << "Upper Location (cart):" << upperLocationCart();
- std::cout << std::endl;
- std::cout << "Upper Location (polar):" << upperLocationPolar();
- std::cout << std::endl;
- std::cout << "P flag:" << pFlag();
- std::cout << std::endl;
+ cout << "ID:" << ID();
+ cout << endl;
+ cout << "number:" << number();
+ cout << endl;
+ cout << "name:" << name();
+ cout << endl;
+ cout << "state:" << state();
+ cout << endl;
+ cout << "country:" << country();
+ cout << endl;
+ cout << "region:" << region();
+ cout << endl;
+ cout << "Location (cart):" << locationCart();
+ cout << endl;
+ cout << "Location (polar):" << locationPolar();
+ cout << endl;
+ cout << "Upper Location (cart):" << upperLocationCart();
+ cout << endl;
+ cout << "Upper Location (polar):" << upperLocationPolar();
+ cout << endl;
+ cout << "P flag:" << pFlag();
+ cout << endl;
}
if ( f != NULL ) {
// Read each line, create an instance of a station, and add it to the vector
while ( fgets( buf, 256, f) != NULL && feof( f ) == 0 ) {
- //std::cout << buf << std::endl;
+ // cout << buf << endl;
m = new CMetarStation( buf );
//m->dump();
METAR_Stations[m->ID()]=( m );
// Close the list
fclose( f );
- // std::cout << METAR_Stations.size() << " Metar stations" << std::endl;
+ // cout << METAR_Stations.size() << " Metar stations" << endl;
} else {
- // std::cout << "Could not open MetarStations file " << std::endl;
+ // cout << "Could not open MetarStations file " << endl;
}
}
{
std::map<std::string,CMetarStation*>::iterator itr;
double bestDist = 99999999;
- CMetarStation * bestStation;
+ CMetarStation *bestStation = NULL;
Point3D curLocation = locationCart;
itr = METAR_Stations.begin();
while(itr != METAR_Stations.end())
}
}
-std::ostream&
+ostream&
operator << ( ostream& out, const CMetarStation& p )
{
return out
- << "ID:" << p.m_ID << std::endl
- << "number:" << p.m_number << std::endl
- << "name:" << p.m_name << std::endl
- << "state:" << p.m_state << std::endl
- << "country:" << p.m_country << std::endl
- << "region:" << p.m_region << std::endl
- << "Location (cart):" << p.m_locationCart << std::endl
- << "Location (polar):" << p.m_locationCart << std::endl
- << "Upper Location (cart):" << p.m_upperLocationCart << std::endl
- << "Upper Location (polar):" << p.m_upperLocationPolar << std::endl
- << "P flag:" << p.m_pFlag << std::endl;
+ << "ID:" << p.m_ID << endl
+ << "number:" << p.m_number << endl
+ << "name:" << p.m_name << endl
+ << "state:" << p.m_state << endl
+ << "country:" << p.m_country << endl
+ << "region:" << p.m_region << endl
+ << "Location (cart):" << p.m_locationCart << endl
+ << "Location (polar):" << p.m_locationCart << endl
+ << "Upper Location (cart):" << p.m_upperLocationCart << endl
+ << "Upper Location (polar):" << p.m_upperLocationPolar << endl
+ << "P flag:" << p.m_pFlag << endl;
}