]> err.no Git - mapper/commitdiff
Handle the osm filter.
authorKaj-Michael Lang <milang@angel.tal.org>
Fri, 27 Jul 2007 10:11:38 +0000 (13:11 +0300)
committerKaj-Michael Lang <milang@angel.tal.org>
Fri, 27 Jul 2007 10:11:38 +0000 (13:11 +0300)
Drop up to 10 points, then force add.

src/gps-nmea-parse.c
src/map.c
src/map.h

index 069fba5391d801f798025b3313a6c9bbfe279dc9..41a27b9ca99855d1ef9d755a364f2abe633e14d0 100644 (file)
 #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 {
index 48fb991f7fbce8005cd84da7797382df605a0fb2..16838683a0f9f82010a352b2a173ec8d3b662a60 100644 (file)
--- 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) {
index 523ae5d5a36d1ecafb2b8f021fb8f633292d3019..6986544344db55884a25c0218ac3d1cc3c38c4ed 100644 (file)
--- 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();