]>
Commit | Line | Data |
---|---|---|
40a8d1c2 EB |
1 | /* |
2 | * viking -- GPS Data and Topo Analyzer, Explorer, and Manager | |
3 | * | |
a482007a | 4 | * Copyright (C) 2003-2007, Evan Battaglia <gtoevan@gmx.net> |
40a8d1c2 EB |
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 | */ | |
4c77d5e0 | 21 | #ifdef HAVE_CONFIG_H |
40a8d1c2 | 22 | #include "config.h" |
4c77d5e0 | 23 | #endif |
40a8d1c2 | 24 | #include <string.h> |
4c77d5e0 | 25 | #include <glib/gi18n.h> |
40a8d1c2 EB |
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[] = { | |
e6994d8d | 46 | { "numberofpoints", VIK_LAYER_PARAM_UINT, VIK_LAYER_GROUP_NONE, N_("Max number of points:"), VIK_LAYER_WIDGET_SPINBUTTON, simplify_params_scales, NULL, NULL }, |
40a8d1c2 EB |
47 | }; |
48 | ||
49 | VikLayerParamData bfilter_simplify_params_defaults[] = { | |
0f89a3a3 RN |
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 | |
40a8d1c2 | 55 | { 100 }, |
0f89a3a3 | 56 | #endif |
40a8d1c2 EB |
57 | }; |
58 | ||
59 | VikDataSourceInterface vik_datasource_bfilter_simplify_interface = { | |
7306a492 | 60 | N_("Simplify All Tracks..."), |
4c77d5e0 | 61 | N_("Simplified Tracks"), |
40a8d1c2 EB |
62 | VIK_DATASOURCE_CREATENEWLAYER, |
63 | VIK_DATASOURCE_INPUTTYPE_TRWLAYER, | |
d2525524 | 64 | TRUE, |
40a8d1c2 | 65 | FALSE, /* keep dialog open after success */ |
b2aa700f | 66 | TRUE, |
40a8d1c2 EB |
67 | NULL, NULL, NULL, |
68 | (VikDataSourceGetCmdStringFunc) datasource_bfilter_simplify_get_cmd_string, | |
eb3f9398 | 69 | (VikDataSourceProcessFunc) a_babel_convert_from_shellcommand, |
40a8d1c2 | 70 | NULL, NULL, NULL, |
2b756ea0 | 71 | (VikDataSourceOffFunc) NULL, |
40a8d1c2 EB |
72 | |
73 | bfilter_simplify_params, | |
74 | sizeof(bfilter_simplify_params)/sizeof(bfilter_simplify_params[0]), | |
75 | bfilter_simplify_params_defaults, | |
76 | NULL, | |
77 | 0 | |
78 | }; | |
79 | ||
80 | ||
81 | static void datasource_bfilter_simplify_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename ) | |
82 | { | |
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 ); | |
85 | } | |
86 | ||
87 | /************************************ Duplicate Location ***********************************/ | |
88 | ||
89 | static void datasource_bfilter_dup_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename ); | |
90 | ||
91 | /* TODO: shell_escape stuff */ | |
92 | /* TODO: name is useless for filters */ | |
93 | ||
94 | ||
95 | VikDataSourceInterface vik_datasource_bfilter_dup_interface = { | |
4c77d5e0 GB |
96 | N_("Remove Duplicate Waypoints"), |
97 | N_("Remove Duplicate Waypoints"), | |
40a8d1c2 EB |
98 | VIK_DATASOURCE_CREATENEWLAYER, |
99 | VIK_DATASOURCE_INPUTTYPE_TRWLAYER, | |
d2525524 | 100 | TRUE, |
40a8d1c2 | 101 | FALSE, /* keep dialog open after success */ |
b2aa700f | 102 | TRUE, |
40a8d1c2 EB |
103 | NULL, NULL, NULL, |
104 | (VikDataSourceGetCmdStringFunc) datasource_bfilter_dup_get_cmd_string, | |
eb3f9398 | 105 | (VikDataSourceProcessFunc) a_babel_convert_from_shellcommand, |
40a8d1c2 | 106 | NULL, NULL, NULL, |
2b756ea0 | 107 | (VikDataSourceOffFunc) NULL, |
40a8d1c2 EB |
108 | |
109 | NULL, 0, NULL, NULL, 0 | |
110 | }; | |
111 | ||
112 | ||
113 | static void datasource_bfilter_dup_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename ) | |
114 | { | |
115 | *input_file_type = NULL; | |
7de42638 | 116 | *cmd = g_strdup_printf ( "gpsbabel -i gpx -f %s -x duplicate,location -o gpx -F -", input_filename ); |
40a8d1c2 EB |
117 | } |
118 | ||
119 | ||
120 | /************************************ Polygon ***********************************/ | |
121 | ||
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 ); | |
123 | ||
124 | /* TODO: shell_escape stuff */ | |
125 | /* TODO: name is useless for filters */ | |
126 | ||
127 | ||
128 | VikDataSourceInterface vik_datasource_bfilter_polygon_interface = { | |
4c77d5e0 | 129 | N_("Waypoints Inside This"), |
8a7788c9 | 130 | N_("Polygonized Layer"), |
40a8d1c2 EB |
131 | VIK_DATASOURCE_CREATENEWLAYER, |
132 | VIK_DATASOURCE_INPUTTYPE_TRWLAYER_TRACK, | |
d2525524 | 133 | TRUE, |
40a8d1c2 | 134 | FALSE, /* keep dialog open after success */ |
b2aa700f | 135 | TRUE, |
40a8d1c2 EB |
136 | NULL, NULL, NULL, |
137 | (VikDataSourceGetCmdStringFunc) datasource_bfilter_polygon_get_cmd_string, | |
eb3f9398 | 138 | (VikDataSourceProcessFunc) a_babel_convert_from_shellcommand, |
40a8d1c2 | 139 | NULL, NULL, NULL, |
2b756ea0 | 140 | (VikDataSourceOffFunc) NULL, |
40a8d1c2 EB |
141 | |
142 | NULL, | |
143 | 0, | |
144 | NULL, | |
145 | NULL, | |
146 | 0 | |
147 | }; | |
148 | ||
149 | ||
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 ) | |
151 | { | |
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 ); | |
154 | } | |
155 | ||
156 | /************************************ Exclude Polygon ***********************************/ | |
157 | ||
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 ); | |
159 | ||
160 | /* TODO: shell_escape stuff */ | |
161 | /* TODO: name is useless for filters */ | |
162 | ||
163 | ||
164 | VikDataSourceInterface vik_datasource_bfilter_exclude_polygon_interface = { | |
4c77d5e0 GB |
165 | N_("Waypoints Outside This"), |
166 | N_("Polygonzied Layer"), | |
40a8d1c2 EB |
167 | VIK_DATASOURCE_CREATENEWLAYER, |
168 | VIK_DATASOURCE_INPUTTYPE_TRWLAYER_TRACK, | |
d2525524 | 169 | TRUE, |
40a8d1c2 | 170 | FALSE, /* keep dialog open after success */ |
b2aa700f | 171 | TRUE, |
40a8d1c2 EB |
172 | NULL, NULL, NULL, |
173 | (VikDataSourceGetCmdStringFunc) datasource_bfilter_exclude_polygon_get_cmd_string, | |
eb3f9398 | 174 | (VikDataSourceProcessFunc) a_babel_convert_from_shellcommand, |
40a8d1c2 | 175 | NULL, NULL, NULL, |
2b756ea0 | 176 | (VikDataSourceOffFunc) NULL, |
40a8d1c2 EB |
177 | |
178 | NULL, | |
179 | 0, | |
180 | NULL, | |
181 | NULL, | |
182 | 0 | |
183 | }; | |
184 | ||
185 | ||
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 ) | |
187 | { | |
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 ); | |
190 | } | |
191 |