1 /**********************************************************
2  * Version $Id: GPSBabel.cpp 911 2011-02-14 16:38:15Z reklov_w $
3  *********************************************************/
4 /*******************************************************************************
5     GPSBabel.cpp
6     Copyright (C) Victor Olaya
7 
8     This program is free software; you can redistribute it and/or modify
9     it under the terms of the GNU General Public License as published by
10     the Free Software Foundation; either version 2 of the License, or
11     (at your option) any later version.
12 
13     This program is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17 
18     You should have received a copy of the GNU General Public License
19     along with this program; if not, write to the Free Software
20     Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA
21 *******************************************************************************/
22 #include "GPSBabel.h"
23 
24 CSG_String	sGPSBabelID[]	=
25 {
26 	"geo",
27 	"gpsman",
28 	"gpx",
29 	"magellan",
30 	"mapsend",
31 	"pcx",
32 	"mapsource",
33 	"gpsutil",
34 	"tiger",
35 	"csv",
36 	"xmap",
37 	"dna",
38 	"psp",
39 	"cetus",
40 	"gpspilot",
41 	"magnav",
42 	"garmin",
43 	"mxf",
44 	"holux",
45 	"ozi",
46 	"tpg",
47 	"tmpro"
48 };
49 
CGPSBabel()50 CGPSBabel::CGPSBabel(){
51 
52 	Parameters.Set_Name(_TL("GPSBabel"));
53 
54 	Parameters.Set_Description(_TW(
55 		"An interface to the GPSBabel software"
56 		"(c) 2005 by Victor Olaya\r\nemail: volaya@ya.com"));
57 
58 	Parameters.Add_FilePath(NULL,
59 							"BASEPATH",
60 							_TL("GPSBabel path"),
61 							_TL("GPSBabel path"),
62 							_TL(""),
63 							_TL(""),
64 							false,
65 							true);
66 
67 	Parameters.Add_FilePath(NULL,
68 							"INPUT",
69 							_TL("Input file"),
70 							_TL(""),
71 							_TL("All Files|*.*|"));
72 
73 	Parameters.Add_Choice(NULL,
74 						"FORMATIN",
75 						_TL("Input format"),
76 						_TL(""),
77 						_TW("Geocaching.com .loc|"
78 							"GPSman|"
79 							"GPX XML|"
80 							"Magellan protocol|"
81 							"Magellan Mapsend|"
82 							"Garmin PCX5|"
83 							"Garmin Mapsource|"
84 							"gpsutil|"
85 							"U.S. Census Bureau Tiger Mapping Service|"
86 							"Comma separated values|"
87 							"Delorme Topo USA4/XMap Conduit|"
88 							"Navitrak DNA marker format|"
89 							"MS PocketStreets 2002 Pushpin|"
90 							"Cetus for Palm/OS|"
91 							"GPSPilot Tracker for Palm/OS|"
92 							"Magellan NAV Companion for PalmOS|"
93 							"Garmin serial protocol|"
94 							"MapTech Exchange Format|"
95 							"Holux (gm-100) .wpo Format|"
96 							"OziExplorer Waypoint|"
97 							"National Geographic Topo .tpg|"
98 							"TopoMapPro Places File|"
99 						),	0);
100 
101 	Parameters.Add_FilePath(NULL,
102 							"OUTPUT",
103 							_TL("Output file"),
104 							_TL(""),
105 							_TL("All Files|*.*|"),
106 							_TL(""),
107 							true,
108 							false);
109 
110 	Parameters.Add_Choice(NULL,
111 						"FORMATOUT",
112 						_TL("Output format"),
113 						_TL(""),
114 					_TW("Geocaching.com .loc|"
115 						"GPSman|"
116 						"GPX XML|"
117 						"Magellan protocol|"
118 						"Magellan Mapsend|"
119 						"Garmin PCX5|"
120 						"Garmin Mapsource|"
121 						"gpsutil|"
122 						"U.S. Census Bureau Tiger Mapping Service|"
123 						"Comma separated values|"
124 						"Delorme Topo USA4/XMap Conduit|"
125 						"Navitrak DNA marker format|"
126 						"MS PocketStreets 2002 Pushpin|"
127 						"Cetus for Palm/OS|"
128 						"GPSPilot Tracker for Palm/OS|"
129 						"Magellan NAV Companion for PalmOS|"
130 						"Garmin serial protocol|"
131 						"MapTech Exchange Format|"
132 						"Holux (gm-100) .wpo Format|"
133 						"OziExplorer Waypoint|"
134 						"National Geographic Topo .tpg|"
135 						"TopoMapPro Places File|"),
136 						0);
137 
138 }//constructor
139 
~CGPSBabel()140 CGPSBabel::~CGPSBabel(){
141 
142 }//destructor
143 
On_Execute(void)144 bool CGPSBabel::On_Execute(void){
145 
146 	CSG_String sCmd;
147 	CSG_String sInputFile = Parameters("INPUT")->asString();
148 	CSG_String sOutputFile = Parameters("OUTPUT")->asString();
149 	CSG_String sBasePath = Parameters("BASEPATH")->asString();
150 	int iInputFormat = Parameters("FORMATIN")->asInt();
151 	int iOutputFormat = Parameters("FORMATOUT")->asInt();
152 
153 	sCmd = sBasePath + SG_T("\\") + SG_T("gpsbabel.exe ")
154 			+ SG_T("-i ") + sGPSBabelID[iInputFormat]	+ SG_T(" ")
155 			+ SG_T("-f ") + sInputFile					+ SG_T(" ")
156 			+ SG_T("-o ") + sGPSBabelID[iOutputFormat]	+ SG_T(" ")
157 			+ SG_T("-F ") + sOutputFile					+ SG_T(" ");
158 
159 	system(sCmd.b_str());
160 
161 	return true;
162 
163 }//method