From a9463a839971d5b422092f9ed79a49ed972d1c38 Mon Sep 17 00:00:00 2001 From: daveluff Date: Sun, 9 Mar 2003 17:35:16 +0000 Subject: [PATCH] Added a range parameter to the FindByPos search function, also fixed a bug whereby one too few buckets in the North and East direction were searched - hence when only one bucket should have been searched none were --- src/ATC/ATCmgr.cxx | 6 +----- src/ATC/commlist.cxx | 13 ++++++------- src/ATC/commlist.hxx | 8 ++++---- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/ATC/ATCmgr.cxx b/src/ATC/ATCmgr.cxx index b2532db33..f32c7ef6a 100644 --- a/src/ATC/ATCmgr.cxx +++ b/src/ATC/ATCmgr.cxx @@ -26,10 +26,6 @@ #include "ATCmgr.hxx" #include "commlist.hxx" -//#include "atislist.hxx" -//#include "groundlist.hxx" -//#include "towerlist.hxx" -//#include "approachlist.hxx" #include "ATCdisplay.hxx" #include "ATCDialog.hxx" #include "ATCutils.hxx" @@ -501,7 +497,7 @@ void FGATCMgr::AreaSearch() { elev = elev_node->getDoubleValue() * SG_FEET_TO_METER; // search stations in range - int num_app = current_commlist->FindByPos(lon, lat, elev, &approaches, APPROACH); + int num_app = current_commlist->FindByPos(lon, lat, elev, 100.0, &approaches, APPROACH); if (num_app != 0) { //cout << num_app << " approaches found in radiostack search !!!!" << endl; diff --git a/src/ATC/commlist.cxx b/src/ATC/commlist.cxx index eb0201e92..8f282ea3b 100644 --- a/src/ATC/commlist.cxx +++ b/src/ATC/commlist.cxx @@ -163,7 +163,7 @@ bool FGCommList::FindByFreq( double lon, double lat, double elev, double freq, return false; } -int FGCommList::FindByPos(double lon, double lat, double elev, comm_list_type* stations, atc_type tp) +int FGCommList::FindByPos(double lon, double lat, double elev, double range, comm_list_type* stations, atc_type tp) { // number of relevant stations found within range int found = 0; @@ -173,13 +173,12 @@ int FGCommList::FindByPos(double lon, double lat, double elev, comm_list_type* s SGBucket buck(lon, lat); // get neigboring buckets - int max_range = 100; - int bx = (int)( max_range*SG_NM_TO_METER / buck.get_width_m() / 2); - int by = (int)( max_range*SG_NM_TO_METER / buck.get_height_m() / 2 ); + int bx = (int)( range*SG_NM_TO_METER / buck.get_width_m() / 2); + int by = (int)( range*SG_NM_TO_METER / buck.get_height_m() / 2 ); // loop over bucket range - for ( int i=-bx; i