mapper_SOURCES = utils.c \
file.c \
gpx.c \
+ filter.c \
gps.c \
gps-browse.c \
gps-nmea-parse.c \
#include "ui-common.h"
#include "settings.h"
#include "gpx.h"
+#include "filter.h"
void
config_update_proxy(void)
}
gboolean
-config_save_filter(void)
+config_save_filter(GpsTrackFilter *f)
{
/* Filtering */
-gconf_client_set_bool(gconf_client, GCONF_KEY_GPS_FILTER, _gps_filter, NULL);
-gconf_client_set_float(gconf_client, GCONF_KEY_GPS_FILTER_HDOP, _filter_hdop, NULL);
-gconf_client_set_float(gconf_client, GCONF_KEY_GPS_FILTER_VDOP, _filter_vdop, NULL);
-gconf_client_set_float(gconf_client, GCONF_KEY_GPS_FILTER_ANGLE, _filter_angle, NULL);
-gconf_client_set_float(gconf_client, GCONF_KEY_GPS_FILTER_OSM, _filter_osm, NULL);
-gconf_client_set_float(gconf_client, GCONF_KEY_GPS_FILTER_MAXDROP, _filter_maxdrop, NULL);
+gconf_client_set_bool(gconf_client, GCONF_KEY_GPS_FILTER, f->enabled, NULL);
+gconf_client_set_float(gconf_client, GCONF_KEY_GPS_FILTER_HDOP, f->hdop, NULL);
+gconf_client_set_float(gconf_client, GCONF_KEY_GPS_FILTER_VDOP, f->vdop, NULL);
+gconf_client_set_float(gconf_client, GCONF_KEY_GPS_FILTER_ANGLE, f->angle, NULL);
+gconf_client_set_float(gconf_client, GCONF_KEY_GPS_FILTER_OSM, f->osm, NULL);
+gconf_client_set_float(gconf_client, GCONF_KEY_GPS_FILTER_MAXDROP, f->maxdrop, NULL);
gconf_client_suggest_sync(gconf_client, NULL);
return TRUE;
/* Get Always Keep On flag. Default is FALSE. */
_always_keep_on = gconf_client_get_bool(gconf_client,GCONF_KEY_ALWAYS_KEEP_ON, NULL);
-_gps_filter = gconf_client_get_bool(gconf_client, GCONF_KEY_GPS_FILTER, NULL);
-_filter_hdop = gconf_client_get_float(gconf_client, GCONF_KEY_GPS_FILTER_HDOP, NULL);
-_filter_vdop = gconf_client_get_float(gconf_client, GCONF_KEY_GPS_FILTER_VDOP, NULL);
-_filter_angle = gconf_client_get_float(gconf_client, GCONF_KEY_GPS_FILTER_ANGLE, NULL);
-_filter_osm = gconf_client_get_float(gconf_client, GCONF_KEY_GPS_FILTER_OSM, NULL);
-_filter_maxdrop = gconf_client_get_float(gconf_client, GCONF_KEY_GPS_FILTER_MAXDROP, NULL);
-BOUND(_filter_maxdrop, 0, 60);
+filter.enabled = gconf_client_get_bool(gconf_client, GCONF_KEY_GPS_FILTER, NULL);
+filter.hdop = gconf_client_get_float(gconf_client, GCONF_KEY_GPS_FILTER_HDOP, NULL);
+filter.vdop = gconf_client_get_float(gconf_client, GCONF_KEY_GPS_FILTER_VDOP, NULL);
+filter.angle = gconf_client_get_float(gconf_client, GCONF_KEY_GPS_FILTER_ANGLE, NULL);
+filter.osm = gconf_client_get_float(gconf_client, GCONF_KEY_GPS_FILTER_OSM, NULL);
+filter.maxdrop = gconf_client_get_float(gconf_client, GCONF_KEY_GPS_FILTER_MAXDROP, NULL);
+filter.drop_cnt=0;
+BOUND(filter.maxdrop, 0, 60);
+BOUND(filter.hdop, 0, 50);
+BOUND(filter.vdop, 0, 50);
+BOUND(filter.angle, 0, 45);
/* Get Units. Default is UNITS_KM. */
{
#ifndef _CONFIG_GCONF_H
#define _CONFIG_GCONF_H
+#include <gconf/gconf-client.h>
+#include "filter.h"
+
GConfClient *gconf_client;
void config_init(void);
gboolean config_save_repo(void);
gboolean config_load_repo(void);
gboolean config_save_home(void);
-gboolean config_save_filter(void);
gboolean config_save(void);
void config_update_proxy(void);
+gboolean config_save_filter(GpsTrackFilter *f);
+
#endif
#include "bt.h"
#include "ui-common.h"
#include "settings.h"
-
+#include "filter.h"
#include "hildon-wrappers.h"
GtkWidget *dialog;
gtk_table_attach(GTK_TABLE(table), chk_gps_filter = gtk_check_button_new_with_label(_("Enable track filter")),
0, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4);
-gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chk_gps_filter), _gps_filter);
+gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chk_gps_filter), filter.enabled);
gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Horizontal DOP limit")), 0, 1, 1, 2, GTK_FILL, 0, 2, 4);
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
gtk_table_attach(GTK_TABLE(table), num_maxdrop = gtk_hscale_new_with_range(0, 60, 1), 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, 0, 2, 4);
-gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chk_gps_filter), _gps_filter);
-gtk_range_set_value(GTK_RANGE(num_hdop), _filter_hdop);
-gtk_range_set_value(GTK_RANGE(num_vdop), _filter_vdop);
-gtk_range_set_value(GTK_RANGE(num_angle), _filter_angle);
-gtk_range_set_value(GTK_RANGE(num_osm_dist), _filter_osm);
-gtk_range_set_value(GTK_RANGE(num_maxdrop), _filter_maxdrop);
+gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chk_gps_filter), filter.enabled);
+gtk_range_set_value(GTK_RANGE(num_hdop), filter.hdop);
+gtk_range_set_value(GTK_RANGE(num_vdop), filter.vdop);
+gtk_range_set_value(GTK_RANGE(num_angle), filter.angle);
+gtk_range_set_value(GTK_RANGE(num_osm_dist), filter.osm);
+gtk_range_set_value(GTK_RANGE(num_maxdrop), filter.maxdrop);
gtk_window_set_default_size(GTK_WINDOW(dialog), 500, 300);
gtk_widget_show_all(dialog);
if (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
- _filter_angle = gtk_range_get_value(GTK_RANGE(num_angle));
- _filter_hdop = gtk_range_get_value(GTK_RANGE(num_hdop));
- _filter_vdop = gtk_range_get_value(GTK_RANGE(num_vdop));
- _filter_osm = gtk_range_get_value(GTK_RANGE(num_osm_dist));
- _filter_maxdrop = gtk_range_get_value(GTK_RANGE(num_maxdrop));
- _gps_filter = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(chk_gps_filter));
-
- config_save_filter();
+ filter.angle=gtk_range_get_value(GTK_RANGE(num_angle));
+ filter.hdop=gtk_range_get_value(GTK_RANGE(num_hdop));
+ filter.vdop=gtk_range_get_value(GTK_RANGE(num_vdop));
+ filter.osm=gtk_range_get_value(GTK_RANGE(num_osm_dist));
+ filter.maxdrop=gtk_range_get_value(GTK_RANGE(num_maxdrop));
+ filter.enabled=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(chk_gps_filter));
+
+ config_save_filter(&filter);
}
gtk_widget_destroy(dialog);
--- /dev/null
+#include "config.h"
+
+#include <glib.h>
+#include <glib/gstdio.h>
+
+#include "gps.h"
+#include "osm.h"
+#include "filter.h"
+
+/**
+ * Check track filter against GPS values
+ * return TRUE if point is ok, FALSE if it should be skipped
+ */
+gboolean
+filter_check(GpsTrackFilter *f, GpsData *gps, osm_location *location)
+{
+if (f->enabled==FALSE)
+ return TRUE;
+
+if (f->drop_cnt>f->maxdrop) {
+ f->drop_cnt=0;
+ return TRUE;
+}
+
+if ((gps->hdop<f->hdop || f->hdop==0.0) && (gps->vdop<f->vdop || f->vdop==0.0)) {
+ f->drop_cnt=0;
+ return TRUE;
+}
+
+if (fabs(gps->heading-gps->lheading)>f->angle || f->angle==0.0 ) {
+ f->drop_cnt=0;
+ return TRUE;
+}
+
+if (!location->street) {
+ f->drop_cnt=0;
+ return TRUE;
+}
+
+if (location->street && location->street->dist>f->osm) {
+ f->drop_cnt=0;
+ return TRUE;
+}
+
+f->drop_cnt++;
+#if 0
+g_printf("*** Filtering by: [%s %s %s %s] A: %f (%d)\n",
+ gps->hdop>f->hdop ? "HDOP" : "-",
+ gps->vdop>f->vdop ? "VDOP" : "-",
+ (fabs(gps->heading-gps->lheading)<f->angle) ? "Angle" : "-",
+ (location->street && (location->street->dist>f->osm)) ? "OSM" : "-",
+ fabs(gps->heading-gps->lheading), f->drop_cnt);
+#endif
+return FALSE;
+}
+
--- /dev/null
+#include "config.h"
+#include <glib.h>
+
+#ifndef _FILTER_H
+#define _FILTER_H
+
+#include "gpsdata.h"
+#include "osm.h"
+
+typedef struct _gps_track_filter GpsTrackFilter;
+struct _gps_track_filter {
+ gboolean enabled;
+ gdouble hdop;
+ gdouble vdop;
+ gdouble angle;
+ gdouble osm;
+ gdouble min_speed;
+ guint maxdrop;
+ guint drop_cnt;
+};
+
+GpsTrackFilter filter;
+
+gboolean filter_check(GpsTrackFilter *f, GpsData *gps, osm_location *location);
+
+#endif
#include "gtkgps.h"
#include "gtkcompass.h"
-#define GPS_FILTER_MAX_SKIP (10)
-static gint 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) && (track_drop_cnt<_filter_maxdrop)) {
- gps_integerize_data(&_gps, &_pos);
- 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 {
- track_drop_cnt++;
- g_printf("*** Filtering by: [%s %s %s %s] A: %f (%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" : "-",
- fabs(_gps.heading-_gps.lheading), track_drop_cnt);
- }
- map_refresh_mark();
- } else {
- track_drop_cnt=0;
- gps_integerize_data(&_gps, &_pos);
- track_add(_pos.time, newly_fixed);
- _gps.lheading=_gps.heading;
- map_refresh_mark();
- }
+ 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;
+ map_refresh_mark();
}
}
guint32 id;
node_type_t type;
gchar *name;
- gint lat;
- gint lon;
+ gint32 lat;
+ gint32 lon;
gdouble dist;
guint32 isin_p;
guint32 isin_c;
struct _osm_way_node {
guint32 id;
guint32 flags;
- gint lat;
- gint lon;
+ gint32 lat;
+ gint32 lon;
};
/* Way */
osm_place *secondary;
gboolean changed;
gboolean valid;
- gint lat;
- gint lon;
+ gint32 lat;
+ gint32 lon;
gfloat heading;
gfloat speed;
gint nfcnt;
gboolean _enable_gps;
gboolean _gps_info;
-struct _track_filter {
- gboolean enabled;
- gdouble hdop;
- gdouble vdop;
- gdouble angle;
- gdouble osm;
- gdouble maxdrop;
-};
-
-gboolean _gps_filter;
-gdouble _filter_hdop;
-gdouble _filter_vdop;
-gdouble _filter_angle;
-gdouble _filter_osm;
-gdouble _filter_maxdrop;
-
gint _show_tracks;
gboolean _show_scale;
gboolean _show_velvec;
#include <glib.h>
#include <sqlite3.h>
+#include "filter.h"
#define TRACK_SQL_SELECT_TRACKS "select id,name,slat,slon,elat,elon,len,sdate,edate from tracks order by sdate"
#define TRACK_SQL_INSERT_TRACK "insert into tracks (id,name,sloc,sdate) values (?,?,?,?);