Hi All,
Two small Chat Menu related patches:
1) The chat menu will now select the runway closest to the aircraft when the
aircraft is on the ground, or very low (< 100ft). This handles the case where
the
user has selected a runway explicitly, e.g. 01R for KSFO take-offs for noise
abatement. My thanks for AnMaster for pointing this out on IRC. Note that above
100 ft, the wind-appropriate runway will still be used.
2) Change to keyboard description for the - key, as pointed out by Melchior.
If someone could commit them to CVS, I'd be very grateful.
-Stuart
Index: chat-menu.xml
===================================================================
RCS file: /var/cvs/FlightGear-0.9/data/gui/dialogs/chat-menu.xml,v
retrieving revision 1.1
diff -u -r1.1 chat-menu.xml
--- chat-menu.xml 8 Dec 2007 19:04:59 -0000 1.1
+++ chat-menu.xml 10 Dec 2007 12:18:57 -0000
@@ -179,27 +179,61 @@
};
}
- # Determine the active runway.
- var wind_speed = getprop("/environment/wind-speed-kt");
- var wind_from = wind_speed ?
getprop("/environment/wind-from-heading-deg")
: 270;
- var max = -1;
+ # Determine the active runway. We have two ways to do this:
+ # - If the aircraft is on the ground (or very close to it), we'll try to
determine
+ # the runway it is closest to.
+ # - If the aircraft is in the air, we'll work out the active runway based
on the wind.
+
var active_runway = "";
-
- foreach (var r; keys(airport.runways)) {
- var curr = airport.runways[r];
-
- var wind = wind_from - curr.heading;
- while (wind >= 180) wind -= 360;
- while (wind < -180) wind += 360;
-
- var deviation = math.abs(wind) + 1e-20;
- var v = (0.01 * curr.length + 0.01 * curr.width) / deviation;
-
- if (v > max) {
- max = v;
- active_runway = r;
+ var on_ground = (getprop("/position/altitude-agl-ft") < 100);
+
+ if (on_ground)
+ {
+ # To find out the closest runway to the aircrafts position, we'll look
at the heading
+ # required to go from the aircraft's current position to the center of
each runway.
+ # The closer this is to the runways real heading, the more likely this
is the runway
+ # we're on. Note that we can't rely on /sim/atc/runway, as this is only
set on
+ # initialization.
+ var max = 360;
+ var loc = geo.aircraft_position();
+
+ foreach (var r; keys(airport.runways)) {
+ var curr = airport.runways[r];
+ var p = geo.Coord.new();
+ p.set_latlon(curr.lat, curr.lon, airport.elevation);
+
+ var course = p.course_to(loc);
+ var deviation = math.abs(course - geo.normdeg(curr.heading + 180));
+
+ if (deviation < max)
+ {
+ active_runway = r;
+ max = deviation;
+ }
}
}
+ else
+ {
+ var wind_speed = getprop("/environment/wind-speed-kt");
+ var wind_from = wind_speed ?
getprop("/environment/wind-from-heading-deg") : 270;
+ var max = -1;
+
+ foreach (var r; keys(airport.runways)) {
+ var curr = airport.runways[r];
+
+ var wind = wind_from - curr.heading;
+ while (wind >= 180) wind -= 360;
+ while (wind < -180) wind += 360;
+
+ var deviation = math.abs(wind) + 1e-20;
+ var v = (0.01 * curr.length + 0.01 * curr.width) / deviation;
+
+ if (v > max) {
+ max = v;
+ active_runway = r;
+ }
+ }
+ }
# Find our distance and cardinal direction to the airport.
var directions = split(",", "North,North East,East,South East,South,South
West,West,North West");
Index: keyboard.xml
===================================================================
RCS file: /var/cvs/FlightGear-0.9/data/keyboard.xml,v
retrieving revision 1.105
diff -u -r1.105 keyboard.xml
--- keyboard.xml 8 Dec 2007 19:30:20 -0000 1.105
+++ keyboard.xml 10 Dec 2007 12:21:17 -0000
@@ -355,7 +355,7 @@
<key n="45">
<name>-</name>
<repeatable type="bool">false</repeatable>
- <desc>Compose Chat</desc>
+ <desc>Chat Menu</desc>
<binding>
<command>dialog-show</command>
<dialog-name>chat-menu</dialog-name>
___________________________________________________________
Yahoo! Answers - Got a question? Someone out there knows the answer. Try it
now.
http://uk.answers.yahoo.com/
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Flightgear-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/flightgear-devel