2 * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
4 * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 /************************************ Simplify ***********************************/
32 static void datasource_bfilter_simplify_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename );
34 /* TODO: shell_escape stuff */
35 /* TODO: name is useless for filters */
37 /* spin button scales */
38 VikLayerParamScale simplify_params_scales[] = {
42 VikLayerParam bfilter_simplify_params[] = {
43 { "numberofpoints", VIK_LAYER_PARAM_UINT, VIK_LAYER_GROUP_NONE, "Max number of points:", VIK_LAYER_WIDGET_SPINBUTTON, simplify_params_scales + 0 },
46 VikLayerParamData bfilter_simplify_params_defaults[] = {
50 VikDataSourceInterface vik_datasource_bfilter_simplify_interface = {
51 "Simplify All Tracks",
53 VIK_DATASOURCE_SHELL_CMD,
54 VIK_DATASOURCE_CREATENEWLAYER,
55 VIK_DATASOURCE_INPUTTYPE_TRWLAYER,
56 FALSE, /* keep dialog open after success */
58 (VikDataSourceGetCmdStringFunc) datasource_bfilter_simplify_get_cmd_string,
61 bfilter_simplify_params,
62 sizeof(bfilter_simplify_params)/sizeof(bfilter_simplify_params[0]),
63 bfilter_simplify_params_defaults,
69 static void datasource_bfilter_simplify_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename )
71 *input_file_type = NULL;
72 *cmd = g_strdup_printf ( "gpsbabel -i gpx -f %s -x simplify,count=%d -o gpx -F -", input_filename, paramdatas[0].u );
75 /************************************ Duplicate Location ***********************************/
77 static void datasource_bfilter_dup_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename );
79 /* TODO: shell_escape stuff */
80 /* TODO: name is useless for filters */
83 VikDataSourceInterface vik_datasource_bfilter_dup_interface = {
84 "Remove Duplicate Waypoints",
85 "Remove Duplicate Waypoints",
86 VIK_DATASOURCE_SHELL_CMD,
87 VIK_DATASOURCE_CREATENEWLAYER,
88 VIK_DATASOURCE_INPUTTYPE_TRWLAYER,
89 FALSE, /* keep dialog open after success */
91 (VikDataSourceGetCmdStringFunc) datasource_bfilter_dup_get_cmd_string,
94 NULL, 0, NULL, NULL, 0
98 static void datasource_bfilter_dup_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename )
100 *input_file_type = NULL;
101 *cmd = g_strdup_printf ( "gpsbabel -i gpx -f %s -x dup,loc -o gpx -F -", input_filename );
105 /************************************ Polygon ***********************************/
107 static void datasource_bfilter_polygon_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename, const gchar *input_track_filename );
109 /* TODO: shell_escape stuff */
110 /* TODO: name is useless for filters */
113 VikDataSourceInterface vik_datasource_bfilter_polygon_interface = {
114 "Waypoints Inside This",
116 VIK_DATASOURCE_SHELL_CMD,
117 VIK_DATASOURCE_CREATENEWLAYER,
118 VIK_DATASOURCE_INPUTTYPE_TRWLAYER_TRACK,
119 FALSE, /* keep dialog open after success */
121 (VikDataSourceGetCmdStringFunc) datasource_bfilter_polygon_get_cmd_string,
132 static void datasource_bfilter_polygon_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename, const gchar *input_track_filename )
134 *input_file_type = NULL;
135 *cmd = g_strdup_printf ( "gpsbabel -i gpx -f %s -o arc -F - | gpsbabel -i gpx -f %s -x polygon,file=- -o gpx -F -", input_track_filename, input_filename );
138 /************************************ Exclude Polygon ***********************************/
140 static void datasource_bfilter_exclude_polygon_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename, const gchar *input_track_filename );
142 /* TODO: shell_escape stuff */
143 /* TODO: name is useless for filters */
146 VikDataSourceInterface vik_datasource_bfilter_exclude_polygon_interface = {
147 "Waypoints Outside This",
149 VIK_DATASOURCE_SHELL_CMD,
150 VIK_DATASOURCE_CREATENEWLAYER,
151 VIK_DATASOURCE_INPUTTYPE_TRWLAYER_TRACK,
152 FALSE, /* keep dialog open after success */
154 (VikDataSourceGetCmdStringFunc) datasource_bfilter_exclude_polygon_get_cmd_string,
165 static void datasource_bfilter_exclude_polygon_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename, const gchar *input_track_filename )
167 *input_file_type = NULL;
168 *cmd = g_strdup_printf ( "gpsbabel -i gpx -f %s -o arc -F - | gpsbabel -i gpx -f %s -x polygon,exclude,file=- -o gpx -F -", input_track_filename, input_filename );