]> git.street.me.uk Git - andy/viking.git/blob - src/datasource_bfilter.c
add another missing file
[andy/viking.git] / src / datasource_bfilter.c
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  */
21 #include "config.h"
22 #include <string.h>
23
24 #include "viking.h"
25 #include "babel.h"
26 #include "gpx.h"
27 #include "acquire.h"
28
29
30 /************************************ Simplify ***********************************/
31
32 static void datasource_bfilter_simplify_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename );
33
34 /* TODO: shell_escape stuff */
35 /* TODO: name is useless for filters */
36
37 /* spin button scales */
38 VikLayerParamScale simplify_params_scales[] = {
39   {1, 10000, 10, 0},
40 };
41
42 VikLayerParam bfilter_simplify_params[] = {
43   { "numberofpoints", VIK_LAYER_PARAM_UINT, VIK_LAYER_GROUP_NONE, "Max number of points:", VIK_LAYER_WIDGET_SPINBUTTON, simplify_params_scales + 0 },
44 };
45
46 VikLayerParamData bfilter_simplify_params_defaults[] = {
47   { 100 },
48 };
49
50 VikDataSourceInterface vik_datasource_bfilter_simplify_interface = {
51   "Simplify All Tracks",
52   "Simplified Tracks",
53   VIK_DATASOURCE_SHELL_CMD,
54   VIK_DATASOURCE_CREATENEWLAYER,
55   VIK_DATASOURCE_INPUTTYPE_TRWLAYER,
56   FALSE, /* keep dialog open after success */
57   NULL, NULL, NULL,
58   (VikDataSourceGetCmdStringFunc)       datasource_bfilter_simplify_get_cmd_string,
59   NULL, NULL, NULL,
60
61   bfilter_simplify_params,
62   sizeof(bfilter_simplify_params)/sizeof(bfilter_simplify_params[0]),
63   bfilter_simplify_params_defaults,
64   NULL,
65   0
66 };
67
68
69 static void datasource_bfilter_simplify_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename )
70 {
71   *input_file_type = NULL;
72   *cmd = g_strdup_printf ( "gpsbabel -i gpx -f %s -x simplify,count=%d -o gpx -F -", input_filename, paramdatas[0].u );
73 }
74
75 /************************************ Duplicate Location ***********************************/
76
77 static void datasource_bfilter_dup_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename );
78
79 /* TODO: shell_escape stuff */
80 /* TODO: name is useless for filters */
81
82
83 VikDataSourceInterface vik_datasource_bfilter_dup_interface = {
84   "Remove Duplicate Waypoints",
85   "Remove Duplicate Waypoints",
86   VIK_DATASOURCE_SHELL_CMD,
87   VIK_DATASOURCE_CREATENEWLAYER,
88   VIK_DATASOURCE_INPUTTYPE_TRWLAYER,
89   FALSE, /* keep dialog open after success */
90   NULL, NULL, NULL,
91   (VikDataSourceGetCmdStringFunc)       datasource_bfilter_dup_get_cmd_string,
92   NULL, NULL, NULL,
93
94   NULL, 0, NULL, NULL, 0
95 };
96
97
98 static void datasource_bfilter_dup_get_cmd_string ( VikLayerParamData *paramdatas, gchar **cmd, gchar **input_file_type, const gchar *input_filename )
99 {
100   *input_file_type = NULL;
101   *cmd = g_strdup_printf ( "gpsbabel -i gpx -f %s -x dup,loc -o gpx -F -", input_filename );
102 }
103
104
105 /************************************ Polygon ***********************************/
106
107 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 );
108
109 /* TODO: shell_escape stuff */
110 /* TODO: name is useless for filters */
111
112
113 VikDataSourceInterface vik_datasource_bfilter_polygon_interface = {
114   "Waypoints Inside This",
115   "Polygonzied Layer",
116   VIK_DATASOURCE_SHELL_CMD,
117   VIK_DATASOURCE_CREATENEWLAYER,
118   VIK_DATASOURCE_INPUTTYPE_TRWLAYER_TRACK,
119   FALSE, /* keep dialog open after success */
120   NULL, NULL, NULL,
121   (VikDataSourceGetCmdStringFunc)       datasource_bfilter_polygon_get_cmd_string,
122   NULL, NULL, NULL,
123
124   NULL,
125   0,
126   NULL,
127   NULL,
128   0
129 };
130
131
132 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 )
133 {
134   *input_file_type = NULL;
135   *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 );
136 }
137
138 /************************************ Exclude Polygon ***********************************/
139
140 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 );
141
142 /* TODO: shell_escape stuff */
143 /* TODO: name is useless for filters */
144
145
146 VikDataSourceInterface vik_datasource_bfilter_exclude_polygon_interface = {
147   "Waypoints Outside This",
148   "Polygonzied Layer",
149   VIK_DATASOURCE_SHELL_CMD,
150   VIK_DATASOURCE_CREATENEWLAYER,
151   VIK_DATASOURCE_INPUTTYPE_TRWLAYER_TRACK,
152   FALSE, /* keep dialog open after success */
153   NULL, NULL, NULL,
154   (VikDataSourceGetCmdStringFunc)       datasource_bfilter_exclude_polygon_get_cmd_string,
155   NULL, NULL, NULL,
156
157   NULL,
158   0,
159   NULL,
160   NULL,
161   0
162 };
163
164
165 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 )
166 {
167   *input_file_type = NULL;
168   *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 );
169 }
170