On Fri, Jul 29, 2011 at 3:18 PM, Stuart Buchanan wrote:
> 2011/7/14 Mathias Fröhlich wrote:
>> While being able to do a croase ground query on such a kind of regular grid
>> might be beneficial for the weather module. I would prefer the ai module just
>> using the already available bounding volume tree that is used for the main
>> aircrafts elevation queries. This is already really fast.
>> Also, may be making use of these bounding volume hierarchies for the weather
>> module as an intermediate step might be a good idea?
>
> Hi Mathias,
>
> Presumably this is using the ground_cache rather code rather than the
> scenery.get_elevation_m() code that the Nasal system uses to to get
> geodinfo()
>
> If so, I'll see if there's a sensible way to expose this over the
> Nasal interface
> as an alternative to the current geodinfo() routine.
>
> Is there any reason not to simply use the ground_cache for the Nasal
> geodinfo() routine? They both seem to make elevation and material
> information available?

So, I quickly wrote an alternative to the current Nasal  system geodinfo(),
using the groundcache instead of the  current scenery method.

I then tested both methods with a small piece of Nasal calling geodinfo
repeatedly across a degree of lat/lon at intervals of 0.01 degree in both
lat and lon. I.e. about 10,000 geodinfo calls.

Over multiple runs, the existing scenery based method took between
5.78 and 6.15 seconds. The groundcache version took between 0.38
and 0.5 seconds. So there seems to be about an order of magnitude
difference in performance between the two. In fact it may be more
than that, as there were a number of array operations
 taking place as well.

By inspection of a much smaller data set (0.1 degree steps), the differences
in altitude reported are < 1cm, and the materials returned are identical.

So, changing the existing geodinfo function for one that uses the groundcache
would appear to offer a significant improvement in performance, the
tradeoff being
presumably an increase in memory footprint due to use of the ground-cache.

For reference, the Nasal test code is copied below.

Comments?

-Stuart


------

var lat = getprop("/position/latitude-deg");
var lon = getprop("/position/longitude-deg");

var t = systime();

var alts = [];
var mats = [];
var count = 0;

print ("Time: " ~ t);

for (var i = 0; i < 1; i = i + 0.01) {
  for (var j = 0; j < 1; j = j + 0.01) {
    var geo_info = fastgeodinfo(lat + i, lon + j);
    if (geo_info != nil) {
       append(alts, geo_info[0]);

       if (geo_info[1] != nil) {
         append(mats, geo_info[1].names[0]);
        }
    }
  }
}

var d = systime();

print("Time: " ~ d);

print("Delta: " ~ (d - t));
print("Alts: " ~ size(alts) ~ " Mats: " ~ size(mats) ~ "\n");

------------------------------------------------------------------------------
Got Input?   Slashdot Needs You.
Take our quick survey online.  Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to