]> err.no Git - mapper/blob - src/filter.c
More map widget integration changes
[mapper] / src / filter.c
1 #include "config.h"
2
3 #include <glib.h>
4 #include <glib/gstdio.h>
5
6 #include "gps.h"
7 #include "osm.h"
8 #include "filter.h"
9
10 /** 
11  * Check track filter against GPS values
12  * return TRUE if point is ok, FALSE if it should be skipped
13  */
14 gboolean 
15 filter_check(GpsTrackFilter *f, GpsData *gps, osm_location *location)
16 {
17 if (f->enabled==FALSE)
18         return TRUE;
19
20 if (f->drop_cnt>f->maxdrop) {
21         f->drop_cnt=0;
22         return TRUE;
23 }
24
25 if ((gps->hdop<f->hdop || f->hdop==0.0) && (gps->vdop<f->vdop || f->vdop==0.0)) {
26         f->drop_cnt=0;
27         return TRUE;
28 }
29
30 if (fabs(gps->heading-gps->lheading)>f->angle || f->angle==0.0 ) {
31         f->drop_cnt=0;
32         return TRUE;
33 }
34
35 if (!location->street) {
36         f->drop_cnt=0;
37         return TRUE;
38 }
39
40 if (location->street && location->street->dist>f->osm) {
41         f->drop_cnt=0;
42         return TRUE;
43 }
44
45 f->drop_cnt++;
46 #if 0
47 g_printf("*** Filtering by: [%s %s %s %s] A: %f (%d)\n", 
48         gps->hdop>f->hdop ? "HDOP" : "-", 
49         gps->vdop>f->vdop ? "VDOP" : "-", 
50         (fabs(gps->heading-gps->lheading)<f->angle) ? "Angle" : "-",
51         (location->street && (location->street->dist>f->osm)) ? "OSM" : "-", 
52         fabs(gps->heading-gps->lheading), f->drop_cnt);
53 #endif
54 return FALSE;
55 }
56