]> git.street.me.uk Git - andy/viking.git/blame - src/datasource_bfilter.c
[DOC] Fix Gnome's menu entry category for viking
[andy/viking.git] / src / datasource_bfilter.c
CommitLineData
40a8d1c2
EB
1/*
2 * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
3 *
4 * Copyright (C) 2003-2005, 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 */
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
35static 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 */
41VikLayerParamScale simplify_params_scales[] = {
42 {1, 10000, 10, 0},
43};
44
45VikLayerParam bfilter_simplify_params[] = {
4c77d5e0 46 { "numberofpoints", VIK_LAYER_PARAM_UINT, VIK_LAYER_GROUP_NONE, N_("Max number of points:"), VIK_LAYER_WIDGET_SPINBUTTON, simplify_params_scales + 0 },
40a8d1c2
EB
47};
48
49VikLayerParamData bfilter_simplify_params_defaults[] = {
50 { 100 },
51};
52
53VikDataSourceInterface vik_datasource_bfilter_simplify_interface = {
4c77d5e0
GB
54 N_("Simplify All Tracks"),
55 N_("Simplified Tracks"),
40a8d1c2
EB
56 VIK_DATASOURCE_SHELL_CMD,
57 VIK_DATASOURCE_CREATENEWLAYER,
58 VIK_DATASOURCE_INPUTTYPE_TRWLAYER,
59 FALSE, /* keep dialog open after success */
60 NULL, NULL, NULL,
61 (VikDataSourceGetCmdStringFunc) datasource_bfilter_simplify_get_cmd_string,
62 NULL, NULL, NULL,
2b756ea0 63 (VikDataSourceOffFunc) NULL,
40a8d1c2
EB
64
65 bfilter_simplify_params,
66 sizeof(bfilter_simplify_params)/sizeof(bfilter_simplify_params[0]),
67 bfilter_simplify_params_defaults,
68 NULL,
69 0
70};
71
72
73static void datasource_bfilter_simplify_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename )
74{
75 *input_file_type = NULL;
76 *cmd = g_strdup_printf ( "gpsbabel -i gpx -f %s -x simplify,count=%d -o gpx -F -", input_filename, paramdatas[0].u );
77}
78
79/************************************ Duplicate Location ***********************************/
80
81static void datasource_bfilter_dup_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename );
82
83/* TODO: shell_escape stuff */
84/* TODO: name is useless for filters */
85
86
87VikDataSourceInterface vik_datasource_bfilter_dup_interface = {
4c77d5e0
GB
88 N_("Remove Duplicate Waypoints"),
89 N_("Remove Duplicate Waypoints"),
40a8d1c2
EB
90 VIK_DATASOURCE_SHELL_CMD,
91 VIK_DATASOURCE_CREATENEWLAYER,
92 VIK_DATASOURCE_INPUTTYPE_TRWLAYER,
93 FALSE, /* keep dialog open after success */
94 NULL, NULL, NULL,
95 (VikDataSourceGetCmdStringFunc) datasource_bfilter_dup_get_cmd_string,
96 NULL, NULL, NULL,
2b756ea0 97 (VikDataSourceOffFunc) NULL,
40a8d1c2
EB
98
99 NULL, 0, NULL, NULL, 0
100};
101
102
103static void datasource_bfilter_dup_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename )
104{
105 *input_file_type = NULL;
7de42638 106 *cmd = g_strdup_printf ( "gpsbabel -i gpx -f %s -x duplicate,location -o gpx -F -", input_filename );
40a8d1c2
EB
107}
108
109
110/************************************ Polygon ***********************************/
111
112static void datasource_bfilter_polygon_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename, const gchar *input_track_filename );
113
114/* TODO: shell_escape stuff */
115/* TODO: name is useless for filters */
116
117
118VikDataSourceInterface vik_datasource_bfilter_polygon_interface = {
4c77d5e0 119 N_("Waypoints Inside This"),
8a7788c9 120 N_("Polygonized Layer"),
40a8d1c2
EB
121 VIK_DATASOURCE_SHELL_CMD,
122 VIK_DATASOURCE_CREATENEWLAYER,
123 VIK_DATASOURCE_INPUTTYPE_TRWLAYER_TRACK,
124 FALSE, /* keep dialog open after success */
125 NULL, NULL, NULL,
126 (VikDataSourceGetCmdStringFunc) datasource_bfilter_polygon_get_cmd_string,
127 NULL, NULL, NULL,
2b756ea0 128 (VikDataSourceOffFunc) NULL,
40a8d1c2
EB
129
130 NULL,
131 0,
132 NULL,
133 NULL,
134 0
135};
136
137
138static void datasource_bfilter_polygon_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename, const gchar *input_track_filename )
139{
140 *input_file_type = NULL;
141 *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 );
142}
143
144/************************************ Exclude Polygon ***********************************/
145
146static 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 );
147
148/* TODO: shell_escape stuff */
149/* TODO: name is useless for filters */
150
151
152VikDataSourceInterface vik_datasource_bfilter_exclude_polygon_interface = {
4c77d5e0
GB
153 N_("Waypoints Outside This"),
154 N_("Polygonzied Layer"),
40a8d1c2
EB
155 VIK_DATASOURCE_SHELL_CMD,
156 VIK_DATASOURCE_CREATENEWLAYER,
157 VIK_DATASOURCE_INPUTTYPE_TRWLAYER_TRACK,
158 FALSE, /* keep dialog open after success */
159 NULL, NULL, NULL,
160 (VikDataSourceGetCmdStringFunc) datasource_bfilter_exclude_polygon_get_cmd_string,
161 NULL, NULL, NULL,
2b756ea0 162 (VikDataSourceOffFunc) NULL,
40a8d1c2
EB
163
164 NULL,
165 0,
166 NULL,
167 NULL,
168 0
169};
170
171
172static 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 )
173{
174 *input_file_type = NULL;
175 *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 );
176}
177