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
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 + 0 },
49 VikLayerParamData bfilter_simplify_params_defaults[] = {
53 VikDataSourceInterface vik_datasource_bfilter_simplify_interface = {
54 N_("Simplify All Tracks"),
55 N_("Simplified Tracks"),
56 VIK_DATASOURCE_SHELL_CMD,
57 VIK_DATASOURCE_CREATENEWLAYER,
58 VIK_DATASOURCE_INPUTTYPE_TRWLAYER,
59 FALSE, /* keep dialog open after success */
61 (VikDataSourceGetCmdStringFunc) datasource_bfilter_simplify_get_cmd_string,
64 bfilter_simplify_params,
65 sizeof(bfilter_simplify_params)/sizeof(bfilter_simplify_params[0]),
66 bfilter_simplify_params_defaults,
72 static void datasource_bfilter_simplify_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename )
74 *input_file_type = NULL;
75 *cmd = g_strdup_printf ( "gpsbabel -i gpx -f %s -x simplify,count=%d -o gpx -F -", input_filename, paramdatas[0].u );
78 /************************************ Duplicate Location ***********************************/
80 static void datasource_bfilter_dup_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename );
82 /* TODO: shell_escape stuff */
83 /* TODO: name is useless for filters */
86 VikDataSourceInterface vik_datasource_bfilter_dup_interface = {
87 N_("Remove Duplicate Waypoints"),
88 N_("Remove Duplicate Waypoints"),
89 VIK_DATASOURCE_SHELL_CMD,
90 VIK_DATASOURCE_CREATENEWLAYER,
91 VIK_DATASOURCE_INPUTTYPE_TRWLAYER,
92 FALSE, /* keep dialog open after success */
94 (VikDataSourceGetCmdStringFunc) datasource_bfilter_dup_get_cmd_string,
97 NULL, 0, NULL, NULL, 0
101 static void datasource_bfilter_dup_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename )
103 *input_file_type = NULL;
104 *cmd = g_strdup_printf ( "gpsbabel -i gpx -f %s -x duplicate,location -o gpx -F -", input_filename );
108 /************************************ Polygon ***********************************/
110 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 );
112 /* TODO: shell_escape stuff */
113 /* TODO: name is useless for filters */
116 VikDataSourceInterface vik_datasource_bfilter_polygon_interface = {
117 N_("Waypoints Inside This"),
118 N_("Polygonized Layer"),
119 VIK_DATASOURCE_SHELL_CMD,
120 VIK_DATASOURCE_CREATENEWLAYER,
121 VIK_DATASOURCE_INPUTTYPE_TRWLAYER_TRACK,
122 FALSE, /* keep dialog open after success */
124 (VikDataSourceGetCmdStringFunc) datasource_bfilter_polygon_get_cmd_string,
135 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 )
137 *input_file_type = NULL;
138 *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 );
141 /************************************ Exclude Polygon ***********************************/
143 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 );
145 /* TODO: shell_escape stuff */
146 /* TODO: name is useless for filters */
149 VikDataSourceInterface vik_datasource_bfilter_exclude_polygon_interface = {
150 N_("Waypoints Outside This"),
151 N_("Polygonzied Layer"),
152 VIK_DATASOURCE_SHELL_CMD,
153 VIK_DATASOURCE_CREATENEWLAYER,
154 VIK_DATASOURCE_INPUTTYPE_TRWLAYER_TRACK,
155 FALSE, /* keep dialog open after success */
157 (VikDataSourceGetCmdStringFunc) datasource_bfilter_exclude_polygon_get_cmd_string,
168 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 )
170 *input_file_type = NULL;
171 *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 );