From 51342929e41100f619d1d48729a03dbca3ae4450 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Fri, 27 Jul 2007 13:11:38 +0300 Subject: [PATCH] Handle the osm filter. Drop up to 10 points, then force add. --- src/gps-nmea-parse.c | 25 ++++++++++++++-------- src/map.c | 49 ++++++++++++++++++++------------------------ src/map.h | 3 +++ 3 files changed, 42 insertions(+), 35 deletions(-) diff --git a/src/gps-nmea-parse.c b/src/gps-nmea-parse.c index 069fba5..41a27b9 100644 --- a/src/gps-nmea-parse.c +++ b/src/gps-nmea-parse.c @@ -24,12 +24,14 @@ #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) { @@ -158,18 +160,25 @@ void channel_parse_rmc(gchar * sentence) /* 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 { diff --git a/src/map.c b/src/map.c index 48fb991..1683868 100644 --- a/src/map.c +++ b/src/map.c @@ -98,8 +98,7 @@ gboolean curl_download_timeout() == 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. */ @@ -115,13 +114,9 @@ gboolean curl_download_timeout() } 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. */ @@ -147,19 +142,15 @@ gboolean curl_download_timeout() 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; } @@ -167,8 +158,7 @@ gboolean curl_download_timeout() /* 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, @@ -197,12 +187,9 @@ gboolean curl_download_timeout() /* 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(); @@ -1388,8 +1375,13 @@ map_set_place_information(osm_way *s, osm_place *mp, osm_place *sp, PoiInfo *p) { 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 : "" : "", @@ -1401,6 +1393,7 @@ snprintf(buffer, sizeof(buffer), "On %s%s%s%s%s%s%s%s%s%s%s", (sp && sp->name) ? sp->name : "", (mp && mp->name) ? " in " : "", (mp && mp->name) ? mp->name : ""); +} gtk_label_set_label(GTK_LABEL(_info_banner), buffer); } @@ -1429,6 +1422,9 @@ if (map_loc.street && osm_way_distance(ilat, ilon, map_loc.street->node_f, map_l 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); @@ -1518,7 +1514,6 @@ gboolean map_cb_button_press(GtkWidget * widget, GdkEventButton * event) gboolean map_cb_button_release(GtkWidget * widget, GdkEventButton * event) { -gint ux,uy; printf("%s()\n", __PRETTY_FUNCTION__); switch (event->button) { diff --git a/src/map.h b/src/map.h index 523ae5d..6986544 100644 --- a/src/map.h +++ b/src/map.h @@ -84,6 +84,9 @@ GHashTable *_pui_by_easy; guint _key_zoom_new; guint _key_zoom_timeout_sid; +gboolean _map_location_known; +gdouble _map_location_dist; + gboolean map_key_zoom_timeout(); gboolean curl_download_timeout(); -- 2.39.5