Browse Source

Add the minimum_points option to trackfilter for OSM users.

tags/gpsbabel_1_5_4
Robert Lipe 2 years ago
parent
commit
9cdbfc777e
2 changed files with 32 additions and 2 deletions
  1. 24
    2
      trackfilter.cc
  2. 8
    0
      xmldoc/filters/options/track-minimum_points.xml

+ 24
- 2
trackfilter.cc View File

@@ -52,6 +52,7 @@
#define TRACKFILTER_SEGMENT_OPTION "segment"
#define TRACKFILTER_FAKETIME_OPTION "faketime"
#define TRACKFILTER_DISCARD_OPTION "discard"
#define TRACKFILTER_MINPOINTS_OPTION "minimum_points"

#undef TRACKF_DBG

@@ -72,6 +73,7 @@ static char* opt_trk2seg = NULL;
static char* opt_segment = NULL;
static char* opt_faketime = NULL;
static char* opt_discard = NULL;
static char* opt_minpoints = NULL;

static
arglist_t trackfilter_args[] = {
@@ -156,6 +158,11 @@ arglist_t trackfilter_args[] = {
"Discard track points without timestamps during merge",
NULL, ARGTYPE_BOOL, ARG_NOMINMAX
},
{
TRACKFILTER_MINPOINTS_OPTION, &opt_minpoints,
"Discard tracks with fewer than these points",
NULL, ARGTYPE_INT, "0"
},
ARG_TERMINATOR
};

@@ -311,7 +318,7 @@ trackfilter_fill_track_list_cb(const route_head* track) /* callback for track_d
Waypoint* wpt, *prev;
queue* elem, *tmp;

if (track->rte_waypt_ct == 0) {
if (track->rte_waypt_ct == 0 ) {
track_del_head((route_head*)track);
return;
}
@@ -364,6 +371,16 @@ trackfilter_fill_track_list_cb(const route_head* track) /* callback for track_d
track_ct++;
}

static void
trackfilter_minpoint_list_cb(const route_head* track)
{
int minimum_points = atoi(opt_minpoints);
if (track->rte_waypt_ct < minimum_points ) {
track_del_head((route_head*)track);
return;
}
}

/*******************************************************************************
* track title producers
*******************************************************************************/
@@ -458,7 +475,7 @@ trackfilter_pack(void)
prev = track_list[j];
if (prev.last_time >= track_list[i].first_time) {
fatal(MYNAME "-pack: Tracks overlap in time! %s >= %s at %d\n",
qPrintable(prev.last_time.toString()),
qPrintable(prev.last_time.toString()),
qPrintable(track_list[i].first_time.toString()), i);
}
}
@@ -1375,6 +1392,11 @@ trackfilter_process(void)

trackfilter_split();
}

// Performed last as previous options may have created "small" tracks.
if ((opt_minpoints != NULL) && atoi(opt_minpoints) > 0) {
track_disp_all(trackfilter_minpoint_list_cb, NULL, NULL);
}
}

/******************************************************************************************/

+ 8
- 0
xmldoc/filters/options/track-minimum_points.xml View File

@@ -0,0 +1,8 @@
<para>
Eliminates any remaining tracks with fewer than this number of trackpoints.
</para>
<para>
This step is performed last by this filter and is used to clean up earlier
simplifications that may have left tracks with so few points as to be
useless, such as a track taken while stationary but with GPS wander.
</para>

Loading…
Cancel
Save