Wow, this works better, is simpler code, and is much faster! Plus it will be easy to allow the user to pass configurations such as range and airport type as mentioned, to suit GA planes or heavies.

    AirportInfoFilter filter;
    double maxRange = 300.0;
    FGPositioned::List results = FGPositioned::findWithinRange(globals->get_aircraft_position(), range, &filter);
    FGPositioned::sortByRange(results, globals->get_aircraft_position());
    string dest[results.size()];
    for (unsigned int i=0; i < results.size(); i++) {
        dest[i] = results[i]->ident();
    }

gapalp
[email protected]


-------- Original Message --------
Subject: Re: [Flightgear-devel] airport list
From: <[email protected]>
Date: Thu, April 12, 2012 1:09 pm
To: "FlightGear developers discussions"
<[email protected]>

Great! I will work with FGPositioned::findWithinRange to see what I can come up with that's hopefully more efficient.

gapalp
 
 
-------- Original Message --------
Subject: Re: [Flightgear-devel] airport list
From: James Turner <[email protected]>
Date: Thu, April 12, 2012 10:08 am
To: FlightGear developers discussions
<[email protected]>


On 12 Apr 2012, at 14:54, [email protected] wrote:

> I did note the results were slow. It can take up to 5 - 10 seconds to generate the list.
>
> I am looking for a list of ICAOs that branch out from one's current airport within a radius. The below method returns what I want, albeit a bit slow. A listing of ICAOs would be OK, but generating a job with a destination 5000 miles away wouldn't make much sense for most user's amount of time they have to spend in a flying session without being able to save their progress. So I am thinking more of regional jobs that could be completed in 30 minutes to a few hours dependent on the aircraft. Thus the concept of using a list of all ICAOs within x radius of the airport one is grounded at to use with the generation of the random job. Of course it could all be configurable by the user too.
>
> I entertained using the apt.dat file or a custom xml file but wanted to try some of the built-in functions first.

Aha. So what you actually want it all *sensible* airports within a certain NM cut-off. Where sensible means, likely to generate cargo - no grass/gravel strips, or, well, maybe, depending on the kind of cargo you're modelling - northern Canadian or remote Australian supply runs?

You can generate what you need in a single call, possibly creating a new AirportFilter subclass to implement the size criteria. The call you need is:

FGPositioned::findWithinRange

Passing in your desired cutoff in *nautical miles*, and a suitable filter object. For a filter object, subclass FGAirport::AirportFilter or FGAirport::HardSurfaceFilter, and extend it to reject / pass airports you deem unsuitable for your cargo traffic. For examples of subclassing these, look at MapAirportFilter, MetarAirportFilter or AirportInfoFilter.

Note that 'findWithinRange' is generally used in the simulator for ranges *less* than 1000nm, at which point the performance is 'fast enough' - if you start to increase the range to 2000nm, I don't know how it will perform - let me know!

Any other questions, just ask.

James


------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
Flightgear-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
Flightgear-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/flightgear-devel
------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
Flightgear-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to