+void
+wxRadarBg::update_data(const SGPropertyNode *ac, double altitude, double heading,
+ double radius, double bearing, bool selected)
+{
+ osgText::Text *callsign = new osgText::Text;
+ callsign->setFont(_font.get());
+ callsign->setFontResolution(12, 12);
+ callsign->setCharacterSize(_font_size);
+ callsign->setColor(selected ? osg::Vec4(1, 1, 1, 1) : _font_color);
+ osg::Matrixf m(wxRotate(-bearing)
+ * osg::Matrixf::translate(0.0f, radius, 0.0f)
+ * wxRotate(bearing) * _centerTrans);
+
+ osg::Vec3 pos = m.preMult(osg::Vec3(16, 16, 0));
+ // cast to int's, otherwise text comes out ugly
+ callsign->setPosition(osg::Vec3((int)pos.x(), (int)pos.y(), 0));
+ callsign->setAlignment(osgText::Text::LEFT_BOTTOM_BASE_LINE);
+ callsign->setLineSpacing(_font_spacing);
+
+ const char *identity = ac->getStringValue("transponder-id");
+ if (!identity[0])
+ identity = ac->getStringValue("callsign");
+
+ stringstream text;
+ text << identity << endl
+ << setprecision(0) << fixed
+ << setw(3) << setfill('0') << heading * SG_RADIANS_TO_DEGREES << "\xB0 "
+ << setw(0) << altitude << "ft" << endl
+ << ac->getDoubleValue("velocities/true-airspeed-kt") << "kts";
+
+ callsign->setText(text.str());
+ _textGeode->addDrawable(callsign);
+}
+
+
+void
+wxRadarBg::update_aircraft()
+{
+ double diff;
+ double age_factor = 1.0;
+ double test_rng;
+ double test_brg;
+ double range;
+ double bearing;
+ float echo_radius;
+ double angle;
+
+ if (!ground_echoes.empty()){
+ ground_echoes_iterator = ground_echoes.begin();
+
+ while(ground_echoes_iterator != ground_echoes.end()) {
+ diff = _elapsed_time - (*ground_echoes_iterator)->elapsed_time;
+
+ if( diff > _persistance) {
+ ground_echoes.erase(ground_echoes_iterator++);
+ } else {
+// double test_brg = (*ground_echoes_iterator)->bearing;
+// double bearing = test_brg * SG_DEGREES_TO_RADIANS;
+// float angle = calcRelBearing(bearing, _view_heading);
+ double bumpinessFactor = (*ground_echoes_iterator)->bumpiness;
+ float heading = fgGetDouble("/orientation/heading-deg");
+ if ( _display_mode == BSCAN ){
+ test_rng = (*ground_echoes_iterator)->elevation * 6;
+ test_brg = (*ground_echoes_iterator)->bearing;
+ angle = calcRelBearingDeg(test_brg, heading) * 6;
+ range = sqrt(test_rng * test_rng + angle * angle);
+ bearing = atan2(angle, test_rng);
+ //cout << "angle " << angle <<" bearing "
+ // << bearing / SG_DEGREES_TO_RADIANS << endl;
+ echo_radius = (0.1 + (1.9 * bumpinessFactor)) * 240 * age_factor;
+ } else {
+ test_rng = (*ground_echoes_iterator)->range;
+ range = test_rng * SG_METER_TO_NM;
+ test_brg = (*ground_echoes_iterator)->bearing;
+ bearing = test_brg * SG_DEGREES_TO_RADIANS;
+ echo_radius = (0.1 + (1.9 * bumpinessFactor)) * 120 * age_factor;
+ bearing += _angle_offset;
+ }
+
+ float radius = range * _scale;
+ //double heading = 90 * SG_DEGREES_TO_RADIANS;
+ //heading += _angle_offset;
+
+ age_factor = 1;
+
+ if (diff != 0)
+ age_factor = 1 - (0.5 * diff/_persistance);
+
+ float size = echo_radius * UNIT;