#include "gps.h"
#include "mapper-types.h"
#include "ui-common.h"
-
+#include "map.h"
#include "track.h"
#include "route.h"
#include "settings.h"
+track_drop_cnt=0;
+
gboolean
channel_cb_error(GIOChannel * src, GIOCondition condition, gpointer data)
{
/* Add new data to track only if we have a fix */
_track_store=TRUE;
+ /* XXX: Set filter logic somewhere else */
+
if ((_conn_state == RCVR_FIXED) && (_track_store==TRUE)) {
- if (_gps_filter==TRUE) {
+ if ( (_gps_filter==TRUE) && (track_drop_cnt<10) ) {
integerize_data(_vel_offsetx, _vel_offsety, _pos, _gps);
- if ( (_gps.hdop<(_filter_hdop/4.0)+2.0 || _filter_hdop==0.0) &&
- (_gps.vdop<(_filter_vdop/4.0)+2.0 || _filter_vdop==0.0) &&
- (fabs(_gps.heading-_gps.lheading)>_filter_angle || _filter_angle==0.0 ) ) {
+ if ( (_gps.hdop<_filter_hdop || _filter_hdop==0.0) &&
+ (_gps.vdop<_filter_vdop || _filter_vdop==0.0) &&
+ (fabs(_gps.heading-_gps.lheading)>_filter_angle || _filter_angle==0.0 ) &&
+ (_map_location_known==TRUE && (_map_location_dist<_filter_osm || _map_location_dist==0.0)) ) {
track_add(_pos.time, newly_fixed);
_gps.lheading=_gps.heading;
+ track_drop_cnt=0;
} else {
- g_printf("*** Droping: H:%f V:%f A:%f (%f %f %f)\n",
- _gps.hdop, _gps.vdop, abs(_gps.heading-_gps.lheading),
- _filter_hdop, _filter_vdop, _filter_angle);
+ track_drop_cnt++;
+ g_printf("*** Filtering by: [%s %s %s %s] (%d)\n",
+ _gps.hdop<_filter_hdop ? "HDOP" : "-",
+ _gps.vdop<_filter_vdop ? "VDOP" : "-",
+ (fabs(_gps.heading-_gps.lheading)<_filter_angle) ? "Angle" : "-",
+ (_map_location_known==TRUE && (_map_location_dist<_filter_osm)) ? "OSM" : "-", track_drop_cnt);
}
refresh_mark();
} else {
== curl_multi_perform(_curl_multi, &num_transfers))
return TRUE; /* Give UI a chance first. */
- while (_curl_multi
- && (msg = curl_multi_info_read(_curl_multi, &num_msgs))) {
+ while (_curl_multi && (msg = curl_multi_info_read(_curl_multi, &num_msgs))) {
if (msg->msg == CURLMSG_DONE) {
if (msg->easy_handle == _autoroute_data.curl_easy) {
/* This is the autoroute download. */
}
cancel_autoroute(TRUE); /* We're done. Clean up. */
} else {
- ProgressUpdateInfo *pui =
- g_hash_table_lookup(_pui_by_easy,
- msg->easy_handle);
- g_queue_push_head(_curl_easy_queue,
- msg->easy_handle);
- g_hash_table_remove(_pui_by_easy,
- msg->easy_handle);
+ ProgressUpdateInfo *pui = g_hash_table_lookup(_pui_by_easy, msg->easy_handle);
+ g_queue_push_head(_curl_easy_queue, msg->easy_handle);
+ g_hash_table_remove(_pui_by_easy, msg->easy_handle);
fclose(pui->file);
if (msg->data.result != CURLE_OK)
g_unlink(pui->dest_str); /* Delete so we try again. */
g_tree_steal(_pui_tree, pui);
g_tree_insert(_downloading_tree, pui, pui);
- pui->src_str =
- map_construct_url(pui->tilex, pui->tiley,
- pui->zoom);
- pui->dest_str =
- g_strdup_printf("%s/%u/%u/%u.jpg",
+ pui->src_str = map_construct_url(pui->tilex, pui->tiley, pui->zoom);
+ pui->dest_str = g_strdup_printf("%s/%u/%u/%u.jpg",
pui->repo->cache_dir, pui->zoom,
pui->tilex, pui->tiley);
if (!pui->src_str) {
/* Failed to generate URL. */
g_idle_add_full(G_PRIORITY_HIGH_IDLE,
- (GSourceFunc)
- map_download_idle_refresh, pui,
+ (GSourceFunc)map_download_idle_refresh, pui,
NULL);
continue;
}
/* Check to see if we need to overwrite. */
if (pui->retries > 0) {
/* We're not updating - check if file already exists. */
- if (g_file_test
- (pui->dest_str, G_FILE_TEST_EXISTS)) {
+ if (g_file_test(pui->dest_str, G_FILE_TEST_EXISTS)) {
g_idle_add_full(G_PRIORITY_HIGH_IDLE,
(GSourceFunc)
map_download_idle_refresh,
/* Need a new curl_easy. */
MACRO_CURL_EASY_INIT(curl_easy);
}
- curl_easy_setopt(curl_easy, CURLOPT_URL,
- pui->src_str);
- curl_easy_setopt(curl_easy, CURLOPT_WRITEDATA,
- f);
- g_hash_table_insert(_pui_by_easy, curl_easy,
- pui);
+ curl_easy_setopt(curl_easy, CURLOPT_URL, pui->src_str);
+ curl_easy_setopt(curl_easy, CURLOPT_WRITEDATA, f);
+ g_hash_table_insert(_pui_by_easy, curl_easy, pui);
if (!_curl_multi) {
/* Initialize CURL. */
_curl_multi = curl_multi_init();
{
gchar buffer[256];
-/* oh, fun */
-snprintf(buffer, sizeof(buffer), "On %s%s%s%s%s%s%s%s%s%s%s",
+if (!s && !mp && !sp) {
+ snprintf(buffer, sizeof(buffer), "Location unknown. %s%s",
+ (p && p->label) ? "Near: " : "",
+ (p && p->label) ? p->label : "");
+} else {
+ /* oh, fun */
+ snprintf(buffer, sizeof(buffer), "On %s%s%s%s%s%s%s%s%s%s%s",
s ? s->name ? s->name : _("unknown") : "?",
s ? s->ref ? ", " : "" : "",
s ? s->ref ? s->ref : "" : "",
(sp && sp->name) ? sp->name : "",
(mp && mp->name) ? " in " : "",
(mp && mp->name) ? mp->name : "");
+}
gtk_label_set_label(GTK_LABEL(_info_banner), buffer);
}
map_loc.street=osm_find_nearest_way(ilat, ilon);
}
+_map_location_known=map_loc.street ? TRUE : FALSE;
+_map_location_dist=map_loc.street ? map_loc.street->dist : 900000.0;
+
p=poi_find_nearest(lat, lon);
fs=osm_find_nearest_place(NODE_PLACE_SUBURB, ilat, ilon, &map_loc.secondary);
gboolean map_cb_button_release(GtkWidget * widget, GdkEventButton * event)
{
-gint ux,uy;
printf("%s()\n", __PRETTY_FUNCTION__);
switch (event->button) {