On Saturday 20 September 2003 01:33, David Luff wrote:
> Lee Elliott writes:
> 
> > Hello all,
> > 
> > Once you've started FG, the tower views are permently fixed to the 
departure 
> > airfield.  Would it be difficult to optionally switch the tower views to 
the 
> > destination airfield, when one is set in the AP waypoint list?
> > 
> 
> Hi Lee,
> 
> There is code in the ATC system to find the closest ATC service of a given 
type to a given point.  It shouldn't be too hard to piggy-back that to get 
the closest tower view to the user if desired.
> 
> In commlist.hxx - FindClosest(...) It writes the info into an ATCData&, but 
it would be trivial to write a wrapper to return the ICAO code so the main 
program wouldn't have to know about ATCData.  Likewise it requires the 
atc_type (TOWER, GROUND, etc) to be passed in, but once again a wrapper 
function assuming tower could be quickly written so that the main program 
need know nothing about atc_type.
> 
> Oh sod it, I can't resist, putting the below in commlist.cxx with a header 
in commlist.hxx *should* work
> 
> commlist.hxx:
> // Return the ICAO code of the nearest tower within m miles
> // Returns XXXX if no tower within distance (defaults to 100)
> string FindClosestTower(Point3D p, double m = 100);
> 
> // Return the ICAO code of the nearest tower within m miles
> // Returns XXXX if no tower within distance (defaults to 100)
> string FGCommList::FindClosestTower(Point3D p, double m) {
>   ATCData d;
>   double n = FindClosest(p.lon(), p.lat(), p.elev(), d, TOWER, m);
>   if(n) {
>     return(d.ident);
>   } else {
>     return("XXXX");
>   }
> }
> 
> You wouldn't want to call it every frame though - searches by area are not 
the most efficient.  (The ATC services are mapped by tile-id, but within the 
search area every tile-id is traversed, and the resultant ATC services found 
ordered by distance.)  There are a fair few tiles within 100 miles = 200 X 
200 miles = 40,000 sq miles!  Given that that's too far to see, I've just 
added miles to be passed in to the above, since we can't see the plane at 100 
miles!  I believe that I found some problem with very small distances such as 
10 though - I seem to recall that if the centre of a tile fell outside the 
distance then the tile was excluded, and an ATC service quite close but on 
the edge of the tile could get overlooked.  Somewhere between 20 and 40 miles 
called intermittently (globals->get_current_commlist()->Find... etc) would 
probably do you.
> 
> Good luck!
> 
> Cheers - Dave

Ta - I'll give it a try:)

LeeE


_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to