2 * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
4 * Copyright (C) 2003-2007, 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
25 #include <glib/gi18n.h>
33 /************************************ Simplify ***********************************/
35 static void datasource_bfilter_simplify_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename );
37 /* TODO: shell_escape stuff */
38 /* TODO: name is useless for filters */
40 /* spin button scales */
41 VikLayerParamScale simplify_params_scales[] = {
45 VikLayerParam bfilter_simplify_params[] = {
46 { "numberofpoints", VIK_LAYER_PARAM_UINT, VIK_LAYER_GROUP_NONE, N_("Max number of points:"), VIK_LAYER_WIDGET_SPINBUTTON, simplify_params_scales, NULL },
49 VikLayerParamData bfilter_simplify_params_defaults[] = {
50 /* Annoyingly 'C' cannot initialize unions properly */
51 /* It's dependent on the standard used or the compiler support... */
52 #if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L || __GNUC__
59 VikDataSourceInterface vik_datasource_bfilter_simplify_interface = {
60 N_("Simplify All Tracks..."),
61 N_("Simplified Tracks"),
62 VIK_DATASOURCE_SHELL_CMD,
63 VIK_DATASOURCE_CREATENEWLAYER,
64 VIK_DATASOURCE_INPUTTYPE_TRWLAYER,
66 FALSE, /* keep dialog open after success */
68 (VikDataSourceGetCmdStringFunc) datasource_bfilter_simplify_get_cmd_string,
69 (VikDataSourceProcessFunc) NULL,
71 (VikDataSourceOffFunc) NULL,
73 bfilter_simplify_params,
74 sizeof(bfilter_simplify_params)/sizeof(bfilter_simplify_params[0]),
75 bfilter_simplify_params_defaults,
81 static void datasource_bfilter_simplify_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename )
83 *input_file_type = NULL;
84 *cmd = g_strdup_printf ( "gpsbabel -i gpx -f %s -x simplify,count=%d -o gpx -F -", input_filename, paramdatas[0].u );
87 /************************************ Duplicate Location ***********************************/
89 static void datasource_bfilter_dup_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename );
91 /* TODO: shell_escape stuff */
92 /* TODO: name is useless for filters */
95 VikDataSourceInterface vik_datasource_bfilter_dup_interface = {
96 N_("Remove Duplicate Waypoints"),
97 N_("Remove Duplicate Waypoints"),
98 VIK_DATASOURCE_SHELL_CMD,
99 VIK_DATASOURCE_CREATENEWLAYER,
100 VIK_DATASOURCE_INPUTTYPE_TRWLAYER,
102 FALSE, /* keep dialog open after success */
104 (VikDataSourceGetCmdStringFunc) datasource_bfilter_dup_get_cmd_string,
105 (VikDataSourceProcessFunc) NULL,
107 (VikDataSourceOffFunc) NULL,
109 NULL, 0, NULL, NULL, 0
113 static void datasource_bfilter_dup_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename )
115 *input_file_type = NULL;
116 *cmd = g_strdup_printf ( "gpsbabel -i gpx -f %s -x duplicate,location -o gpx -F -", input_filename );
120 /************************************ Polygon ***********************************/
122 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 );
124 /* TODO: shell_escape stuff */
125 /* TODO: name is useless for filters */
128 VikDataSourceInterface vik_datasource_bfilter_polygon_interface = {
129 N_("Waypoints Inside This"),
130 N_("Polygonized Layer"),
131 VIK_DATASOURCE_SHELL_CMD,
132 VIK_DATASOURCE_CREATENEWLAYER,
133 VIK_DATASOURCE_INPUTTYPE_TRWLAYER_TRACK,
135 FALSE, /* keep dialog open after success */
137 (VikDataSourceGetCmdStringFunc) datasource_bfilter_polygon_get_cmd_string,
138 (VikDataSourceProcessFunc) NULL,
140 (VikDataSourceOffFunc) NULL,
150 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 )
152 *input_file_type = NULL;
153 *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 );
156 /************************************ Exclude Polygon ***********************************/
158 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 );
160 /* TODO: shell_escape stuff */
161 /* TODO: name is useless for filters */
164 VikDataSourceInterface vik_datasource_bfilter_exclude_polygon_interface = {
165 N_("Waypoints Outside This"),
166 N_("Polygonzied Layer"),
167 VIK_DATASOURCE_SHELL_CMD,
168 VIK_DATASOURCE_CREATENEWLAYER,
169 VIK_DATASOURCE_INPUTTYPE_TRWLAYER_TRACK,
171 FALSE, /* keep dialog open after success */
173 (VikDataSourceGetCmdStringFunc) datasource_bfilter_exclude_polygon_get_cmd_string,
174 (VikDataSourceProcessFunc) NULL,
176 (VikDataSourceOffFunc) NULL,
186 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 )
188 *input_file_type = NULL;
189 *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 );