]> git.street.me.uk Git - andy/viking.git/blob - src/datasource_bfilter.c
Add GPS Layer tooltip to say the protocol (aka device manufacturer) type.
[andy/viking.git] / src / datasource_bfilter.c
1 /*
2  * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
3  *
4  * Copyright (C) 2003-2007, Evan Battaglia <gtoevan@gmx.net>
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24 #include <string.h>
25 #include <glib/gi18n.h>
26
27 #include "viking.h"
28 #include "babel.h"
29 #include "gpx.h"
30 #include "acquire.h"
31
32
33 /************************************ Simplify ***********************************/
34
35 static void datasource_bfilter_simplify_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename );
36
37 /* TODO: shell_escape stuff */
38 /* TODO: name is useless for filters */
39
40 /* spin button scales */
41 VikLayerParamScale simplify_params_scales[] = {
42   {1, 10000, 10, 0},
43 };
44
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 },
47 };
48
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__
53   { .i = 100 },
54 #else
55   { 100 },
56 #endif
57 };
58
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,
65   TRUE,
66   FALSE, /* keep dialog open after success */
67   NULL, NULL, NULL,
68   (VikDataSourceGetCmdStringFunc)       datasource_bfilter_simplify_get_cmd_string,
69   NULL, NULL, NULL,
70   (VikDataSourceOffFunc) NULL,
71
72   bfilter_simplify_params,
73   sizeof(bfilter_simplify_params)/sizeof(bfilter_simplify_params[0]),
74   bfilter_simplify_params_defaults,
75   NULL,
76   0
77 };
78
79
80 static void datasource_bfilter_simplify_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename )
81 {
82   *input_file_type = NULL;
83   *cmd = g_strdup_printf ( "gpsbabel -i gpx -f %s -x simplify,count=%d -o gpx -F -", input_filename, paramdatas[0].u );
84 }
85
86 /************************************ Duplicate Location ***********************************/
87
88 static void datasource_bfilter_dup_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename );
89
90 /* TODO: shell_escape stuff */
91 /* TODO: name is useless for filters */
92
93
94 VikDataSourceInterface vik_datasource_bfilter_dup_interface = {
95   N_("Remove Duplicate Waypoints"),
96   N_("Remove Duplicate Waypoints"),
97   VIK_DATASOURCE_SHELL_CMD,
98   VIK_DATASOURCE_CREATENEWLAYER,
99   VIK_DATASOURCE_INPUTTYPE_TRWLAYER,
100   TRUE,
101   FALSE, /* keep dialog open after success */
102   NULL, NULL, NULL,
103   (VikDataSourceGetCmdStringFunc)       datasource_bfilter_dup_get_cmd_string,
104   NULL, NULL, NULL,
105   (VikDataSourceOffFunc) NULL,
106
107   NULL, 0, NULL, NULL, 0
108 };
109
110
111 static void datasource_bfilter_dup_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename )
112 {
113   *input_file_type = NULL;
114   *cmd = g_strdup_printf ( "gpsbabel -i gpx -f %s -x duplicate,location -o gpx -F -", input_filename );
115 }
116
117
118 /************************************ Polygon ***********************************/
119
120 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 );
121
122 /* TODO: shell_escape stuff */
123 /* TODO: name is useless for filters */
124
125
126 VikDataSourceInterface vik_datasource_bfilter_polygon_interface = {
127   N_("Waypoints Inside This"),
128   N_("Polygonized Layer"),
129   VIK_DATASOURCE_SHELL_CMD,
130   VIK_DATASOURCE_CREATENEWLAYER,
131   VIK_DATASOURCE_INPUTTYPE_TRWLAYER_TRACK,
132   TRUE,
133   FALSE, /* keep dialog open after success */
134   NULL, NULL, NULL,
135   (VikDataSourceGetCmdStringFunc)       datasource_bfilter_polygon_get_cmd_string,
136   NULL, NULL, NULL,
137   (VikDataSourceOffFunc) NULL,
138
139   NULL,
140   0,
141   NULL,
142   NULL,
143   0
144 };
145
146
147 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 )
148 {
149   *input_file_type = NULL;
150   *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 );
151 }
152
153 /************************************ Exclude Polygon ***********************************/
154
155 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 );
156
157 /* TODO: shell_escape stuff */
158 /* TODO: name is useless for filters */
159
160
161 VikDataSourceInterface vik_datasource_bfilter_exclude_polygon_interface = {
162   N_("Waypoints Outside This"),
163   N_("Polygonzied Layer"),
164   VIK_DATASOURCE_SHELL_CMD,
165   VIK_DATASOURCE_CREATENEWLAYER,
166   VIK_DATASOURCE_INPUTTYPE_TRWLAYER_TRACK,
167   TRUE,
168   FALSE, /* keep dialog open after success */
169   NULL, NULL, NULL,
170   (VikDataSourceGetCmdStringFunc)       datasource_bfilter_exclude_polygon_get_cmd_string,
171   NULL, NULL, NULL,
172   (VikDataSourceOffFunc) NULL,
173
174   NULL,
175   0,
176   NULL,
177   NULL,
178   0
179 };
180
181
182 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 )
183 {
184   *input_file_type = NULL;
185   *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 );
186 }
187