menu_cb_gps_show_info(GtkAction * action)
{
_gps_info = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action));
-gps_show_info();
+gps_show_info(_gps);
return TRUE;
}
menu_cb_goto_gps(GtkAction *action)
{
_center_mode = CENTER_LATLON;
-map_center_unit(_pos.unitx, _pos.unity);
+map_center_unit(_gps->unitx, _gps->unity);
map_update_location_from_center();
MACRO_BANNER_SHOW_INFO(_window, _("At GPS coordinates."));
return TRUE;
if (_center_mode > 0) {
/* Auto-Center is enabled - use the GPS position. */
- unit2latlon(_pos.unitx, _pos.unity, lat, lon);
+ lat=_gps->lat;
+ lon=_gps->lon;
} else {
/* Auto-Center is disabled - use the view center. */
unit2latlon(_center.unitx, _center.unity, lat, lon);
}
if (_enable_gps==FALSE)
set_action_activate("autocenter_none", TRUE);
-set_action_sensitive("gps_details", _enable_gps);
set_action_sensitive("goto_gps", _enable_gps);
set_action_sensitive("autocenter_latlon", _enable_gps);
set_action_sensitive("autocenter_lead", _enable_gps);
map_move_mark();
-gps_show_info();
+gps_show_info(_gps);
return TRUE;
}
return TRUE;
}
-gboolean
-menu_cb_gps_details(GtkAction * action)
-{
-gps_details();
-return TRUE;
-}
-
gboolean
menu_cb_settings(GtkAction * action)
{
unit2latlon(unitx, unity, lat, lon);
g_snprintf(buffer, sizeof(buffer), "%s: %.02lf %s", _("Distance"),
- calculate_distance(_gps.lat, _gps.lon, lat, lon) * UNITS_CONVERT[_units], UNITS_TEXT[_units]);
+ calculate_distance(_gps->lat, _gps->lon, lat, lon) * UNITS_CONVERT[_units], UNITS_TEXT[_units]);
MACRO_BANNER_SHOW_INFO(_window, buffer);
}
gdouble lat, lon;
if (_center_mode>0) {
- lat=_gps.lat;
- lon=_gps.lon;
+ lat=_gps->lat;
+ lon=_gps->lon;
} else {
unit2latlon(_center.unitx, _center.unity, lat, lon);
}
poi_info *p;
if (_center_mode>0) {
- lat=_gps.lat;
- lon=_gps.lon;
+ lat=_gps->lat;
+ lon=_gps->lon;
} else {
unit2latlon(_center.unitx, _center.unity, lat, lon);
}
gdouble lat, lon;
if (_center_mode>0) {
- lat=_gps.lat;
- lon=_gps.lon;
+ lat=_gps->lat;
+ lon=_gps->lon;
} else {
unit2latlon(_center.unitx, _center.unity, lat, lon);
}
gboolean
cmenu_cb_loc_set_gps(GtkAction * action)
{
-_pos.unitx = x2unit(_cmenu_position_x);
-_pos.unity = y2unit(_cmenu_position_y);
-unit2latlon(_pos.unitx, _pos.unity, _gps.lat, _gps.lon);
+_gps->unitx = x2unit(_cmenu_position_x);
+_gps->unity = y2unit(_cmenu_position_y);
+unit2latlon(_gps->unitx, _gps->unity, _gps->lat, _gps->lon);
/* Move mark to new location. */
map_refresh_mark();
INFO_FONT_TEXT[_info_font_size], NULL);
/* Save last latitude/longiture. */
-gconf_client_set_float(gconf_client, GCONF_KEY_LAT, _gps.lat, NULL);
-gconf_client_set_float(gconf_client, GCONF_KEY_LON, _gps.lon, NULL);
+gconf_client_set_float(gconf_client, GCONF_KEY_LAT, _gps->lat, NULL);
+gconf_client_set_float(gconf_client, GCONF_KEY_LON, _gps->lon, NULL);
/* Save last center latitude/longitude. */
unit2latlon(_center.unitx, _center.unity, center_lat, center_lon);
_auto_download = gconf_client_get_bool(gconf_client, GCONF_KEY_AUTO_DOWNLOAD, NULL);
/* Get saved location */
-_gps.lat = gconf_client_get_float(gconf_client, GCONF_KEY_LAT, NULL);
-_gps.lon = gconf_client_get_float(gconf_client, GCONF_KEY_LON, NULL);
-if (_gps.lat==0.0) _gps.lat=64.0;
-if (_gps.lon==0.0) _gps.lon=22.0;
+_gps->lat = gconf_client_get_float(gconf_client, GCONF_KEY_LAT, NULL);
+_gps->lon = gconf_client_get_float(gconf_client, GCONF_KEY_LON, NULL);
+if (_gps->lat==0.0) _gps->lat=64.20;
+if (_gps->lon==0.0) _gps->lon=22.20;
/* Home */
_home.valid=TRUE;
/* Turku is default */
if (_home.valid==FALSE) {
- _home.lat=64.0;
- _home.lon=22.0;
+ _home.lat=64.20;
+ _home.lon=22.20;
_home.valid=TRUE;
}
center_lat = gconf_value_get_float(value);
gconf_value_free(value);
} else {
- center_lat = _gps.lat;
+ center_lat = _gps->lat;
}
/* Get last saved longitude. Default is last saved longitude. */
center_lon = gconf_value_get_float(value);
gconf_value_free(value);
} else {
- center_lon = _gps.lon;
+ center_lon = _gps->lon;
}
latlon2unit(center_lat, center_lon, _center.unitx, _center.unity);
_enable_gps = FALSE;
}
-/* Initialize _conn_state based on _enable_gps. */
+/* Initialize _conn_state based on _enable_gps-> */
_conn_state = (_enable_gps ? RCVR_DOWN : RCVR_OFF);
/* Load the route locations. */
{
/* An error has occurred - re-connect(). */
rcvr_disconnect();
-track_add(0, FALSE);
+track_add(NULL, FALSE);
_speed_excess = FALSE;
if (_conn_state > RCVR_OFF) {
gps_conn_set_state(RCVR_DOWN);
- gps_hide_text();
rcvr_connect_later();
}
return FALSE;
/* Data is invalid - not enough satellites?. */
if (_conn_state != RCVR_UP) {
gps_conn_set_state(RCVR_UP);
- track_add(0, FALSE);
+ track_add(NULL, FALSE);
}
}
MACRO_PARSE_FLOAT(tmpd, dpoint - 2);
dpoint[-2] = '\0';
MACRO_PARSE_INT(tmpi, token);
- _gps.lat = tmpi + (tmpd * (1.0 / 60.0));
+ _gps->lat = tmpi + (tmpd * (1.0 / 60.0));
}
/* Parse N or S. */
token = strsep(&sentence, DELIM);
if (token && *token == 'S')
- _gps.lat = -_gps.lat;
+ _gps->lat = -_gps->lat;
/* Parse the longitude. */
token = strsep(&sentence, DELIM);
MACRO_PARSE_FLOAT(tmpd, dpoint - 2);
dpoint[-2] = '\0';
MACRO_PARSE_INT(tmpi, token);
- _gps.lon = tmpi + (tmpd * (1.0 / 60.0));
+ _gps->lon = tmpi + (tmpd * (1.0 / 60.0));
}
/* Parse E or W. */
token = strsep(&sentence, DELIM);
if (token && *token == 'W')
- _gps.lon = -_gps.lon;
+ _gps->lon = -_gps->lon;
/* Parse speed over ground, knots. */
token = strsep(&sentence, DELIM);
if (token && *token) {
- MACRO_PARSE_FLOAT(_gps.speed, token);
- if (_gps.fix > 1) {
- _gps.maxspeed = MAX(_gps.maxspeed, _gps.speed);
- gps_display_data_speed(info_banner.speed, _gps.speed);
+ MACRO_PARSE_FLOAT(_gps->speed, token);
+ if (_gps->fix > FIX_NOFIX) {
+ _gps->maxspeed=MAX(_gps->maxspeed, _gps->speed);
}
}
/* Parse heading, degrees from true north. */
token = strsep(&sentence, DELIM);
if (token && *token) {
- MACRO_PARSE_FLOAT(_gps.heading, token);
+ MACRO_PARSE_FLOAT(_gps->heading, token);
}
/* Parse date. */
gpsdate[6] = '\0'; /* Make sure time is 6 chars long. */
strcat(gpsdate, token);
strptime(gpsdate, "%H%M%S%d%m%y", &time);
- _pos.time = mktime(&time) + _gmtoffset;
+ _gps->time = mktime(&time) + _gmtoffset;
} else
- _pos.time = time(NULL);
+ _gps->time = time(NULL);
/* Add new data to track only if we have a fix */
_track_store=TRUE;
- if ((_conn_state==RCVR_FIXED) && (_track_store==TRUE) && filter_check(&filter, &_gps, &map_loc)==TRUE) {
- gps_integerize_data(&_gps, &_pos);
- track_add(_pos.time, newly_fixed);
- _gps.lheading=_gps.heading;
+ gps_integerize_data(_gps);
+ gps_display_data_speed(info_banner.speed, _gps->speed);
+
+ if ((_conn_state==RCVR_FIXED) && (_track_store==TRUE) && filter_check(&filter, _gps, &map_loc)==TRUE) {
+ track_add(_gps, newly_fixed);
+ _gps->lheading=_gps->heading;
map_refresh_mark();
}
}
/* Parse Fix quality */
token = strsep(&sentence, DELIM);
if (token && *token)
- MACRO_PARSE_INT(_gps.fixquality, token);
+ MACRO_PARSE_INT(_gps->fixquality, token);
/* Skip number of satellites */
token = strsep(&sentence, DELIM);
/* Parse Horizontal dilution of position */
token = strsep(&sentence, DELIM);
if (token && *token)
- MACRO_PARSE_INT(_gps.hdop, token);
+ MACRO_PARSE_INT(_gps->hdop, token);
/* Altitude */
token = strsep(&sentence, DELIM);
if (token && *token) {
- MACRO_PARSE_FLOAT(_pos.altitude, token);
+ MACRO_PARSE_FLOAT(_gps->altitude, token);
} else
- _pos.altitude = NAN;
+ _gps->altitude = NAN;
}
static void
/* 3D fix. */
token = strsep(&sentence, DELIM);
if (token && *token)
- MACRO_PARSE_INT(_gps.fix, token);
+ MACRO_PARSE_INT(_gps->fix, token);
- _gps.satinuse = 0;
+ _gps->satinuse = 0;
for (i = 0; i < 12; i++) {
gint fprn;
token = strsep(&sentence, DELIM);
else
fprn=-1;
satforfix[i]=fprn;
- _gps.sat[i].fix=FALSE;
+ _gps->sat[i].fix=FALSE;
}
for (i=0;i<12;i++)
for (si=0;si<12;si++) {
- if (_gps.sat[i].prn==satforfix[si])
- _gps.sat[i].fix=TRUE;
+ if (_gps->sat[i].prn==satforfix[si])
+ _gps->sat[i].fix=TRUE;
}
/* PDOP */
token = strsep(&sentence, DELIM);
if (token && *token)
- MACRO_PARSE_FLOAT(_gps.pdop, token);
+ MACRO_PARSE_FLOAT(_gps->pdop, token);
/* HDOP */
token = strsep(&sentence, DELIM);
if (token && *token)
- MACRO_PARSE_FLOAT(_gps.hdop, token);
+ MACRO_PARSE_FLOAT(_gps->hdop, token);
/* VDOP */
token = strsep(&sentence, DELIM);
if (token && *token)
- MACRO_PARSE_FLOAT(_gps.vdop, token);
+ MACRO_PARSE_FLOAT(_gps->vdop, token);
}
static void
static guint running_total = 0;
static guint num_sats_used = 0;
static guint satcnt = 0;
- g_printf("%s(): %s\n", __PRETTY_FUNCTION__, sentence);
+ /* g_printf("%s(): %s\n", __PRETTY_FUNCTION__, sentence); */
/* Parse number of messages. */
token = strsep(&sentence, DELIM);
/* Parse number of satellites in view. */
token = strsep(&sentence, DELIM);
if (token && *token) {
- MACRO_PARSE_INT(_gps.satinview, token);
- if (_gps.satinview > 12) /* Handle buggy NMEA. */
- _gps.satinview = 12;
+ MACRO_PARSE_INT(_gps->satinview, token);
+ if (_gps->satinview > 12) /* Handle buggy NMEA. */
+ _gps->satinview = 12;
}
/* Loop until there are no more satellites to parse. */
/* Get token for Satellite Number. */
token = strsep(&sentence, DELIM);
if (token && *token)
- _gps.sat[satcnt].prn = atoi(token);
+ _gps->sat[satcnt].prn = atoi(token);
/* Get token for elevation in degrees (0-90). */
token = strsep(&sentence, DELIM);
if (token && *token)
- _gps.sat[satcnt].elevation = atoi(token);
+ _gps->sat[satcnt].elevation = atoi(token);
/* Get token for azimuth in degrees to true north (0-359). */
token = strsep(&sentence, DELIM);
if (token && *token)
- _gps.sat[satcnt].azimuth = atoi(token);
+ _gps->sat[satcnt].azimuth = atoi(token);
/* Get token for SNR. */
token = strsep(&sentence, DELIM);
- if (token && *token && (_gps.sat[satcnt].snr = atoi(token))) {
+ if (token && *token && (_gps->sat[satcnt].snr = atoi(token))) {
/* SNR is non-zero - add to total and count as used. */
- running_total += _gps.sat[satcnt].snr;
+ running_total += _gps->sat[satcnt].snr;
num_sats_used++;
}
satcnt++;
g_free(buf);
if (_gps_info)
- gps_display_data();
+ gps_display_data(_gps);
if (_satdetails_on)
- gps_display_details();
+ gps_display_details(_gps);
return FALSE;
}
gtk_widget_set_size_request(GTK_WIDGET(text_dop), -1, 30);
gtk_box_pack_start(GTK_BOX(vbox), text_dop, FALSE, TRUE, 0);
-_gps_signal=gtk_gps_new(GTK_GPS_MODE_SKY, &_gps);
+_gps_signal=gtk_gps_new(GTK_GPS_MODE_SKY, _gps);
gtk_widget_set_size_request(_gps_signal, -1, 100);
gtk_box_pack_start(GTK_BOX(vbox), _gps_signal, TRUE, TRUE, 0);
-_gps_compass = gtk_compass_new(&_gps);
+_gps_compass = gtk_compass_new(_gps);
gtk_widget_set_size_request(_gps_compass, -1, 100);
gtk_box_pack_start(GTK_BOX(vbox), _gps_compass, TRUE, TRUE, 0);
gtk_label_set_label(GTK_LABEL(text_speed), " --- ");
gtk_label_set_label(GTK_LABEL(text_alt), " --- ");
gtk_label_set_label(GTK_LABEL(text_dop), " --- ");
-gtk_label_set_label(GTK_LABEL(text_time), "--:--:--");
}
void
-gps_display_data(void)
+gps_display_data(GpsData *gps)
{
gchar buffer[32];
/* local time */
-strftime(buffer, 15, "%X", localtime(&_pos.time));
+strftime(buffer, 15, "%X", localtime(&gps->time));
gtk_label_set_label(GTK_LABEL(text_time), buffer);
-if (_gps.fix < 2) {
+if (gps->fix==FIX_NOFIX) {
/* no fix no fun */
gps_clear_text_fields();
-} else {
- /* latitude */
- lat_format(_degformat, _gps.lat, buffer);
- gtk_label_set_label(GTK_LABEL(text_lat), buffer);
+ return;
+}
- /* longitude */
- lon_format(_degformat, _gps.lon, buffer);
- gtk_label_set_label(GTK_LABEL(text_lon), buffer);
+/* latitude */
+lat_format(_degformat, gps->lat, buffer);
+gtk_label_set_label(GTK_LABEL(text_lat), buffer);
- /* speed */
- gps_display_data_speed(text_speed, _gps.speed);
+/* longitude */
+lon_format(_degformat, gps->lon, buffer);
+gtk_label_set_label(GTK_LABEL(text_lon), buffer);
- /* altitude */
- switch (_units) {
- case UNITS_MI:
- case UNITS_NM:
- g_snprintf(buffer, 32, "Alt: %.1f ft", _pos.altitude * 3.2808399f);
- break;
- default:
- g_snprintf(buffer, 32, "Alt: %.1f m", _pos.altitude);
- }
- gtk_label_set_label(GTK_LABEL(text_alt), buffer);
-
- /* DOP */
- g_snprintf(buffer, 32, "%.1f/%.1f/%.1f", _gps.hdop, _gps.vdop, _gps.pdop);
- gtk_label_set_label(GTK_LABEL(text_dop), buffer);
-}
+/* speed */
+gps_display_data_speed(text_speed, gps->speed);
-return;
+/* altitude */
+switch (_units) {
+case UNITS_MI:
+case UNITS_NM:
+ g_snprintf(buffer, 32, "Alt: %.1f ft", gps->altitude * 3.2808399f);
+ break;
+default:
+ g_snprintf(buffer, 32, "Alt: %.1f m", gps->altitude);
}
+gtk_label_set_label(GTK_LABEL(text_alt), buffer);
-void
-gps_hide_text(void)
-{
-/* Clear gps data */
-_gps.fix = 1;
-_gps.satinuse = 0;
-_gps.satinview = 0;
-
-if (_gps_info)
- gps_display_data();
+/* DOP */
+g_snprintf(buffer, 32, "%.1f/%.1f/%.1f", gps->hdop, gps->vdop, gps->pdop);
+gtk_label_set_label(GTK_LABEL(text_dop), buffer);
}
void
-gps_show_info(void)
+gps_show_info(GpsData *gps)
{
if (_gps_info && _enable_gps)
gtk_widget_show_all(GTK_WIDGET(_gps_widget));
else {
- gps_hide_text();
gtk_widget_hide_all(GTK_WIDGET(_gps_widget));
}
}
gboolean
-gps_display_details(void)
+gps_display_details(GpsData *gps)
{
gchar buffer[32];
-if (_gps.fix < 2) {
+if (gps->fix==FIX_NOFIX) {
/* no fix no fun */
gtk_label_set_label(GTK_LABEL(_sdi_lat), " --- ");
gtk_label_set_label(GTK_LABEL(_sdi_lon), " --- ");
gtk_label_set_label(GTK_LABEL(_sdi_tim), " --:--:-- ");
} else {
/* latitude */
- lat_format(_degformat, _gps.lat, buffer);
+ lat_format(_degformat, gps->lat, buffer);
gtk_label_set_label(GTK_LABEL(_sdi_lat), buffer);
/* longitude */
- lon_format(_degformat, _gps.lon, buffer);
+ lon_format(_degformat, gps->lon, buffer);
gtk_label_set_label(GTK_LABEL(_sdi_lon), buffer);
/* speed */
- gps_display_data_speed(_sdi_spd, _gps.speed);
+ gps_display_data_speed(_sdi_spd, gps->speed);
/* altitude */
switch (_units) {
case UNITS_MI:
case UNITS_NM:
- g_snprintf(buffer, 32, "%.1f ft", _pos.altitude * 3.2808399f);
+ g_snprintf(buffer, 32, "%.1f ft", gps->altitude * 3.2808399f);
break;
default:
- g_snprintf(buffer, 32, "%.1f m", _pos.altitude);
+ g_snprintf(buffer, 32, "%.1f m", gps->altitude);
break;
}
gtk_label_set_label(GTK_LABEL(_sdi_alt), buffer);
/* heading */
- g_snprintf(buffer, 32, "%0.0f° (%0.0f)", _gps.heading, fabs(_gps.heading-_gps.lheading));
+ g_snprintf(buffer, 32, "%0.0f° (%0.0f)", gps->heading, fabs(gps->heading-gps->lheading));
gtk_label_set_label(GTK_LABEL(_sdi_hea), buffer);
/* local time */
- strftime(buffer, 15, "%X", localtime(&_pos.time));
+ strftime(buffer, 15, "%X", localtime(&gps->time));
gtk_label_set_label(GTK_LABEL(_sdi_tim), buffer);
}
/* Sat in view */
-g_snprintf(buffer, 32, "%d", _gps.satinview);
+g_snprintf(buffer, 32, "%d", gps->satinview);
gtk_label_set_label(GTK_LABEL(_sdi_vie), buffer);
/* Sat in use */
-g_snprintf(buffer, 32, "%d", _gps.satinuse);
+g_snprintf(buffer, 32, "%d", gps->satinuse);
gtk_label_set_label(GTK_LABEL(_sdi_use), buffer);
/* fix */
-switch (_gps.fix) {
+switch (gps->fix) {
case 2:
case 3:
- g_snprintf(buffer, 32, "%dD fix", _gps.fix);
+ g_snprintf(buffer, 32, "%dD fix", gps->fix);
break;
default:
g_snprintf(buffer, 32, "nofix");
}
gtk_label_set_label(GTK_LABEL(_sdi_fix), buffer);
-if (_gps.fix == 1)
+if (gps->fix ==FIX_NOFIX)
g_snprintf(buffer, 32, "none");
else {
- switch (_gps.fixquality) {
+ switch (gps->fixquality) {
case 1:
g_strlcat(buffer,_("SPS"),32);
break;
gtk_label_set_label(GTK_LABEL(_sdi_fqu), buffer);
/* max speed */
-gps_display_data_speed(_sdi_msp, _gps.maxspeed);
+gps_display_data_speed(_sdi_msp, gps->maxspeed);
return TRUE;
}
-
-void
-gps_details_dialog(void)
-{
-GtkWidget *dialog;
-
-dialog = gtk_dialog_new_with_buttons(_("GPS Details"),
- GTK_WINDOW(_window),
- GTK_DIALOG_MODAL, GTK_STOCK_OK,
- GTK_RESPONSE_ACCEPT, NULL);
-
-gtk_window_set_default_size(GTK_WINDOW(dialog), 600, 300);
-
-gtk_widget_show_all(dialog);
-_satdetails_on = TRUE;
-gps_display_details();
-while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
- _satdetails_on = FALSE;
- break;
-}
-gtk_widget_destroy(dialog);
-}
-
-void
-gps_details(void)
-{
-GtkWidget *dialog;
-GtkWidget *table;
-GtkWidget *label;
-GtkWidget *notebook;
-
-dialog = gtk_dialog_new_with_buttons(_("GPS Details"),
- GTK_WINDOW(_window),
- GTK_DIALOG_MODAL, GTK_STOCK_OK,
- GTK_RESPONSE_ACCEPT, NULL);
-
-gtk_window_set_default_size(GTK_WINDOW(dialog), 600, 300);
-gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
- notebook = gtk_notebook_new(), TRUE, TRUE, 0);
-
-/* textual info */
-gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
- table = gtk_table_new(4, 6, FALSE),
- label = gtk_label_new(_("GPS Information")));
-
-gtk_table_attach(GTK_TABLE(table),
- label = gtk_label_new(_("Latitude")),
- 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, 0, 20, 4);
-gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-gtk_table_attach(GTK_TABLE(table),
- _sdi_lat = gtk_label_new(" --- "),
- 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4);
-gtk_misc_set_alignment(GTK_MISC(_sdi_lat), 0.f, 0.5f);
-
-gtk_table_attach(GTK_TABLE(table),
- label = gtk_label_new(_("Longitude")),
- 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, 0, 20, 4);
-gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-gtk_table_attach(GTK_TABLE(table),
- _sdi_lon = gtk_label_new(" --- "),
- 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4);
-gtk_misc_set_alignment(GTK_MISC(_sdi_lon), 0.f, 0.5f);
-
-gtk_table_attach(GTK_TABLE(table),
- label = gtk_label_new(_("Speed")),
- 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, 0, 20, 4);
-gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-gtk_table_attach(GTK_TABLE(table),
- _sdi_spd = gtk_label_new(" --- "),
- 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, 0, 2, 4);
-gtk_misc_set_alignment(GTK_MISC(_sdi_spd), 0.f, 0.5f);
-
-gtk_table_attach(GTK_TABLE(table),
- label = gtk_label_new(_("Altitude")),
- 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, 0, 20, 4);
-gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-gtk_table_attach(GTK_TABLE(table),
- _sdi_alt = gtk_label_new(" --- "),
- 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, 0, 2, 4);
-gtk_misc_set_alignment(GTK_MISC(_sdi_alt), 0.f, 0.5f);
-
-gtk_table_attach(GTK_TABLE(table),
- label = gtk_label_new(_("Heading")),
- 0, 1, 4, 5, GTK_EXPAND | GTK_FILL, 0, 20, 4);
-gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-gtk_table_attach(GTK_TABLE(table),
- _sdi_hea = gtk_label_new(" --- "),
- 1, 2, 4, 5, GTK_EXPAND | GTK_FILL, 0, 2, 4);
-gtk_misc_set_alignment(GTK_MISC(_sdi_hea), 0.f, 0.5f);
-
-gtk_table_attach(GTK_TABLE(table),
- label = gtk_label_new(_("Local time")),
- 0, 1, 5, 6, GTK_EXPAND | GTK_FILL, 0, 20, 4);
-gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-gtk_table_attach(GTK_TABLE(table),
- _sdi_tim = gtk_label_new(" --:--:-- "),
- 1, 2, 5, 6, GTK_EXPAND | GTK_FILL, 0, 2, 4);
-gtk_misc_set_alignment(GTK_MISC(_sdi_tim), 0.f, 0.5f);
-
-gtk_table_attach(GTK_TABLE(table),
- label = gtk_label_new(_("Sat in view")),
- 2, 3, 0, 1, GTK_EXPAND | GTK_FILL, 0, 20, 4);
-gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-gtk_table_attach(GTK_TABLE(table),
- _sdi_vie = gtk_label_new("0"),
- 3, 4, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4);
-gtk_misc_set_alignment(GTK_MISC(_sdi_vie), 0.f, 0.5f);
-
-gtk_table_attach(GTK_TABLE(table),
- label = gtk_label_new(_("Sat in use")),
- 2, 3, 1, 2, GTK_EXPAND | GTK_FILL, 0, 20, 4);
-gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-gtk_table_attach(GTK_TABLE(table),
- _sdi_use = gtk_label_new("0"),
- 3, 4, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4);
-gtk_misc_set_alignment(GTK_MISC(_sdi_use), 0.f, 0.5f);
-
-gtk_table_attach(GTK_TABLE(table),
- label = gtk_label_new(_("Fix")),
- 2, 3, 2, 3, GTK_EXPAND | GTK_FILL, 0, 20, 4);
-gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-gtk_table_attach(GTK_TABLE(table),
- _sdi_fix = gtk_label_new(_("nofix")),
- 3, 4, 2, 3, GTK_EXPAND | GTK_FILL, 0, 2, 4);
-gtk_misc_set_alignment(GTK_MISC(_sdi_fix), 0.f, 0.5f);
-
-gtk_table_attach(GTK_TABLE(table),
- label = gtk_label_new(_("Fix Quality")),
- 2, 3, 3, 4, GTK_EXPAND | GTK_FILL, 0, 20, 4);
-gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-gtk_table_attach(GTK_TABLE(table),
- _sdi_fqu = gtk_label_new(_("none")),
- 3, 4, 3, 4, GTK_EXPAND | GTK_FILL, 0, 2, 4);
-gtk_misc_set_alignment(GTK_MISC(_sdi_fqu), 0.f, 0.5f);
-
-gtk_table_attach(GTK_TABLE(table),
- label = gtk_label_new(_("Max speed")),
- 2, 3, 5, 6, GTK_EXPAND | GTK_FILL, 0, 20, 4);
-gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-gtk_table_attach(GTK_TABLE(table),
- _sdi_msp = gtk_label_new(" --- "),
- 3, 4, 5, 6, GTK_EXPAND | GTK_FILL, 0, 2, 4);
-gtk_misc_set_alignment(GTK_MISC(_sdi_msp), 0.f, 0.5f);
-
-gtk_widget_show_all(dialog);
-_satdetails_on = TRUE;
-gps_display_details();
-while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
- _satdetails_on = FALSE;
- break;
-}
-gtk_widget_destroy(dialog);
-}
#define _GPS_PANELS_H
GtkWidget *gps_info_panel(void);
+
void gps_display_data_speed(GtkWidget *widget, gfloat s);
-void gps_display_data(void);
-void gps_show_info(void);
-void gps_hide_text(void);
+void gps_display_data(GpsData *gps);
+void gps_show_info(GpsData *gps);
+gboolean gps_display_details(GpsData *gps);
void gps_details_dialog(void);
#endif
#include "latlon.h"
#include "map.h"
-void
+GpsData *
gps_init(void)
{
-_gps.lat = 0;
-_gps.lon = 0;
-_gps.heading = 0;
-_gps.lheading = 0;
-_gps.fix = 1;
-_gps.satinuse = 0;
-_gps.satinview = 0;
-_gps.speed = 0.f;
-_pos.unitx = 0;
-_pos.unity = 0;
+GpsData *gps;
-gps_integerize_data(&_gps, &_pos);
+gps=g_slice_new0(GpsData);
+gps->fix=FIX_NOFIX;
+gps_integerize_data(gps);
+return gps;
}
/**
* Convert the float lat/lon/speed/heading data into integer units.
*/
void
-gps_integerize_data(GpsData *gps, Point *pos)
+gps_integerize_data(GpsData *gps)
{
gdouble tmp;
-latlon2unit(gps->lat, gps->lon, pos->unitx, pos->unity);
tmp=(gps->heading*(1.f/180.f))*G_PI;
-gps->vel_offsetx=(gint)(floorf(gps->speed*sinf(tmp)+0.5f));
-gps->vel_offsety=-(gint)(floorf(gps->speed*cosf(tmp)+0.5f));
+latlon2unit(gps->lat, gps->lon, gps->unitx, gps->unity);
+gps->vel_offsetx=(gint)(floor(gps->speed*sin(tmp)+0.5f));
+gps->vel_offsety=-(gint)(floor(gps->speed*cos(tmp)+0.5f));
}
typedef struct _GpsIO GpsIO;
struct _GpsIO {
gint fd;
+ GIOChannel *channel;
+ DBusGProxy *rfcomm_req_proxy;
+ GpsIOSourceType src_type;
guint connect_sid;
guint error_sid;
guint input_sid;
guint clater_sid;
- GIOChannel *channel;
- DBusGProxy *rfcomm_req_proxy;
- GpsIOSourceType src_type;
-
gchar buf[GPS_READ_BUF_SIZE];
gchar *curr;
gchar *last;
};
GpsIO gpsio;
+GpsData *_gps;
gchar _gps_read_buf[GPS_READ_BUF_SIZE];
gchar *_gps_read_buf_curr;
gint _gmtoffset;
-/** GPS data. */
-GpsData _gps;
-Point _pos;
-
-void gps_init(void);
-void gps_integerize_data(GpsData *gps, Point *pos);
+GpsData *gps_init(void);
+void gps_integerize_data(GpsData *gps);
gboolean channel_cb_error(GIOChannel * src, GIOCondition condition, gpointer data);
gboolean channel_cb_input(GIOChannel * src, GIOCondition condition, gpointer data);
*/
typedef struct _GpsData GpsData;
struct _GpsData {
- guint fix;
- guint fixquality;
gdouble lat;
gdouble lon;
+ guint unitx;
+ guint unity;
+ time_t time;
+ GpsFix fix;
+ guint fixquality;
gfloat speed;
gfloat maxspeed;
gfloat avgspeed;
+ gfloat altitude;
gfloat heading;
gfloat lheading;
gfloat hdop;
/* Initialize fields. Do no use g_ascii_formatd; these strings will be
* output (and parsed) as locale-dependent. */
- g_snprintf(buffer, sizeof(buffer), "%.06f", _gps.lat);
+ g_snprintf(buffer, sizeof(buffer), "%.06f", _gps->lat);
gtk_label_set_text(GTK_LABEL(lbl_gps_lat), buffer);
- g_snprintf(buffer, sizeof(buffer), "%.06f", _gps.lon);
+ g_snprintf(buffer, sizeof(buffer), "%.06f", _gps->lon);
gtk_label_set_text(GTK_LABEL(lbl_gps_lon), buffer);
unit2latlon(_center.unitx, _center.unity, lat, lon);
void
map_set_mark(void)
{
-mark_x1 = unit2x(_pos.unitx);
-mark_y1 = unit2y(_pos.unity);
-mark_x2 = mark_x1 + (_show_velvec ? _gps.vel_offsetx : 0);
-mark_y2 = mark_y1 + (_show_velvec ? _gps.vel_offsety : 0);
+mark_x1 = unit2x(_gps->unitx);
+mark_y1 = unit2y(_gps->unity);
+mark_x2 = mark_x1 + (_show_velvec ? _gps->vel_offsetx : 0);
+mark_y2 = mark_y1 + (_show_velvec ? _gps->vel_offsety : 0);
mark_minx = MIN(mark_x1, mark_x2) - (2 * _draw_width);
mark_miny = MIN(mark_y1, mark_y2) - (2 * _draw_width);
mark_width = abs(mark_x1 - mark_x2) + (4 * _draw_width);
gboolean
map_update_location_from_gps(void)
{
-map_update_location(_gps.lat, _gps.lon, FALSE);
+map_update_location(_gps->lat, _gps->lon, FALSE);
return FALSE;
}
/* Force re-validation of place if user is clicking around */
map_loc.valid=FALSE;
/* XXX: hmm, not the right place for this */
-if (_gps.fix<2) {
- _pos.unitx=_center.unitx;
- _pos.unity=_center.unity;
- unit2latlon(_pos.unitx, _pos.unity, _gps.lat, _gps.lon);
+if (_gps->fix==FIX_NOFIX) {
+ _gps->unitx=_center.unitx;
+ _gps->unity=_center.unity;
+ unit2latlon(_gps->unitx, _gps->unity, _gps->lat, _gps->lon);
}
unit2latlon(_center.unitx, _center.unity, lat, lon);
map_update_location(lat, lon, TRUE);
gfloat cur_speed;
gchar *buffer;
-cur_speed = _gps.speed * UNITS_CONVERT[_units];
+cur_speed = _gps->speed * UNITS_CONVERT[_units];
gc=(cur_speed > _speed_limit) ? speed_gc1 : speed_gc2;
buffer = g_strdup_printf("%0.0f", cur_speed);
map_information_text(10, 10, gc, buffer);
if (zoom_timeout_sid==0)
return FALSE;
-z=(z+_gps.speed+1)/5;
+z=(z+_gps->speed+1)/5;
if (z>5) z=5.0; else if (z<1) z=1.0;
iz=(gint)roundf(z);
#ifdef DEBUG
-g_printf("Setting autozoom to: %f %d S:%f\n", z, iz, _gps.speed);
+g_printf("Setting autozoom to: %f %d S:%f\n", z, iz, _gps->speed);
#endif
if (iz>last)
iz=last+1;
{
if (az==TRUE) {
MACRO_BANNER_SHOW_INFO(_window, "Autozoom enabled");
- zoom_timeout_sid=g_timeout_add(_gps.speed<5 ? 2000 : 5000, (GSourceFunc) map_autozoomer, NULL);
+ zoom_timeout_sid=g_timeout_add(_gps->speed<5 ? 2000 : 5000, (GSourceFunc) map_autozoomer, NULL);
return;
} else {
if (zoom_timeout_sid) {
static void
map_draw_track(gint x, gint y)
{
-_pos.unitx = x2unit((gint) (x + 0.5));
-_pos.unity = y2unit((gint) (y + 0.5));
-unit2latlon(_pos.unitx, _pos.unity, _gps.lat, _gps.lon);
-_gps.speed = 20.f;
-gps_integerize_data(&_gps, &_pos);
+_gps->unitx=x2unit((gint) (x + 0.5));
+_gps->unity=y2unit((gint) (y + 0.5));
+unit2latlon(_gps->unitx, _gps->unity, _gps->lat, _gps->lon);
+_gps->speed=20.f;
+gps_integerize_data(_gps);
track_add(time(NULL), FALSE);
map_refresh_mark();
}
ilat=lat2mp_int(lat);
ilon=lon2mp_int(lon);
-if (_gps.fix>1 && !force)
- osm_set_way_range_from_speed(_gps.speed);
+if (_gps->fix>1 && !force)
+ osm_set_way_range_from_speed(_gps->speed);
else
osm_set_way_range(OSM_RANGE_WAY/4);
#define unit2y(unit) (unit2pixel(unit) - tile2pixel(_base_tiley) - _offsety)
#define y2unit(y) (pixel2unit(y + _offsety) + tile2unit(_base_tiley))
-#define leadx2unit() (_pos.unitx + (_lead_ratio) * pixel2unit(_gps.vel_offsetx))
-#define leady2unit() (_pos.unity + (0.6f*_lead_ratio)*pixel2unit(_gps.vel_offsety))
+#define leadx2unit() (_gps->unitx + (_lead_ratio) * pixel2unit(_gps->vel_offsetx))
+#define leady2unit() (_gps->unity + (0.6f*_lead_ratio)*pixel2unit(_gps->vel_offsety))
/* Pans are done two "grids" at a time, or 64 pixels. */
#define PAN_UNITS (grid2unit(2))
center_unity = leady2unit(); \
break; \
case CENTER_LATLON: \
- center_unitx = _pos.unitx; \
- center_unity = _pos.unity; \
+ center_unitx = _gps->unitx; \
+ center_unity = _gps->unity; \
break; \
default: \
center_unitx = _center.unitx; \
};
#define MACRO_RECALC_OFFSET() { \
- _offsetx = grid2pixel( \
- unit2grid(_center.unitx) \
- - _screen_grids_halfwidth \
- - tile2grid(_base_tilex)); \
- _offsety = grid2pixel( \
- unit2grid(_center.unity) \
- - _screen_grids_halfheight \
- - tile2grid(_base_tiley)); \
+ _offsetx = grid2pixel(unit2grid(_center.unitx) - _screen_grids_halfwidth - tile2grid(_base_tilex)); \
+ _offsety = grid2pixel(unit2grid(_center.unity) - _screen_grids_halfheight - tile2grid(_base_tiley)); \
}
#define MACRO_RECALC_FOCUS_BASE() { \
}
#define MACRO_QUEUE_DRAW_AREA() \
- gtk_widget_queue_draw_area( \
- _map_widget, \
- 0, 0, \
- _screen_width_pixels, \
- _screen_height_pixels)
+ gtk_widget_queue_draw_area(_map_widget, 0, 0, _screen_width_pixels, _screen_height_pixels)
/* Render all on-map metadata an annotations, including POI and paths. */
#define MACRO_MAP_RENDER_DATA() { \
MAPPER_INIT_START=0,
MAPPER_INIT_MISC,
MAPPER_INIT_CONFIG,
- MAPPER_INIT_GPS,
MAPPER_INIT_DB,
MAPPER_INIT_POI,
MAPPER_INIT_OSM,
_conn_state = RCVR_OFF;
curl_global_init(CURL_GLOBAL_NOTHING);
gnome_vfs_init();
+ _gps=gps_init();
timezone_init();
gpx_init();
variables_init();
case MAPPER_INIT_CONFIG:
config_init();
map_download_init();
- mis=MAPPER_INIT_GPS;
+ mis=MAPPER_INIT_DB;
p=0.2;
w="Config";
break;
- case MAPPER_INIT_GPS:
- gps_init();
- mis=MAPPER_INIT_DB;
- p=0.3;
- w="GPS";
- break;
case MAPPER_INIT_DB:
if (db_connect(&_db, _mapper_db)) {
mis=MAPPER_INIT_POI;
/* Check if we are still near the same way as last time */
if (map_loc->street && osm_way_distance(lat, lon, map_loc->street->node_f, map_loc->street->node_t, &dist)==TRUE) {
/* We are probably on the same way as last time */
- if ( (dist>(gdouble)way_dist_range) || (fabs(_gps.heading-map_loc->heading)>10.0)) {
+ if ( (dist>(gdouble)way_dist_range) || (fabs(_gps->heading-map_loc->heading)>10.0)) {
/* We have moved a large amount, check way again */
g_printf("*** dist %f over range, checking again\n", dist);
osm_way_free(map_loc->street);
}
if (map_loc->changed==TRUE) {
- map_loc->heading=_gps.heading;
- map_loc->speed=_gps.speed;
+ map_loc->heading=_gps->heading;
+ map_loc->speed=_gps->speed;
}
#if 0
#include "help.h"
+#define DISTANCE_SQUARED(a, b) \
+ ((guint64)((((gint64)(b).unitx)-(a).unitx)*(((gint64)(b).unitx)-(a).unitx))\
+ + (guint64)((((gint64)(b).unity)-(a).unity)*(((gint64)(b).unity)-(a).unity)))
+
void route_find_nearest_point(void);
void cancel_autoroute(gboolean temporary);
void route_show_distance_to_last(void);
gchar buffer[80];
gchar strlat[32];
gchar strlon[32];
- g_ascii_formatd(strlat, 32, "%.06f", _gps.lat);
- g_ascii_formatd(strlon, 32, "%.06f", _gps.lon);
+ g_ascii_formatd(strlat, 32, "%.06f", _gps->lat);
+ g_ascii_formatd(strlon, 32, "%.06f", _gps->lon);
g_snprintf(buffer, sizeof(buffer), "%s, %s", strlat, strlon);
gtk_entry_set_text(GTK_ENTRY(oti->txt_from), buffer);
} else if (toggle == oti->rad_use_route) {
{
gchar latstr[32], lonstr[32], *latlonstr;
-g_ascii_dtostr(latstr, 32, _gps.lat);
-g_ascii_dtostr(lonstr, 32, _gps.lon);
+g_ascii_dtostr(latstr, 32, _gps->lat);
+g_ascii_dtostr(lonstr, 32, _gps->lon);
latlonstr = g_strdup_printf("%s,%s", latstr, lonstr);
_autoroute_data.src_str =
g_strdup_printf(_route_dl_url, latlonstr, _autoroute_data.dest);
/* First, set near_dist_squared with the new distance from
* _near_point. */
near = _near_point;
- near_dist_squared = DISTANCE_SQUARED(_pos, *near);
+ near_dist_squared = DISTANCE_SQUARED(*_gps, *near);
/* Now, search _route for a closer point. If quick is TRUE, then we'll
* only search forward, only as long as we keep finding closer points.
*/
for (curr = _near_point; curr++ != _route.tail;) {
if (curr->unity) {
- guint dist_squared = DISTANCE_SQUARED(_pos, *curr);
+ guint dist_squared = DISTANCE_SQUARED(*_gps, *curr);
if (dist_squared <= near_dist_squared) {
near = curr;
near_dist_squared = dist_squared;
for (wnext = wcurr = _next_way; wcurr != _route.wtail; wcurr++) {
if (wcurr->point < near || (wcurr->point == near && quick
- && (_next_wpt && (DISTANCE_SQUARED(_pos, *near) > _next_way_dist_squared
- && DISTANCE_SQUARED(_pos, *_next_wpt) < _next_wpt_dist_squared))))
+ && (_next_wpt && (DISTANCE_SQUARED(*_gps, *near) > _next_way_dist_squared
+ && DISTANCE_SQUARED(*_gps, *_next_wpt) < _next_wpt_dist_squared))))
/* Okay, this else if expression warrants explanation. If the
* nearest track point happens to be a waypoint, then we want to
* check if we have "passed" that waypoint. To check this, we
- * test the distance from _pos to the waypoint and from _pos to
+ * test the distance from _gps to the waypoint and from _gps to
* _next_wpt, and if the former is increasing and the latter is
* decreasing, then we have passed the waypoint, and thus we
* should skip it. Note that if there is no _next_wpt, then
}
if (wnext == _route.wtail && (wnext->point < near || (wnext->point == near && quick
- && (_next_wpt && (DISTANCE_SQUARED (_pos, *near) > _next_way_dist_squared
- && DISTANCE_SQUARED(_pos, *_next_wpt) < _next_wpt_dist_squared)))))
+ && (_next_wpt && (DISTANCE_SQUARED (*_gps, *near) > _next_way_dist_squared
+ && DISTANCE_SQUARED(*_gps, *_next_wpt) < _next_wpt_dist_squared)))))
{
_next_way = NULL;
_next_wpt = NULL;
}
ret = TRUE;
}
- _next_way_dist_squared = DISTANCE_SQUARED(_pos, *wnext->point);
+ _next_way_dist_squared = DISTANCE_SQUARED(*_gps, *wnext->point);
if (_next_wpt)
- _next_wpt_dist_squared = DISTANCE_SQUARED(_pos, *_next_wpt);
+ _next_wpt_dist_squared = DISTANCE_SQUARED(*_gps, *_next_wpt);
}
}
return ret;
if (point == NULL)
return FALSE;
-unit2latlon(_pos.unitx, _pos.unity, lat1, lon1);
+unit2latlon(_gps->unitx, _gps->unity, lat1, lon1);
if (point > _near_point) {
Point *curr;
/* Skip _near_point in case we have already passed it. */
/* POI */
#define GCONF_KEY_POI_ZOOM GCONF_KEY_PREFIX"/poi_zoom"
+#define GCONF_KEY_POI_THEME_BASE GCONF_KEY_PREFIX"/poi_theme_base"
+#define GCONF_KEY_POI_ICON_THEME GCONF_KEY_PREFIX"/poi_icon_theme"
#define GCONF_KEY_AUTOCENTER_MODE GCONF_KEY_PREFIX"/autocenter_mode"
#define GCONF_KEY_LEAD_AMOUNT GCONF_KEY_PREFIX"/lead_amount"
gtk_widget_destroy(confirm);
}
-gfloat
-track_calculate_distance_from(Point * point)
+gdouble
+track_calculate_distance_from(Point *point)
{
-gfloat lat1, lon1, lat2, lon2;
-gfloat sum = 0.0;
+gdouble lat1, lon1, lat2, lon2;
+gdouble sum = 0.0;
Point *curr;
-unit2latlon(_pos.unitx, _pos.unity, lat1, lon1);
+unit2latlon(_gps->unitx, _gps->unity, lat1, lon1);
-/* Skip _track.tail because that should be _pos. */
+/* Skip _track.tail because that should be _gps. */
for (curr = _track.tail; curr > point; --curr) {
if (curr->unity) {
unit2latlon(curr->unitx, curr->unity, lat2, lon2);
track_show_distance_from(Point * point)
{
gchar buffer[80];
-gfloat sum;
+gdouble sum;
sum = track_calculate_distance_from(point);
* data, as well as calling osso_display_state_on() when we have the focus.
*
* If a non-zero time is given, then the current position (as taken from the
- * _pos variable) is appended to _track with the given time. If time is zero,
+ * _gps variable) is appended to _track with the given time. If time is zero,
* then _point_null is appended to _track with time zero (this produces a "break"
* in the track).
*/
void
-track_add(time_t time, gboolean newly_fixed)
+track_add(GpsData *gps, gboolean newly_fixed)
{
gboolean show_directions = TRUE;
gint announce_thres_unsquared;
-if (abs((gint)_pos.unitx-_track.tail->unitx) > _draw_width || abs((gint)_pos.unity-_track.tail->unity) > _draw_width) {
- /* If time != 0, update the nearest-waypoint data. */
- if (time && _route.head != _route.tail &&
- (newly_fixed ? (route_find_nearest_point(), TRUE) : route_update_nears(TRUE))) {
+if (!gps) {
+ MACRO_PATH_INCREMENT_TAIL(_track);
+ *_track.tail=_point_null;
+ return;
+}
+
+if (abs((gint)gps->unitx-_track.tail->unitx) > _draw_width || abs((gint)gps->unity-_track.tail->unity) > _draw_width) {
+
+ /* If gps is available, update the nearest-waypoint data. */
+ if (gps && _route.head != _route.tail && (newly_fixed ? (route_find_nearest_point(), TRUE) : route_update_nears(TRUE))) {
/* Nearest waypoint has changed - re-render paths. */
map_render_paths();
MACRO_QUEUE_DRAW_AREA();
/* Instead of calling map_render_paths(), we'll draw the new line
* ourselves and call gtk_widget_queue_draw_area(). */
- map_render_segment(_gc[COLORABLE_TRACK],
- _gc[COLORABLE_TRACK_BREAK],
- _track.tail->unitx, _track.tail->unity,
- _pos.unitx, _pos.unity);
+ map_render_segment(_gc[COLORABLE_TRACK], _gc[COLORABLE_TRACK_BREAK],
+ _track.tail->unitx, _track.tail->unity, gps->unitx, gps->unity);
- if (time && _track.tail->unity) {
+ if (_track.tail->unity && _track.tail->unitx) {
tx1 = unit2x(_track.tail->unitx);
ty1 = unit2y(_track.tail->unity);
- tx2 = unit2x(_pos.unitx);
- ty2 = unit2y(_pos.unity);
+ tx2 = unit2x(gps->unitx);
+ ty2 = unit2y(gps->unity);
gtk_widget_queue_draw_area(_map_widget,
MIN(tx1, tx2) - _draw_width,
MIN(ty1, ty2) - _draw_width,
}
MACRO_PATH_INCREMENT_TAIL(_track);
+ _track.tail->unitx=gps->unitx;
+ _track.tail->unity=gps->unity;
+ _track.tail->time=gps->time;
+ _track.tail->altitude=gps->altitude;
+}
- if (time)
- *_track.tail = _pos;
- else
- *_track.tail = _point_null;
-
- if (_autoroute_data.enabled && !_autoroute_data.in_progress && _near_point_dist_squared > 400) {
- MACRO_BANNER_SHOW_INFO(_window, _("Recalculating directions..."));
- _autoroute_data.in_progress = TRUE;
- show_directions = FALSE;
- g_idle_add((GSourceFunc) auto_route_dl_idle, NULL);
- }
-
- /* Keep the display on. */
- KEEP_DISPLAY_ON();
+if (_autoroute_data.enabled && !_autoroute_data.in_progress && _near_point_dist_squared > 400) {
+ MACRO_BANNER_SHOW_INFO(_window, _("Recalculating directions..."));
+ _autoroute_data.in_progress = TRUE;
+ show_directions = FALSE;
+ g_idle_add((GSourceFunc)auto_route_dl_idle, NULL);
}
-announce_thres_unsquared=(20+(guint)_gps.speed)*_announce_notice_ratio*3;
+announce_thres_unsquared=(20+(guint)gps->speed)*_announce_notice_ratio*3;
/* Check if we should announce upcoming waypoints. */
-if (show_directions && time && _next_way_dist_squared < (announce_thres_unsquared * announce_thres_unsquared)) {
+if (gps && show_directions && _next_way_dist_squared < (announce_thres_unsquared * announce_thres_unsquared)) {
if (_enable_voice && g_strcmp0(_next_way->desc, _last_spoken_phrase)) {
g_free(_last_spoken_phrase);
_last_spoken_phrase=g_strdup(_next_way->desc);
}
MACRO_BANNER_SHOW_INFO(_window, _next_way->desc);
}
+
+/* Keep the display on if we are moving. */
+KEEP_DISPLAY_ON();
}
void
gboolean
track_insert_mark(void)
{
-gfloat lat, lon;
+gdouble lat, lon;
gchar tmp1[16], tmp2[16], *p_latlon;
GtkWidget *dialog;
GtkWidget *table;
gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Lat, Lon")), 0, 1, 0, 1, GTK_FILL, 0, 2, 4);
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-unit2latlon(_pos.unitx, _pos.unity, lat, lon);
+unit2latlon(_gps->unitx, _gps->unity, lat, lon);
lat_format(_degformat, lat, tmp1);
lon_format(_degformat, lon, tmp2);
p_latlon = g_strdup_printf("%s, %s", tmp1, tmp2);
void track_init(void);
void track_deinit(void);
-void track_add(time_t time, gboolean newly_fixed);
+void track_add(GpsData *gps, gboolean newly_fixed);
void track_insert_break(void);
gboolean track_insert_mark(void);
gboolean track_save(void);
#include <glib/gi18n.h>
#include "gtkgps.h"
+#include "gtkcompass.h"
#include "hildon-mapper.h"
" <menuitem action='autocenter_none'/>"
" </menu>"
" </menu>"
+" <menu action='search'>"
+" <menuitem action='poi_search'/>"
+" <menuitem action='search_address'/>"
+" </menu>"
" <menu action='track'>"
" <menuitem action='track_open'/>"
" <menuitem action='track_save'/>"
" <menuitem action='route_clear'/>"
" </menu>"
" <menu action='poi'>"
-" <menuitem action='poi_search'/>"
" <menuitem action='poi_categories'/>"
" <separator/>"
" <menuitem action='poi_import'/>"
" <menuitem action='goto_destination'/>"
" <menuitem action='goto_gps'/>"
" <separator/>"
-" <menuitem action='search_address'/>"
" <menuitem action='goto_latlon'/>"
" <menuitem action='goto_nearpoi'/>"
" <menuitem action='goto_nextway'/>"
" <menuitem action='gps_enabled'/>"
" <menuitem action='gps_information'/>"
" <separator/>"
-" <menuitem action='gps_details'/>"
-" <separator/>"
" <menuitem action='gps_settings'/>"
" </menu>"
" <menu action='help'>"
{"poi_settings", GTK_STOCK_PREFERENCES, N_("_Settings..."), NULL, NULL, NULL },
{"poi_add", GTK_STOCK_ADD, N_("_Add"), "<control>A", NULL, G_CALLBACK(cb_poi_add) },
{"poi_quick_add", GTK_STOCK_ABOUT, N_("_Quick Add"), "<control>E", NULL, G_CALLBACK(cb_poi_add) },
- {"poi_search", GTK_STOCK_FIND, N_("_Search..."), NULL, NULL, G_CALLBACK(cb_poi_search) },
{"poi_import", GTK_STOCK_OPEN, N_("_Import..."), NULL, NULL, NULL },
{"poi_export", GTK_STOCK_SAVE, N_("_Export..."), NULL, NULL, NULL },
+ {"search", NULL, N_("_Search"), NULL, NULL, NULL },
+ {"poi_search", GTK_STOCK_FIND, N_("_Search..."), NULL, NULL, G_CALLBACK(cb_poi_search) },
+ {"search_address", GTK_STOCK_FIND, N_("Address..."), NULL, NULL, G_CALLBACK(menu_cb_search_address) },
+
{"map", NULL, N_("_Map"), NULL, NULL, NULL },
{"map_maps", NULL, N_("_Maps"), NULL, NULL, NULL },
{"map_manager", NULL, N_("Manager..."), NULL, NULL, G_CALLBACK(menu_cb_mapman) },
{"goto_home", GTK_STOCK_HOME, N_("_Home"), "<control>H", NULL, G_CALLBACK(menu_cb_goto_home) },
{"goto_destination", GTK_STOCK_JUMP_TO, N_("_Destination"), "<control>J", NULL, G_CALLBACK(menu_cb_goto_destination) },
{"goto_gps", NULL, N_("_GPS"), "<control>G", NULL, G_CALLBACK(menu_cb_goto_gps) },
- {"search_address", GTK_STOCK_FIND, N_("Address..."), NULL, NULL, G_CALLBACK(menu_cb_search_address) },
{"goto_latlon", NULL, N_("Lat/Lon"), NULL, NULL, G_CALLBACK(menu_cb_goto_latlon) },
{"goto_nextway", NULL, N_("Next Waypoint"), NULL, NULL, G_CALLBACK(menu_cb_goto_nextway) },
{"goto_nearpoi", NULL, N_("Near POI"), NULL, NULL, G_CALLBACK(menu_cb_goto_nearpoi) },
{"gps", NULL, N_("Gp_s"), NULL, NULL, NULL },
- {"gps_details", GTK_STOCK_INFO, N_("_Details..."), NULL, NULL, G_CALLBACK(menu_cb_gps_details) },
{"gps_settings", NULL, N_("_Settings..."), NULL, NULL, NULL },
};
static guint n_ui_entries = G_N_ELEMENTS (ui_entries);
/* GPS Tab */
vbox = gtk_vbox_new(FALSE, 0);
label = gtk_label_new("Gps");
-_gps_sat_view = gtk_gps_new(GTK_GPS_MODE_SKY, &_gps);
+_gps_sat_view = gtk_gps_new(GTK_GPS_MODE_SKY, _gps);
gtk_box_pack_start(GTK_BOX(vbox), _gps_sat_view, TRUE, TRUE, 0);
-_gps_sat_view = gtk_gps_new(GTK_GPS_MODE_SIGNAL, &_gps);
+_gps_sat_view = gtk_gps_new(GTK_GPS_MODE_SIGNAL, _gps);
gtk_box_pack_start(GTK_BOX(vbox), _gps_sat_view, TRUE, TRUE, 0);
ui_notebook.gps=gtk_notebook_append_page(notebook, vbox, label);
/* Heading Tab */
vbox = gtk_vbox_new(FALSE, 0);
label = gtk_label_new("Heading");
-_tab_compass = gtk_compass_new(&_gps);
+_tab_compass = gtk_compass_new(_gps);
gtk_box_pack_start(GTK_BOX(vbox), _tab_compass, TRUE, TRUE, 0);
ui_notebook.heading=gtk_notebook_append_page(notebook, vbox, label);
} \
}
-#define DISTANCE_SQUARED(a, b) \
- ((guint64)((((gint64)(b).unitx)-(a).unitx)*(((gint64)(b).unitx)-(a).unitx))\
- + (guint64)((((gint64)(b).unity)-(a).unity)*(((gint64)(b).unity)-(a).unity)))
-
-
#ifdef WITH_OSSO
#define KEEP_DISPLAY_ON() { \
/* Note that the flag means keep on ONLY when fullscreen. */ \