]> git.mxchange.org Git - flightgear.git/blobdiff - src/Instrumentation/newnavradio.cxx
Support helipad names in the --runway startup option
[flightgear.git] / src / Instrumentation / newnavradio.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 9468e3f..41b606c
 #include <assert.h>
 #include <boost/foreach.hpp>
 
-#include <simgear/math/SGMath.hxx>
 #include <simgear/math/interpolater.hxx>
 #include <simgear/sg_inlines.h>
 #include <simgear/props/propertyObject.hxx>
 #include <simgear/misc/strutils.hxx>
+#include <simgear/sound/sample_group.hxx>
 
 #include <Main/fg_props.hxx>
 #include <Navaids/navlist.hxx>
@@ -149,7 +149,7 @@ public:
 
 protected:
   virtual double computeSignalQuality_norm( const SGGeod & aircraftPosition );
-  virtual FGNavList * getNavaidList() = 0;
+  virtual FGNavList::TypeFilter* getNavaidFilter() = 0;
 
   // General-purpose sawtooth function.  Graph looks like this:
   //         /\                                    .
@@ -174,7 +174,7 @@ protected:
   PropertyObject<double> _trackDistance_m;
   PropertyObject<double> _slantDistance_m;
   PropertyObject<double> _heightAboveStation_ft;
-  PropertyObject<string> _ident;
+  PropertyObject<std::string> _ident;
   PropertyObject<bool>   _inRange;
   PropertyObject<double> _range_nm;
 };
@@ -259,7 +259,8 @@ double NavRadioComponent::getRange_nm( const SGGeod & aircraftPosition )
 
 void NavRadioComponent::search( double frequency, const SGGeod & aircraftPosition )
 {
-  if( NULL == (_navRecord = getNavaidList()->findByFreq(frequency, aircraftPosition )) ) {
+  _navRecord = FGNavList::findByFreq(frequency, aircraftPosition, getNavaidFilter() );
+  if( NULL == _navRecord ) {
     SG_LOG(SG_INSTR,SG_ALERT, "No " << _name << " available at " << frequency );
     _ident = "";
     return;
@@ -323,7 +324,7 @@ public:
   virtual double getRange_nm(const SGGeod & aircraftPosition);
 protected:
   virtual double computeSignalQuality_norm( const SGGeod & aircraftPosition );
-  virtual FGNavList * getNavaidList();
+  virtual FGNavList::TypeFilter* getNavaidFilter();
 
 private:
   double _totalTime;
@@ -377,7 +378,9 @@ double VOR::ServiceVolume::adjustRange( double height_ft, double nominalRange_nm
 }
 
 VOR::VOR( SGPropertyNode_ptr rootNode) :
-  NavRadioComponentWithIdent("vor", rootNode, new VORAudioIdent(getIdentString(string("vor"), rootNode->getIndex()))),
+    NavRadioComponentWithIdent("vor", rootNode,
+                               new VORAudioIdent(getIdentString(std::string("vor"),
+                                                                rootNode->getIndex()))),
   _totalTime(0.0),
   _radial( rootNode->getNode(_name,true)->getNode("radial",true) ),
   _radialInbound( rootNode->getNode(_name,true)->getNode("radial-inbound",true) )
@@ -393,9 +396,10 @@ double VOR::getRange_nm( const SGGeod & aircraftPosition )
   return _serviceVolume.adjustRange( _heightAboveStation_ft, _navRecord->get_range() );
 }
 
-FGNavList * VOR::getNavaidList()
+FGNavList::TypeFilter* VOR::getNavaidFilter()
 {
-  return globals->get_navlist();
+  static FGNavList::TypeFilter filter(FGPositioned::VOR);
+  return &filter;
 }
 
 double VOR::computeSignalQuality_norm( const SGGeod & aircraftPosition )
@@ -468,7 +472,7 @@ public:
 
 protected:
   virtual double computeSignalQuality_norm( const SGGeod & aircraftPosition );
-  virtual FGNavList * getNavaidList();
+  virtual FGNavList::TypeFilter* getNavaidFilter();
 
 private:
   class ServiceVolume {
@@ -521,7 +525,8 @@ double LOC::ServiceVolume::adjustRange( double azimuthAngle_deg, double elevatio
 }
 
 LOC::LOC( SGPropertyNode_ptr rootNode) :
-  NavRadioComponentWithIdent("loc", rootNode, new LOCAudioIdent(getIdentString(string("loc"), rootNode->getIndex()))),
+    NavRadioComponentWithIdent("loc", rootNode, new LOCAudioIdent(getIdentString(std::string("loc"),
+                                                                                 rootNode->getIndex()))),
   _serviceVolume(),
   _localizerOffset_norm( rootNode->getNode(_name,true)->getNode("offset-norm",true) ),
   _localizerWidth_deg( rootNode->getNode(_name,true)->getNode("width-deg",true) )
@@ -532,9 +537,9 @@ LOC::~LOC()
 {
 }
 
-FGNavList * LOC::getNavaidList()
+FGNavList::TypeFilter* LOC::getNavaidFilter()
 {
-  return globals->get_loclist();
+  return FGNavList::locFilter();
 }
 
 void LOC::search( double frequency, const SGGeod & aircraftPosition )
@@ -618,8 +623,7 @@ public:
 
   virtual double getRange_nm(const SGGeod & aircraftPosition);
 protected:
-  virtual FGNavList * getNavaidList();
-
+  virtual FGNavList::TypeFilter* getNavaidFilter();
 private:
   class ServiceVolume {
   public:
@@ -687,9 +691,10 @@ GS::~GS()
 {
 }
 
-FGNavList * GS::getNavaidList()
+FGNavList::TypeFilter* GS::getNavaidFilter()
 {
-  return globals->get_gslist();
+  static FGNavList::TypeFilter filter(FGPositioned::GS);
+  return &filter;
 }
 
 double GS::getRange_nm(const SGGeod & aircraftPosition)
@@ -808,7 +813,7 @@ public:
   void valueChanged (SGPropertyNode * prop)
   {
     // format as fixed decimal "nnn.nn"
-    ostringstream buf;
+    std::ostringstream buf;
     buf << std::fixed 
         << std::setw(5) 
         << std::setfill('0') 
@@ -880,7 +885,7 @@ NavRadioImpl::NavRadioImpl( SGPropertyNode_ptr node ) :
   _legacy( this ),
   _name(node->getStringValue("name", "nav")),
   _num(node->getIntValue("number", 0)),
-  _rootNode(fgGetNode( string("/instrumentation/") + _name, _num, true)),
+  _rootNode(fgGetNode( std::string("/instrumentation/") + _name, _num, true)),
   _useFrequencyFormatter( _rootNode->getNode("frequencies/selected-mhz",true), _rootNode->getNode("frequencies/selected-mhz-fmt",true), 0.05 ),
   _stbyFrequencyFormatter( _rootNode->getNode("frequencies/standby-mhz",true), _rootNode->getNode("frequencies/standby-mhz-fmt",true), 0.05 ),
   _navIndicator(_rootNode),
@@ -899,7 +904,7 @@ NavRadioImpl::~NavRadioImpl()
 
 void NavRadioImpl::init()
 {
-  if( 0 < _components.size() )
+  if( ! _components.empty() )
     return;
 
   _components.push_back( new VOR(_rootNode) );
@@ -922,7 +927,7 @@ void NavRadioImpl::update( double dt )
   try {
     position = globals->get_aircraft_position();
   }
-  catch( exception & ) {
+  catch( std::exception & ) {
     return;
   }
 
@@ -966,7 +971,7 @@ void NavRadioImpl::Legacy::update( double dt )
         _navRadioImpl->_components[VOR_COMPONENT]->valid() || _navRadioImpl->_components[LOC_COMPONENT]->valid()  
         );
 
-    string ident = _navRadioImpl->_components[VOR_COMPONENT]->getIdent();
+    std::string ident = _navRadioImpl->_components[VOR_COMPONENT]->getIdent();
     if( ident.empty() )
         ident = _navRadioImpl->_components[LOC_COMPONENT]->getIdent();