]> git.mxchange.org Git - flightgear.git/commitdiff
Fix #369: ATIS receiver has excessive range
authorTorsten Dreyer <Torsten@t3r.de>
Fri, 8 Jul 2011 08:56:18 +0000 (10:56 +0200)
committerTorsten Dreyer <Torsten@t3r.de>
Fri, 8 Jul 2011 08:56:18 +0000 (10:56 +0200)
Add a range filter when searching for CommStations,
searching by frequency is not enough.

src/ATCDCL/ATCmgr.cxx

index 8d8a6fc5815987df5026e478eafa9053fca57b3b..0b93d6a206fb633c001fad16164ee0f2374c97e4 100644 (file)
@@ -250,8 +250,25 @@ void FGATCMgr::FreqSearch(const string navcomm, const int unit) {
     
     _aircraftPos = SGGeod::fromDegFt(lon_node->getDoubleValue(),
         lat_node->getDoubleValue(), elev_node->getDoubleValue());
+
+    class RangeFilter : public CommStation::Filter {
+    public:
+        RangeFilter( const SGGeod & pos ) : CommStation::Filter(), _pos(pos) {}
+        virtual bool pass(FGPositioned* aPos) const {
+            flightgear::CommStation * stn = dynamic_cast<flightgear::CommStation*>(aPos);
+            if( NULL == stn ) return false;
+            double dist = SGGeodesy::distanceNm( stn->geod(), _pos );
+            // if range is not configured, assume at least 10NM range
+            // TODO: maybe ramp down range with proximity to ground?
+            return dist <= SGMiscd::max( stn->rangeNm(), 10.0 );
+        }
+    private:
+        SGGeod _pos;
+    };
+
+    RangeFilter rangeFilter(_aircraftPos );
     
-    CommStation* sta = CommStation::findByFreq(freqKhz, _aircraftPos);
+    CommStation* sta = CommStation::findByFreq(freqKhz, _aircraftPos, &rangeFilter );
     if (!sta) {
         ZapOtherService(ncunit, "x x x");
         return;