// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#include <Airports/simple.hxx>
#include <Main/fgfs.hxx>
#include <Main/fg_props.hxx>
#include <Main/globals.hxx>
#include <simgear/misc/sg_path.hxx>
-#include <simgear/bucket/newbucket.hxx>
#include <list>
lon_node = fgGetNode("/position/longitude-deg", true);
lat_node = fgGetNode("/position/latitude-deg", true);
elev_node = fgGetNode("/position/altitude-ft", true);
+
+ lon = lon_node->getDoubleValue();
+ lat = lat_node->getDoubleValue();
+ elev = elev_node->getDoubleValue();
// go through the $FG_ROOT/ATC directory and find all *.taxi files
SGPath path(globals->get_fg_root());
// Search for valid airports in the vicinity of the user and activate them if necessary
void FGAIMgr::SearchByPos(double range)
{
- //cout << "In SearchByPos(...)\n";
+ //cout << "In SearchByPos(...)" << endl;
// get bucket number for plane position
lon = lon_node->getDoubleValue();
// get neigboring buckets
int bx = (int)( range*SG_NM_TO_METER / buck.get_width_m() / 2);
- //cout << "bx = " << bx << '\n';
+ //cout << "bx = " << bx << endl;
int by = (int)( range*SG_NM_TO_METER / buck.get_height_m() / 2 );
- //cout << "by = " << by << '\n';
+ //cout << "by = " << by << endl;
// loop over bucket range
for ( int i=-bx; i<=bx; i++) {
//cout << "j loop\n";
buck = sgBucketOffset(lon, lat, i, j);
long int bucket = buck.gen_index();
- //cout << "bucket is " << bucket << '\n';
- aptID_list_type* apts = airports[bucket];
- aptID_list_iterator current = apts->begin();
- aptID_list_iterator last = apts->end();
-
- //cout << "Size of apts is " << apts->size() << '\n';
-
- //double rlon = lon * SGD_DEGREES_TO_RADIANS;
- //double rlat = lat * SGD_DEGREES_TO_RADIANS;
- //Point3D aircraft = sgGeodToCart( Point3D(rlon, rlat, elev) );
- //Point3D airport;
- for(; current != last; ++current) {
- //cout << "Found " << *current << '\n';
- if(activated.find(*current) == activated.end()) {
- //cout << "Activating " << *current << '\n';
- //FGAirport a;
- //if(dclFindAirportID(*current, &a)) {
- // // We can do something here based on distance from the user if we wish.
- //}
- ActivateAirport(*current);
- } else {
- //cout << *current << " already activated\n";
+ //cout << "bucket is " << bucket << endl;
+ if(airports.find(bucket) != airports.end()) {
+ aptID_list_type* apts = airports[bucket];
+ aptID_list_iterator current = apts->begin();
+ aptID_list_iterator last = apts->end();
+
+ //cout << "Size of apts is " << apts->size() << endl;
+
+ //double rlon = lon * SGD_DEGREES_TO_RADIANS;
+ //double rlat = lat * SGD_DEGREES_TO_RADIANS;
+ //Point3D aircraft = sgGeodToCart( Point3D(rlon, rlat, elev) );
+ //Point3D airport;
+ for(; current != last; ++current) {
+ //cout << "Found " << *current << endl;;
+ if(activated.find(*current) == activated.end()) {
+ //cout << "Activating " << *current << endl;
+ //FGAirport a;
+ //if(dclFindAirportID(*current, &a)) {
+ // // We can do something here based on distance from the user if we wish.
+ //}
+ ActivateAirport(*current);
+ //cout << "Activation done" << endl;
+ } else {
+ //cout << *current << " already activated" << endl;
+ }
}
}
}