- SGVec3d aircraft = SGVec3d::fromGeod(geod);
-
- // search stations in range
- 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) {
- double distance = distSqr(aircraft, itr->cart);
- uniq[atcdata(itr->ident, itr->name, distance)] = true;
- }
- // create button per map entry (modified copy of <button-template>)
- map<atcdata, bool>::iterator uit = uniq.begin();
- for (int n = 0; uit != uniq.end() && n < 6; ++uit, ++n) { // max 6 buttons
- SGPropertyNode *entry = button_group->getNode("button", n, true);
- copyProperties(button_group->getNode("button-template", true), entry);
- entry->removeChildren("enabled", true);
- entry->setStringValue("legend", uit->first.id.c_str());
- entry->setStringValue("binding[0]/value", uit->first.id.c_str());
- }
- }