\r
!ENDIF \r
\r
+# End Source File\r
+# End Group\r
+# Begin Group "Lib_sgmetar"\r
+\r
+# PROP Default_Filter ""\r
+# Begin Source File\r
+\r
+SOURCE=.\simgear\metar\Antoi.cpp\r
+\r
+!IF "$(CFG)" == "SimGear - Win32 Release"\r
+\r
+# PROP Intermediate_Dir "Release\Lib_sgmetar"\r
+\r
+!ELSEIF "$(CFG)" == "SimGear - Win32 Debug"\r
+\r
+# PROP Intermediate_Dir "Debug\Lib_sgmetar"\r
+\r
+!ENDIF \r
+\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\simgear\metar\Charcmp.cpp\r
+\r
+!IF "$(CFG)" == "SimGear - Win32 Release"\r
+\r
+# PROP Intermediate_Dir "Release\Lib_sgmetar"\r
+\r
+!ELSEIF "$(CFG)" == "SimGear - Win32 Debug"\r
+\r
+# PROP Intermediate_Dir "Debug\Lib_sgmetar"\r
+\r
+!ENDIF \r
+\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\simgear\metar\Dcdmetar.cpp\r
+\r
+!IF "$(CFG)" == "SimGear - Win32 Release"\r
+\r
+# PROP Intermediate_Dir "Release\Lib_sgmetar"\r
+\r
+!ELSEIF "$(CFG)" == "SimGear - Win32 Debug"\r
+\r
+# PROP Intermediate_Dir "Debug\Lib_sgmetar"\r
+\r
+!ENDIF \r
+\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\simgear\metar\Dcdmtrmk.cpp\r
+\r
+!IF "$(CFG)" == "SimGear - Win32 Release"\r
+\r
+# PROP Intermediate_Dir "Release\Lib_sgmetar"\r
+\r
+!ELSEIF "$(CFG)" == "SimGear - Win32 Debug"\r
+\r
+# PROP Intermediate_Dir "Debug\Lib_sgmetar"\r
+\r
+!ENDIF \r
+\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\simgear\metar\Drvmetar.c\r
+\r
+!IF "$(CFG)" == "SimGear - Win32 Release"\r
+\r
+# PROP Intermediate_Dir "Release\Lib_sgmetar"\r
+\r
+!ELSEIF "$(CFG)" == "SimGear - Win32 Debug"\r
+\r
+# PROP Intermediate_Dir "Debug\Lib_sgmetar"\r
+\r
+!ENDIF \r
+\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\simgear\metar\Fracpart.cpp\r
+\r
+!IF "$(CFG)" == "SimGear - Win32 Release"\r
+\r
+# PROP Intermediate_Dir "Release\Lib_sgmetar"\r
+\r
+!ELSEIF "$(CFG)" == "SimGear - Win32 Debug"\r
+\r
+# PROP Intermediate_Dir "Debug\Lib_sgmetar"\r
+\r
+!ENDIF \r
+\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\simgear\metar\MetarReport.cpp\r
+\r
+!IF "$(CFG)" == "SimGear - Win32 Release"\r
+\r
+# PROP Intermediate_Dir "Release\Lib_sgmetar"\r
+\r
+!ELSEIF "$(CFG)" == "SimGear - Win32 Debug"\r
+\r
+# PROP Intermediate_Dir "Debug\Lib_sgmetar"\r
+\r
+!ENDIF \r
+\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\simgear\metar\MetarStation.cpp\r
+\r
+!IF "$(CFG)" == "SimGear - Win32 Release"\r
+\r
+# PROP Intermediate_Dir "Release\Lib_sgmetar"\r
+\r
+!ELSEIF "$(CFG)" == "SimGear - Win32 Debug"\r
+\r
+# PROP Intermediate_Dir "Debug\Lib_sgmetar"\r
+\r
+!ENDIF \r
+\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\simgear\metar\Prtdmetr.cpp\r
+\r
+!IF "$(CFG)" == "SimGear - Win32 Release"\r
+\r
+# PROP Intermediate_Dir "Release\Lib_sgmetar"\r
+\r
+!ELSEIF "$(CFG)" == "SimGear - Win32 Debug"\r
+\r
+# PROP Intermediate_Dir "Debug\Lib_sgmetar"\r
+\r
+!ENDIF \r
+\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\simgear\metar\Stspack2.cpp\r
+\r
+!IF "$(CFG)" == "SimGear - Win32 Release"\r
+\r
+# PROP Intermediate_Dir "Release\Lib_sgmetar"\r
+\r
+!ELSEIF "$(CFG)" == "SimGear - Win32 Debug"\r
+\r
+# PROP Intermediate_Dir "Debug\Lib_sgmetar"\r
+\r
+!ENDIF \r
+\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\simgear\metar\Stspack3.cpp\r
+\r
+!IF "$(CFG)" == "SimGear - Win32 Release"\r
+\r
+# PROP Intermediate_Dir "Release\Lib_sgmetar"\r
+\r
+!ELSEIF "$(CFG)" == "SimGear - Win32 Debug"\r
+\r
+# PROP Intermediate_Dir "Debug\Lib_sgmetar"\r
+\r
+!ENDIF \r
+\r
# End Source File\r
# End Group\r
# Begin Group "Lib_sgmisc"\r
simgear/io/Makefile \
simgear/magvar/Makefile \
simgear/math/Makefile \
+ simgear/metar/Makefile \
simgear/misc/Makefile \
simgear/route/Makefile \
simgear/screen/Makefile \
ZLIB_DIRS = zlib
endif
-METAR_DIRS =
-# METAR_DIRS = metar
+# METAR_DIRS =
+METAR_DIRS = metar
EXTRA_DIST = version.h.in
#include "stardata.hxx"
-#ifdef _MSC_VER
+#if defined (_MSC_VER) || defined (FG_HAVE_NATIVE_SGI_COMPILERS)
FG_USING_STD(getline);
#endif
FG_USING_STD( string );
FG_USING_STD( vector );
+
+#if !defined (FG_HAVE_NATIVE_SGI_COMPILERS)
FG_USING_STD( cout );
FG_USING_STD( endl );
+#endif
enum {
lib_LIBRARIES = libsgmetar.a
+include_HEADERS = MetarReport.h MetarStation.h
+
libsgmetar_a_SOURCES = \
Antoi.cpp Charcmp.cpp Dcdmetar.cpp Dcdmtrmk.cpp Drvmetar.c \
Fracpart.cpp Local.h Metar.h \
- MetarReport.cpp MetarReport.h \
- MetarStation.cpp MetarStation.h \
+ MetarReport.cpp \
+ MetarStation.cpp \
Prtdmetr.cpp Stspack2.cpp Stspack3.cpp
INCLUDES += -I$(top_srcdir)
return ((Decoded_METAR *)m_DecodedReport)->stnid;
}
+int CMetarReport::Day()
+{
+ return ((Decoded_METAR*)m_DecodedReport)->ob_date;
+}
+
+int CMetarReport::Hour()
+{
+ return ((Decoded_METAR*)m_DecodedReport)->ob_hour;
+}
+
+int CMetarReport::Minutes()
+{
+ return ((Decoded_METAR*)m_DecodedReport)->ob_minute;
+}
+
int CMetarReport::WindDirection()
{
return ((Decoded_METAR *)m_DecodedReport)->winData.windDir;
}
+double CMetarReport::AirPressure()
+{
+ return ((Decoded_METAR *)m_DecodedReport)->inches_altstng;
+}
+
void CMetarReport::dump()
{
prtDMETR( (Decoded_METAR *)m_DecodedReport );
}
+
+double CMetarReport::PrevailVisibility() {
+ //Values from each visibility field converted to meters.
+ double smiles;
+ double km;
+ double meters;
+ smiles = ((Decoded_METAR*) m_DecodedReport)->prevail_vsbySM * 621 ;
+ km = ((Decoded_METAR*) m_DecodedReport)->prevail_vsbyKM * 1000;
+ meters = ((Decoded_METAR*) m_DecodedReport)->prevail_vsbyM;
+
+ /* Return the smallest one. If the field is specified it should have been
+ set to MAX_INT */
+ if(smiles < km && smiles < meters)
+ return smiles;
+ else
+ return km < meters ? km : meters;
+}
char *StationID();
+ int Day(); // The day of month on which the report was issued.
+ int Hour(); // The hour of the day the report was issued.
+ int Minutes(); //Minutes past the hour of the report issue time.
+
// Directions in degrees
// Speed in knots
// Altitude in meters
int VariableSkyLayerHeight();
int SnowDepthInches();
-
+
+ double AirPressure(); //Return the air pressure in InchesHg.
+ double PrevailVisibility(); // Prevailing Visibility in meters.
void dump();
private:
#include "MetarStation.h"
#include <algorithm>
-#define TESTPROG
-#ifndef TESTPROG
-// options is too tightly integrated into FlightGear to use in a test program
-#include <Main/options.hxx>
-#endif
-#include <simgear/misc/fgpath.hxx>
-
-
-std::vector< CMetarStation *> METAR_Stations;
-int CMetarStation::initialized( CMetarStation::initialize() );
-
-std::string CMetarStation::tempName;
+#include <simgear/misc/fgpath.hxx>
double CMetarStation::decodeDMS( char *b )
return r * DEG_TO_RAD;
}
+// Constructor
+// Decodes METAR station string of this format:
+// KPUB;72;464;Pueblo, Pueblo Memorial Airport;CO;United States;4;38-17-24N;104-29-54W;38-17-03N;104-29-43W;1440;1420;P
CMetarStation::CMetarStation(
char *s )
double ulongitude = decodeDMS( s );
s = t; t = strchr( s, ';' ); *t = 0; t++;
double altitude = atoi( s ) * FEET_TO_METER;
+ m_altitude = altitude;
s = t; t = strchr( s, ';' ); *t = 0; t++;
double ualtitude = atoi( s ) * FEET_TO_METER;
Point3D p( longitude, latitude, altitude+EQUATORIAL_RADIUS_M );
s = t;
m_pFlag = s[0];
}
- // Constructor
- // Decodes METAR station string of this format:
- // KPUB;72;464;Pueblo, Pueblo Memorial Airport;CO;United States;4;38-17-24N;104-29-54W;38-17-03N;104-29-43W;1440;1420;P
+
-int CMetarStation::initialize()
+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;
+}
+
+
+
+CMetarStationDB::CMetarStationDB(const char * dbPath)
{
// Read the list of metar stations, decoding and adding to global list.
CMetarStation *m;
char buf[256];
- // Goto the Flight Gear installation directory
-#ifdef TESTPROG
- //FGPath weatherPath( "/mkv/Build/FlightGear" );
- FGPath weatherPath( ":Data" );
-#else
- FGPath weatherPath( current_options.get_fg_root() );
-#endif
- weatherPath.append( "Weather" );
- weatherPath.append( "MetarStations" );
// Open the metar station list
- FILE *f = fopen( weatherPath.c_str(), "r" );
+ FILE *f = fopen( dbPath, "r" );
if ( f != NULL ) {
//std::cout << buf << std::endl;
m = new CMetarStation( buf );
//m->dump();
- METAR_Stations.push_back( m );
+ METAR_Stations[m->ID()]=( m );
}
// Close the list
fclose( f );
// std::cout << METAR_Stations.size() << " Metar stations" << std::endl;
- return 1;
+
} else {
// std::cout << "Could not open MetarStations file " << std::endl;
- return 0;
+
}
}
-int CMetarStation::sameName( CMetarStation *m )
-{
- return m->m_ID == tempName;
-}
-
-
-CMetarStation *CMetarStation::find( std::string stationID )
-{
- tempName = stationID;
- CMetarStation **m = std::find_if( METAR_Stations.begin(), METAR_Stations.end(), sameName );
- if ( m != METAR_Stations.end() ) return *m;
- return 0;
-}
-
-double bestDist;
-CMetarStation *bestStation;
-Point3D curLocation;
-void findHelper( CMetarStation *s )
+CMetarStation * CMetarStationDB::find( std::string stationID )
{
- double dist = s->locationCart().distance3Dsquared( curLocation );
- if (dist < bestDist )
- {
- bestDist = dist;
- bestStation = s;
- }
+ std::map<std::string,CMetarStation*>::iterator target;
+ target = METAR_Stations.find(stationID);
+ if(target!= METAR_Stations.end() )
+ return target->second;
+ else
+ return NULL;
}
-CMetarStation *CMetarStation::find( Point3D locationCart )
-{
- bestDist = 99999999;
- bestStation = 0;
- curLocation = locationCart;
- for_each( findHelper );
- return bestStation;
-}
-
-void CMetarStation::for_each( void f( CMetarStation *s ) )
+CMetarStation * CMetarStationDB::find( Point3D locationCart )
{
- std::for_each( METAR_Stations.begin(), METAR_Stations.end(), f );
+ std::map<std::string,CMetarStation*>::iterator itr;
+ double bestDist = 99999999;
+ CMetarStation * bestStation;
+ Point3D curLocation = locationCart;
+ itr = METAR_Stations.begin();
+ while(itr != METAR_Stations.end())
+ {
+ double dist = itr->second->locationCart().distance3Dsquared( curLocation );
+ if (dist < bestDist )
+ {
+ bestDist = dist;
+ bestStation = itr->second;
+ }
+ itr++;
+ }
+
+ return bestStation;
}
-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;
+CMetarStationDB::~CMetarStationDB() {
+ std::map<std::string,CMetarStation*>::iterator itr;
+ for(itr = METAR_Stations.begin(); itr != METAR_Stations.end(); itr++)
+ {
+ delete itr->second;
+ }
}
std::ostream&
// METAR station information is kept in this file:
// http://www.nws.noaa.gov/pub/stninfo/nsd_cccc.gz
// http://www.nws.noaa.gov/pub/stninfo/nsd_cccc.txt
-// This class looks for the file FG_ROOT/Weather/MetarStations instread of nsd_cccc.
+
#ifndef _MetarStation_
#define _MetarStation_
#include <iostream>
#include <string>
#include <vector>
+#include <map>
#include <simgear/math/point3d.hxx>
#include <simgear/math/polar3d.hxx>
//using namespace std;
+class CMetarStationDB;
+
class CMetarStation
{
// Attributes
int m_altitude;
int m_upperAltitude;
char m_pFlag;
-
- static int initialized;
- static std::string tempName;
-
+
// Operations
private:
double decodeDMS( char *b );
- static int sameName( CMetarStation *m );
+
+
CMetarStation(
char *s );
std::string &state() { return m_state; }
std::string &country() { return m_country; }
int region() { return m_region; }
+ unsigned int Altitude() { //Returns the stations height above MSL in M.
+ return m_altitude;}
Point3D &locationPolar() { return m_locationPolar; }
Point3D &upperLocationPolar() { return m_upperLocationPolar; }
Point3D &locationCart() { return m_locationCart; }
friend std::ostream& operator << ( std::ostream&, const CMetarStation& );
void dump();
- static CMetarStation *find( std::string stationID );
- static CMetarStation *find( Point3D locationCart );
- static void for_each( void f( CMetarStation *s ) );
+
+
private:
CMetarStation(
const CMetarStation &rObj );
// Assignment operator. Not implemented.
- static int initialize();
+ friend CMetarStationDB;
};
+class CMetarStationDB
+{
+
+ private:
+ std::string databasePath; //The path of the database file.
+ std::map<std::string , CMetarStation *> METAR_Stations;
+ CMetarStation * bestStation;
+
+ public:
+ CMetarStation *find( std::string stationID );
+ CMetarStation * find( Point3D locationCart );
+ CMetarStationDB(const char * dbFile);
+ ~CMetarStationDB();
+};
+
#endif
//
// $Id$
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <simgear/compiler.h>
+
#include <stdio.h>
#include <stdlib.h>
-#include <iostream>
+#include STL_IOSTREAM
#include <algorithm>
#include "props.hxx"
-using std::cerr;
-using std::endl;
-using std::sort;
+#if !defined(FG_HAVE_NATIVE_SGI_COMPILERS)
+FG_USING_STD(cerr);
+FG_USING_STD(endl);
+#endif
+FG_USING_STD(sort);
\f
#ifndef __PROPS_HXX
#define __PROPS_HXX
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <simgear/compiler.h>
+
#include <stdio.h>
-#include <string>
+#include STL_STRING
#include <vector>
-#include <iostream>
+#include STL_IOSTREAM
-using std::string;
-using std::vector;
-using std::istream;
-using std::ostream;
+FG_USING_STD(string);
+FG_USING_STD(vector);
+#if !defined(FG_HAVE_NATIVE_SGI_COMPILERS)
+FG_USING_STD(istream);
+FG_USING_STD(ostream);
+#endif
#ifdef UNKNOWN
#pragma warn A sloppy coder has defined UNKNOWN as a macro!
# include <config.h>
#endif
+#include <simgear/compiler.h>
+
#include <stdlib.h> // atof() atoi()
#include <simgear/debug/logstream.hxx>
#include "props.hxx"
-#include <iostream>
-#include <fstream>
-#include <string>
+#include STL_IOSTREAM
+#if !defined(FG_HAVE_NATIVE_SGI_COMPILERS)
+# include <fstream>
+#else
+# include <fstream.h>
+#endif
+#include STL_STRING
#include <vector>
-using std::istream;
-using std::ifstream;
-using std::ostream;
-using std::ofstream;
-using std::string;
-using std::vector;
+#if !defined(FG_HAVE_NATIVE_SGI_COMPILERS)
+FG_USING_STD(istream);
+FG_USING_STD(ifstream);
+FG_USING_STD(ostream);
+FG_USING_STD(ofstream);
+#endif
+FG_USING_STD(string);
+FG_USING_STD(vector);
\f
// Test harness.
////////////////////////////////////////////////////////////////////////
-#include <iostream>
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <simgear/compiler.h>
+
+#include STL_IOSTREAM
#include "props.hxx"
-using std::cout;
-using std::endl;
+#if !defined(FG_HAVE_NATIVE_SGI_COMPILERS)
+FG_USING_STD(cout);
+FG_USING_STD(endl);
+#endif
\f
# include <config.h>
#endif
+#include <simgear/compiler.h>
+
#include <stdio.h>
-#include <iostream>
+#include STL_IOSTREAM
#include <plib/sg.h>
#include <plib/ssg.h>
#include <simgear/compiler.h>
#include <stdio.h>
-#include <iostream>
+#include STL_IOSTREAM
#include <plib/sg.h>
#include <plib/ssg.h>
# include <config.h>
#endif
+#include <simgear/compiler.h>
+
#include <stdio.h>
-#include <iostream>
+#include STL_IOSTREAM
#include <plib/sg.h>
#include <plib/ssg.h>
#include <plib/sg.h>
#include <plib/ssg.h>
-FG_USING_NAMESPACE(std);
+#if !defined (FG_HAVE_NATIVE_SGI_COMPILERS)
+FG_USING_STD(cout);
+FG_USING_STD(endl);
+#endif
+
// return a sphere object as an ssgBranch
ssgBranch *ssgMakeSphere( ssgSimpleState *state, ssgColourArray *cl,
new ssgVtxTable ( GL_TRIANGLE_STRIP, vl, nl, tl, cl );
if ( vl->getNum() != nl->getNum() ) {
- std::cout << "bad sphere1\n";
+ cout << "bad sphere1" << endl;
exit(-1);
}
if ( vl->getNum() != tl->getNum() ) {
- std::cout << "bad sphere2\n";
+ cout << "bad sphere2" << endl;
exit(-1);
}
slice->setState( state );
# include <config.h>
#endif
+#include <simgear/compiler.h>
+
#include <stdio.h>
-#include <iostream>
+#include STL_IOSTREAM
#include <plib/sg.h>
#include <plib/ssg.h>
#include "stars.hxx"
+#if !defined (FG_HAVE_NATIVE_SGI_COMPILERS)
FG_USING_STD(cout);
FG_USING_STD(endl);
+#endif
// Set up star rendering call backs
// cout << "Current local time = "
// << asctime(localtime(&cur_time)) << endl;
- if ( root != "" ) {
+ if ( root != (string)"" ) {
FGPath zone( root );
zone.append( "zone.tab" );
FG_LOG( FG_EVENT, FG_DEBUG, "Reading timezone info from: "
#ifndef __EASYXML_HXX
#define __EASYXML_HXX
-#include <iostream>
-#include <string>
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <simgear/compiler.h>
+
+#include STL_IOSTREAM
+#include STL_STRING
#include <vector>
-using std::istream;
-using std::string;
-using std::vector;
+#if !defined(FG_HAVE_NATIVE_SGI_COMPILERS)
+FG_USING_STD(istream);
+#endif
+FG_USING_STD(string);
+FG_USING_STD(vector);
/**