#include <Main/fg_props.hxx>
#include "ATCmgr.hxx"
-#include "ATCDialog.hxx"
+#include "ATCDialogOld.hxx"
#include "ATCutils.hxx"
#include "atis.hxx"
voice(false),
#endif
{
+ globals->set_ATC_mgr(this);
}
FGATCMgr::~FGATCMgr() {
_aircraftPos = SGGeod::fromDegFt(lon_node->getDoubleValue(),
lat_node->getDoubleValue(), elev_node->getDoubleValue());
+
+ class RangeFilter : public CommStation::Filter {
+ public:
+ 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;
+ // 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;
+ };
+
+ RangeFilter rangeFilter(_aircraftPos );
- CommStation* sta = CommStation::findByFreq(freqKhz, _aircraftPos);
+ CommStation* sta = CommStation::findByFreq(freqKhz, _aircraftPos, &rangeFilter );
if (!sta) {
ZapOtherService(ncunit, "x x x");
return;