#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() {
+ globals->set_ATC_mgr(NULL);
delete v1;
}
//cout << "Eradicating service: '" << svc->first << "'" << endl;
svc->second->SetNoDisplay();
svc->second->Update(0); // one last update
- SG_LOG(SG_GENERAL, SG_INFO, "would have erased ATC service:" << svc->second->get_name()<< "/"
+ SG_LOG(SG_ATC, SG_INFO, "would have erased ATC service:" << svc->second->get_name()<< "/"
<< svc->second->get_ident());
// delete svc->second;
atc_list->erase(svc);
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;
};