]> git.mxchange.org Git - flightgear.git/commitdiff
Switch ATCmgr comm station search to filter by range in cartesian, not geodetic,...
authorJames Turner <zakalawe@mac.com>
Wed, 28 Sep 2011 08:06:31 +0000 (09:06 +0100)
committerJames Turner <zakalawe@mac.com>
Wed, 28 Sep 2011 08:06:31 +0000 (09:06 +0100)
src/ATC/CMakeLists.txt
src/ATCDCL/ATCmgr.cxx
src/ATCDCL/CMakeLists.txt

index e055ec6ddcf18eba1281a82a8f57abad8a4fc98a..f7dd1f2dfb0820105cb63bcc3272111742147e54 100644 (file)
@@ -6,5 +6,12 @@ set(SOURCES
        trafficcontrol.cxx
        CommStation.cxx
        )
-       
-flightgear_component(ATC "${SOURCES}")
+
+set(HEADERS
+       atc_mgr.hxx
+       atcdialog.hxx
+       trafficcontrol.hxx
+       CommStation.hxx
+       )
+       
+flightgear_component(ATC "${SOURCES}" "${HEADERS}")
index 7a3da5969f6caf00a8c7090371d214e01c2b0437..dc0901153504b0f7e1554344381803e1405b6111 100644 (file)
@@ -253,16 +253,26 @@ void FGATCMgr::FreqSearch(const string navcomm, const int unit) {
 
     class RangeFilter : public CommStation::Filter {
     public:
-        RangeFilter( const SGGeod & pos ) : CommStation::Filter(), _pos(pos) {}
-        virtual bool pass(FGPositioned* aPos) const {
+        RangeFilter( const SGGeod & pos ) : 
+          CommStation::Filter(), 
+          _cart(SGVec3d::fromGeod(pos)),
+          _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 );
+          // do the range check in cartesian space, since the distances are potentially
+          // large enough that the geodetic functions become unstable
+          // (eg, station on opposite side of the planet)
+            double rangeM = SGMiscd::max( stn->rangeNm(), 10.0 ) * SG_NM_TO_METER;
+            double d2 = distSqr( aPos->cart(), _cart);
+          
+            return d2 <= (rangeM * rangeM);
         }
     private:
+        SGVec3d _cart;
         SGGeod _pos;
     };
 
index d0dde266a07d44be6d93c07175ea8e380bf68838..8f0363135fca8ab71385856c3cade7e7a1b6098a 100644 (file)
@@ -9,5 +9,17 @@ set(SOURCES
        ATCutils.cxx
        ATCProjection.cxx
        )
-       
-flightgear_component(ATCDCL "${SOURCES}")
+
+set(HEADERS
+       ATC.hxx
+       atis.hxx
+       ATCDialogOld.hxx
+       ATCVoice.hxx
+       ATCmgr.hxx
+       ATCutils.hxx
+       ATCProjection.hxx
+       atis_lexicon.hxx
+       atis_remap.hxx
+       )
+       
+flightgear_component(ATCDCL "${SOURCES}" "${HEADERS}")