Bugfixes for elevation and altitude handling

pull/2/head
Daniel Richman 2012-03-11 18:46:14 +00:00
rodzic 82bffe8a2a
commit 5f0e7be4d0
6 zmienionych plików z 50 dodań i 33 usunięć

Wyświetl plik

@ -3507,7 +3507,7 @@ Fl_Button *gps_pos_save=(Fl_Button *)0;
static void cb_gps_pos_save(Fl_Button*, void*) {
stationary_lat->value(gps_pos_lat->value());
stationary_lon->value(gps_pos_lon->value());
stationary_alt->value(gps_pos_alt->value());
stationary_alt->value(gps_pos_altitude->value());
stationary_lat->do_callback();
stationary_lon->do_callback();
stationary_alt->do_callback();
@ -7731,7 +7731,7 @@ d frequency"));
{ Fl_Float_Input* o = stationary_alt = new Fl_Float_Input(120, 135, 125, 25, _("Altitude"));
stationary_alt->type(1);
stationary_alt->callback((Fl_Callback*)cb_stationary_alt);
o->value(progdefaults.myAlt);
o->value(progdefaults.myAlt.c_str());
} // Fl_Float_Input* stationary_alt
o->end();
} // Fl_Group* o

Wyświetl plik

@ -4484,7 +4484,7 @@ btnApplyConfig->activate();}
label {Save as stationary location}
callback {stationary_lat->value(gps_pos_lat->value());
stationary_lon->value(gps_pos_lon->value());
stationary_alt->value(gps_pos_alt->value());
stationary_alt->value(gps_pos_altitude->value());
stationary_lat->do_callback();
stationary_lon->do_callback();
stationary_alt->do_callback();}
@ -4506,7 +4506,7 @@ progdefaults.changed = true;
dl_fldigi::changed(dl_fldigi::CH_STATIONARY_LOCATION);
btnApplyConfig->activate();}
xywh {120 135 125 25} type Float
code0 {o->value(progdefaults.myAlt);}
code0 {o->value(progdefaults.myAlt.c_str());}
}
}
}

Wyświetl plik

@ -3512,7 +3512,8 @@ int rightof(Fl_Widget* w)
else if (a & FL_ALIGN_RIGHT)
return w->x() + w->w();
else
return w->x() + ((lw > w->w()) ? (lw - w->w())/2 : w->w());
/* wtf? return w->x() + ((lw > w->w()) ? (lw - w->w())/2 : w->w()); */
return w->x() + max(lw, w->w());
} else
return w->x() + w->w() + lw;
}

Wyświetl plik

@ -133,6 +133,9 @@ void DUploaderThread::listener_telemetry()
location::update_stationary();
if (!location::listener_valid)
return;
Json::Value data(Json::objectValue);
/* TODO: HABITAT is it really a good idea to upload time like this? */
@ -325,9 +328,12 @@ void DExtractorManager::data(const Json::Value &d)
{
istringstream lat_strm(d["latitude"].asString());
istringstream lon_strm(d["longitude"].asString());
istringstream alt_strm(d["altitude"].asString());
lat_strm >> location::balloon_latitude;
lon_strm >> location::balloon_longitude;
location::balloon_valid = !lat_strm.fail() && !lon_strm.fail();
alt_strm >> location::balloon_altitude;
location::balloon_valid = !lat_strm.fail() && !lon_strm.fail() &&
!alt_strm.fail();
}
else
{

Wyświetl plik

@ -12,6 +12,7 @@
#include "configuration.h"
#include "fl_digi.h"
#include "confdialog.h"
#include "dl_fldigi/dl_fldigi.h"
#include "dl_fldigi/gps.h"
@ -47,10 +48,11 @@ void update_distance_bearing()
{
habDistance->value("");
habBearing->value("");
habElevation->value("");
return;
}
/* See /habitat_extensions/misc/earthmaths.py. This is a port */
/* See /habitat_extensions/misc/earthmaths.py. */
double c = M_PI/180;
double lat1, lon1, lat2, lon2, alt1, alt2;
lat1 = listener_latitude * c;
@ -60,8 +62,10 @@ void update_distance_bearing()
lon2 = balloon_longitude * c;
alt2 = balloon_altitude;
double d_lon, sa, sb, bearing, aa, ab, angle_at_centre, ta, tb, ea, eb,
elevation, distance;
double radius, d_lon, sa, sb, bearing, aa, ab, angle_at_centre,
great_circle_distance, ta, tb, ea, eb, elevation, distance;
radius = 6371000.0;
d_lon = lon2 - lon1;
sa = cos(lat2) * sin(d_lon);
@ -70,6 +74,7 @@ void update_distance_bearing()
aa = sqrt((sa * sa) + (sb * sb));
ab = (sin(lat1) * sin(lat2)) + (cos(lat1) * cos(lat2) * cos(d_lon));
angle_at_centre = atan2(aa, ab);
great_circle_distance = angle_at_centre * radius;
ta = radius + alt1;
tb = radius + alt2;
@ -116,38 +121,43 @@ void update_stationary()
"while in GPS mode");
}
istringstream lat_strm(progdefaults.myLat), lon_strm(progdefaults.myLon);
if (!progdefaults.myLat.size() || !progdefaults.myLon.size())
{
status_important("unable to set listener location: "
"latitude or longitude missing");
goto fail;
}
istringstream lat_strm(progdefaults.myLat), lon_strm(progdefaults.myLon),
alt_strm(progdefaults.myAlt);
lat_strm >> listener_latitude;
lon_strm >> listener_longitude;
listener_altitude = progdefaults.myAlt;
alt_strm >> listener_altitude;
if (lat_strm.fail())
{
status_important("unable to parse stationary latitude");
goto fail;
}
stationary_lat->color(252);
else
stationary_lat->color(255);
if (lon_strm.fail())
stationary_lon->color(252);
else
stationary_lon->color(255);
if (alt_strm.fail())
stationary_alt->color(252);
else
stationary_alt->color(255);
stationary_lat->redraw();
stationary_lon->redraw();
stationary_alt->redraw();
if (lat_strm.fail() || lon_strm.fail() || alt_strm.fail())
{
status_important("unable to parse stationary longitude");
goto fail;
status_important("couldn't set stationary location: invalid float");
listener_valid = false;
update_distance_bearing();
}
else
{
listener_valid = true;
update_distance_bearing();
}
listener_valid = true;
update_distance_bearing();
return;
fail:
listener_valid = false;
update_distance_bearing();
}
} /* namespace location */

Wyświetl plik

@ -1284,7 +1284,7 @@
ELEM_(std::string, myRadio, "MYRADIO", "Short radio description", "") \
ELEM_(std::string, myLat, "MYLAT", "Stationary listener latitude", "") \
ELEM_(std::string, myLon, "MYLON", "Stationary listener longitude", "") \
ELEM_(double, myAlt, "MYALT", "Stationary listener altitude", 0.0) \
ELEM_(std::string, myAlt, "MYALT", "Stationary listener altitude", "0") \
\
/* habitat Flight selection stuff */ \
ELEM_(std::string, tracking_flight, "FLIGHT_DOCID", "The selected flight", "") \