]> 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
index 9bf3259cb3178543c5df8198bb38ba146cf513c4..41b606c152bbe3b49702815e98d9bb4693bc5456 100644 (file)
@@ -33,6 +33,7 @@
 #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>
@@ -148,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:
   //         /\                                    .
@@ -173,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;
 };
@@ -258,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;
@@ -322,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;
@@ -376,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) )
@@ -392,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 )
@@ -467,7 +472,7 @@ public:
 
 protected:
   virtual double computeSignalQuality_norm( const SGGeod & aircraftPosition );
-  virtual FGNavList * getNavaidList();
+  virtual FGNavList::TypeFilter* getNavaidFilter();
 
 private:
   class ServiceVolume {
@@ -520,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) )
@@ -531,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 )
@@ -617,8 +623,7 @@ public:
 
   virtual double getRange_nm(const SGGeod & aircraftPosition);
 protected:
-  virtual FGNavList * getNavaidList();
-
+  virtual FGNavList::TypeFilter* getNavaidFilter();
 private:
   class ServiceVolume {
   public:
@@ -686,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)
@@ -879,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),
@@ -898,7 +904,7 @@ NavRadioImpl::~NavRadioImpl()
 
 void NavRadioImpl::init()
 {
-  if( 0 < _components.size() )
+  if( ! _components.empty() )
     return;
 
   _components.push_back( new VOR(_rootNode) );
@@ -965,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();