]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATCDCL/ATCDialog.cxx
Merge branch 'torsten/metar'
[flightgear.git] / src / ATCDCL / ATCDialog.cxx
index 5e548667ea999a88ef6aea4febbbfd8d5207a6e9..f5f5ec935d3f337e7b1efe4ad1cb7b2e613d503b 100644 (file)
@@ -66,7 +66,7 @@ ATCMenuEntry::ATCMenuEntry() {
 ATCMenuEntry::~ATCMenuEntry() {
 }
 
-static void atcUppercase(string &s) {
+void atcUppercase(string &s) {
        for(unsigned int i=0; i<s.size(); ++i) {
                s[i] = toupper(s[i]);
        }
@@ -266,7 +266,7 @@ void FGATCDialog::PopupCallback(int num) {
                //cout << "TOWER " << endl;
                //cout << "ident is " << atcptr->get_ident() << endl;
                atcmentry_vec_type atcmlist = (available_dialog[TOWER])[atcptr->get_ident()];
-               unsigned int size = atcmlist.size();
+               int size = atcmlist.size();
                if(size && num < size) {
                        //cout << "Doing callback...\n";
                        ATCMenuEntry a = atcmlist[num];
@@ -318,21 +318,19 @@ void FGATCDialog::FreqDialog() {
        // Find the ATC stations within a reasonable range
        comm_list_type atc_stations;
        comm_list_iterator atc_stat_itr;
-       
-       double lon = fgGetDouble("/position/longitude-deg");
-       double lat = fgGetDouble("/position/latitude-deg");
-       double elev = fgGetDouble("/position/altitude-ft");
-       SGVec3d aircraft = SGVec3d::fromGeod(SGGeod::fromDegM(lon, lat, elev));
+
+  SGGeod geod(SGGeod::fromDegFt(fgGetDouble("/position/longitude-deg"),
+    fgGetDouble("/position/latitude-deg"), fgGetDouble("/position/altitude-ft")));
+       SGVec3d aircraft = SGVec3d::fromGeod(geod);
 
        // search stations in range
-       int num_stat = current_commlist->FindByPos(lon, lat, elev, 50.0, &atc_stations);
+       int num_stat = current_commlist->FindByPos(geod, 50.0, &atc_stations);
        if (num_stat != 0) {
                map<atcdata, bool> uniq;
                // fill map (sorts by distance and removes duplicates)
                comm_list_iterator itr = atc_stations.begin();
                for (; itr != atc_stations.end(); ++itr) {
-                       SGVec3d station(itr->x, itr->y, itr->z);
-                       double distance = distSqr(aircraft, station);
+                       double distance = distSqr(aircraft, itr->cart);
                        uniq[atcdata(itr->ident, itr->name, distance)] = true;
                }
                // create button per map entry (modified copy of <button-template>)
@@ -382,9 +380,8 @@ void FGATCDialog::FreqDisplay(string& ident) {
        int n = 0;      // Number of ATC frequencies at this airport
 
        comm_list_type stations;
-       int found = current_commlist->FindByPos(a->getLongitude(), a->getLatitude(), a->getElevation(), 20.0, &stations);
+       int found = current_commlist->FindByPos(a->geod(), 20.0, &stations);
        if(found) {
-               ostringstream ostr;
                comm_list_iterator itr = stations.begin();
                for (n = 0; itr != stations.end(); ++itr) {
                        if(itr->ident != ident)
@@ -398,8 +395,9 @@ void FGATCDialog::FreqDisplay(string& ident) {
                        copyProperties(freq_group->getNode("group-template", true), entry);
                        entry->removeChildren("enabled", true);
 
+                       ostringstream ostr;
                        ostr << itr->type;
-                       entry->setStringValue("text[0]/label", ostr.str().c_str());
+                       entry->setStringValue("text[0]/label", ostr.str());
 
                        char buf[8];
                        snprintf(buf, 8, "%.2f", (itr->freq / 100.0));  // Convert from KHz to MHz
@@ -408,8 +406,6 @@ void FGATCDialog::FreqDisplay(string& ident) {
                        buf[7] = '\0';
 
                        entry->setStringValue("text[1]/label", buf);
-
-                       ostr.seekp(0);
                        n++;
                }
        }