| 1 |
<chapter xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="Usage"> |
| 2 |
<title>Usage</title> |
| 3 |
<section xml:id="Invocation"> |
| 4 |
<title>Invocation</title> |
| 5 |
<para>If you're using GPSBabel, you will need to know how to do at least two things: |
| 6 |
read data from a file, and write it to another file. There are four basic |
| 7 |
options you need to know to do those things: |
| 8 |
</para> |
| 9 |
<segmentedlist> |
| 10 |
<?dbhtml list-presentation="table"?> |
| 11 |
<segtitle>Command</segtitle> |
| 12 |
<segtitle>Meaning</segtitle> |
| 13 |
<seglistitem> |
| 14 |
<seg> |
| 15 |
<option>-i</option> |
| 16 |
<parameter class="command">format</parameter> |
| 17 |
</seg> |
| 18 |
<seg>Set input format</seg> |
| 19 |
</seglistitem> |
| 20 |
<seglistitem> |
| 21 |
<seg> |
| 22 |
<option>-f</option> |
| 23 |
<parameter class="command">filename</parameter> |
| 24 |
</seg> |
| 25 |
<seg>Read file</seg> |
| 26 |
</seglistitem> |
| 27 |
<seglistitem> |
| 28 |
<seg> |
| 29 |
<option>-o</option> |
| 30 |
<parameter class="command">format</parameter> |
| 31 |
</seg> |
| 32 |
<seg>Set output format</seg> |
| 33 |
</seglistitem> |
| 34 |
<seglistitem> |
| 35 |
<seg> |
| 36 |
<option>-F</option> |
| 37 |
<parameter class="command">filename</parameter> |
| 38 |
</seg> |
| 39 |
<seg>Write output file</seg> |
| 40 |
</seglistitem> |
| 41 |
</segmentedlist> |
| 42 |
<important> |
| 43 |
<para>Case matters. Notably |
| 44 |
<option>-f</option> |
| 45 |
(lowercase) sets the |
| 46 |
<emphasis>input</emphasis> |
| 47 |
file. |
| 48 |
<option>-F</option> |
| 49 |
(uppercase) sets the |
| 50 |
<emphasis>output</emphasis> |
| 51 |
file. </para> |
| 52 |
</important> |
| 53 |
<para>The |
| 54 |
<parameter class="command">format</parameter> |
| 55 |
parameters in the above list |
| 56 |
refer to the names of formats or file types supported by GPSBabel. </para> |
| 57 |
<para> |
| 58 |
<userinput>gpsbabel -? </userinput> |
| 59 |
</para> |
| 60 |
<para>will always show you the supported file types. In this document, the |
| 61 |
various supported formats are listed in |
| 62 |
<xref linkend="The_Formats"/> |
| 63 |
. The |
| 64 |
name that you would use on the command line follows the format name in |
| 65 |
parentheses.</para> |
| 66 |
<para>Options are |
| 67 |
<emphasis>always</emphasis> |
| 68 |
processed in order from left to right. |
| 69 |
In practical terms, this means that things you want to read should appear |
| 70 |
in the command before things you want to write. This sometimes surprises |
| 71 |
new users as adding options to turn on debugging at the end, for example, |
| 72 |
doesn't work as the debugging is turned on after all the interesting work is |
| 73 |
done. The reason for this strict ordering becomes more apparent once you |
| 74 |
learn about mixing formats and filters.</para> |
| 75 |
<para>The |
| 76 |
<parameter class="command">filename</parameter> |
| 77 |
parameters specify the |
| 78 |
name of a file to be read or written.</para> |
| 79 |
<para>To use |
| 80 |
GPSBabel in its simplest form, just tell it what you're reading, where to read |
| 81 |
it from, what you're writing, and what to write it to. For |
| 82 |
example:</para> |
| 83 |
<para> |
| 84 |
<userinput>gpsbabel -i geo -f /tmp/geocaching.loc -o gpx -F /tmp/geocaching.gpx</userinput> |
| 85 |
</para> |
| 86 |
<para>tells it to read the file |
| 87 |
<filename>/tmp/geocaching.loc</filename> |
| 88 |
in geocaching.com |
| 89 |
format and create a new file |
| 90 |
<filename>/tmp/geocaching.gpx</filename> |
| 91 |
in GPX format. It's important to note that the names have nothing to do with the formats actually used.</para> |
| 92 |
<para>This command will read from a Magellan unit attached |
| 93 |
to the first serial port on a Linux system (device names will |
| 94 |
vary on other OSes; typically COMx: on Windows) and write them as a geocaching loc file.</para> |
| 95 |
<example xml:id="linux_download_from_magellan"> |
| 96 |
<title>Command showing Linux download from Magellan serial and writing to .loc file</title> |
| 97 |
<para> |
| 98 |
<userinput>gpsbabel -i magellan -f /dev/ttyS0 -o geo -F mag.loc</userinput> |
| 99 |
</para> |
| 100 |
</example> |
| 101 |
<para>This second command does the same on Microsoft Windows.</para> |
| 102 |
<example xml:id="windows_download_from_magellan"> |
| 103 |
<title>Command showing Windows download from Magellan serial and writing to .loc file</title> |
| 104 |
<para> |
| 105 |
<userinput>gpsbabel -i magellan -f com1 -o geo -F mag.loc</userinput> |
| 106 |
</para> |
| 107 |
</example> |
| 108 |
<para>Optionally, you may specify |
| 109 |
<parameter>-s</parameter> |
| 110 |
in any command line. This |
| 111 |
causes the program to ignore any "short" names that may be |
| 112 |
present in the source data format and synthesize one from the |
| 113 |
long name. This is particularly useful if you're writing to |
| 114 |
a target format that isn't the lowest common denominator but |
| 115 |
the source data was written for the lowest common |
| 116 |
denominator. This is useful for writing data from geocaching.com |
| 117 |
to a GPS so my waypoints have "real" names instead of |
| 118 |
the 'GC1234' ones that are optimized for receivers of the lowest |
| 119 |
common denominator. |
| 120 |
A geocacher using Linux with a Magellan receiver may thus find commands |
| 121 |
like this useful.</para> |
| 122 |
<para> |
| 123 |
<userinput>gpsbabel -s -i geo -f geocaching.loc -o magellan -F /dev/ttyS0 </userinput> |
| 124 |
</para> |
| 125 |
<para>His counterpart on Windows will find this equivalent</para> |
| 126 |
<para> |
| 127 |
<userinput>gpsbabel -s -i geo -f geocaching.loc -o magellan -F com1</userinput> |
| 128 |
</para> |
| 129 |
</section> |
| 130 |
<section xml:id="Suboptions"> |
| 131 |
<title>Suboptions</title> |
| 132 |
<para>Many of the available format options in GPSBabel can themselves |
| 133 |
take options. While we try to make all the formats do the most |
| 134 |
sensible thing possible without any extra options; this allows |
| 135 |
great power and flexibility in the operation of the program. |
| 136 |
</para> |
| 137 |
<para>Suboptions are comma separated and immediately follow the option |
| 138 |
itself. The available suboptions are listed on the individual |
| 139 |
format pages. We'll make an example from |
| 140 |
<xref linkend="fmt_kml"/> |
| 141 |
:</para> |
| 142 |
<para> |
| 143 |
<userinput>gpsbabel -i gpx -f file.gpx -o kml,deficon="file://myicon.png",lines=0 -F one.kml -o kml -F two.kml</userinput> |
| 144 |
</para> |
| 145 |
<para>This command will read the GPX file |
| 146 |
<filename>file.gpx</filename> |
| 147 |
and create two KML files. |
| 148 |
<filename>one.kml</filename> |
| 149 |
will |
| 150 |
have the given icon and no lines between track and routepoints. |
| 151 |
|
| 152 |
<filename>two.kml</filename> |
| 153 |
will be created with the defaults used |
| 154 |
in the KML writer.</para> |
| 155 |
<para>Suboptions for the various formats allow you to change serial speeds, |
| 156 |
pass arguments to filters, change the type of file written, override |
| 157 |
icon defaults, and lots of other things. The suboptions for each |
| 158 |
filetype are documented on the page in this document that describes |
| 159 |
the option itself. |
| 160 |
</para> |
| 161 |
</section> |
| 162 |
<section xml:id="Advanced_Usage"> |
| 163 |
<title>Advanced Usage</title> |
| 164 |
<para>Argument are processed in the order they appear on the command |
| 165 |
line and are translated internally into a pipeline that data flows |
| 166 |
through when executed. Normally one would: </para> |
| 167 |
<simplelist type="vert"> |
| 168 |
<member>read from one input</member> |
| 169 |
<member>optionally apply filters </member> |
| 170 |
<member>write into one output</member> |
| 171 |
</simplelist> |
| 172 |
<para>but GPSBabel is flexible enough to allow more complicated |
| 173 |
operations such as reading from several files (potentially of |
| 174 |
different types), applying a filter, reading more data, then writing the |
| 175 |
merged data to multiple destinations. |
| 176 |
</para> |
| 177 |
<para>The input file type remains unchanged until a new |
| 178 |
|
| 179 |
<parameter>-i</parameter> |
| 180 |
argument is seen. |
| 181 |
Files are read in the order they appear. So you could merge |
| 182 |
three input files into one output file with: </para> |
| 183 |
<example xml:id="merging_files"> |
| 184 |
<title>Merging multiple files into one</title> |
| 185 |
<para> |
| 186 |
<userinput>gpsbabel -i geo -f 1.loc -f 2.loc -f 3.loc -o geo -F big.loc</userinput> |
| 187 |
</para> |
| 188 |
</example> |
| 189 |
<para>You can merge files of different types:</para> |
| 190 |
<example xml:id="merging_different_types_of_files"> |
| 191 |
<title>Merging multiple files of differing types.</title> |
| 192 |
<para> |
| 193 |
<userinput>gpsbabel -i geo -f 1.loc -i gpx -f 2.gpx -i pcx 3.pcx -o gpsutil -F big.gps</userinput> |
| 194 |
</para> |
| 195 |
</example> |
| 196 |
<example xml:id="multiple_writes"> |
| 197 |
<title>Writing the same data in multiple output formats.</title> |
| 198 |
<para>You can write the same data in different output formats:</para> |
| 199 |
<para> |
| 200 |
<userinput>gpsbabel -i geo -f 1.loc -o gpx -F 1.gpx -o pcx -F 1.wpt</userinput> |
| 201 |
</para> |
| 202 |
</example> |
| 203 |
</section> |
| 204 |
<section xml:id="Route_And_Track_Modes"> |
| 205 |
<title>Route and Track Modes</title> |
| 206 |
<para>Most formats supported by GPSBabel will make a reasonable attempt to work |
| 207 |
transparently with waypoints, tracks, and routes. Some |
| 208 |
formats, like |
| 209 |
<link linkend="fmt_garmin">garmin</link> |
| 210 |
require the |
| 211 |
<parameter>-t</parameter> |
| 212 |
flag to work with tracks and |
| 213 |
|
| 214 |
<parameter>-r</parameter> |
| 215 |
to work with |
| 216 |
routes. |
| 217 |
<parameter>-w</parameter> |
| 218 |
is for |
| 219 |
waypoints, and is the default. So if you wanted to read all |
| 220 |
data from a Magellan Meridian GPS receiver into a gpx file, you might use a command |
| 221 |
like:</para> |
| 222 |
<para> |
| 223 |
<userinput>gpsbabel -t -r -w -i magellan -f com1: -o gpx -F backup.gpx</userinput> |
| 224 |
</para> |
| 225 |
<para>Tracks and routes are advanced features and don't try |
| 226 |
to handle every possible hazard that can be encountered |
| 227 |
during a conversion. If you're merging or converting files |
| 228 |
of similar limitations, things work very well.</para> |
| 229 |
<para>Many of those hazards can be overcome with our filters |
| 230 |
but there are often compromises to be made. For example, if you |
| 231 |
have a GPX route that contains 150 turn points but you're sending |
| 232 |
the route to a GPS receiver that supports only 30 turnpoints, something has |
| 233 |
to go. One might use our 'simplify' filter to produce a route that |
| 234 |
retained the 30 most mathematically significant turnpoints but that |
| 235 |
may not really be the route you had in mind. |
| 236 |
</para> |
| 237 |
<para>Tracks and routes will sometimes be converted to a |
| 238 |
list of waypoints when necessary, One example is when writing into one |
| 239 |
of the CSV formats. The inverse operation is not supported |
| 240 |
right now, so reading the converted track back from CSV will |
| 241 |
always result in a list of waypoints, not the original track. |
| 242 |
</para> |
| 243 |
<para>The presence of |
| 244 |
<parameter>-s</parameter> |
| 245 |
on the command line tends to |
| 246 |
create havoc on tracks and routes since many of these formats |
| 247 |
rely on internal linkages between such points and renaming |
| 248 |
them may break those linkages. In general, don't use |
| 249 |
|
| 250 |
<parameter>-s</parameter> |
| 251 |
when tracks or |
| 252 |
routes are present.</para> |
| 253 |
</section> |
| 254 |
<section xml:id="inifile"> |
| 255 |
<title>Working with predefined options</title> |
| 256 |
<para>GPSBabel can read a file on startup to set defaults for options. All |
| 257 |
module and filter options may be set this way. |
| 258 |
</para> |
| 259 |
<para>The format of the file is identical to the inifile-format often seen |
| 260 |
on Windows. Here is an example: |
| 261 |
</para> |
| 262 |
<!--I don't know what the best "DOCbook-ese" is for this, but it's probably |
| 263 |
not a simplelist... rjl --> |
| 264 |
<simplelist columns="1"> |
| 265 |
<member>[Common format settings]</member> |
| 266 |
<member>snupper=Y</member> |
| 267 |
<member>snlen=10</member> |
| 268 |
<member>[gpx]</member> |
| 269 |
<member>gpxver=1.1</member> |
| 270 |
<member>[magellan]</member> |
| 271 |
<member>baud=115200</member> |
| 272 |
<member>[tiger]</member> |
| 273 |
<member>[Garmin categories]</member> |
| 274 |
<member>; any # from 1 to 16</member> |
| 275 |
<member>1=fixed waypoints</member> |
| 276 |
<member>2=temporary waypoints</member> |
| 277 |
</simplelist> |
| 278 |
<para>Each section of the file starts with a '[section]' header followed by any |
| 279 |
number of lines formatted option=value. Leading and trailing whitespace |
| 280 |
will be |
| 281 |
automatically removed from header, option and value items. |
| 282 |
|
| 283 |
<!--Are there any other lines? If not, why name them? rjl --> |
| 284 |
Lines starting |
| 285 |
with '#' or ';' will be treated as comments and ignored.</para> |
| 286 |
<para>There are three optional sections. |
| 287 |
|
| 288 |
<itemizedlist> |
| 289 |
<listitem> |
| 290 |
<para>Common format settings.</para> |
| 291 |
<para>Any option from any of the formats listed here will be used by |
| 292 |
GPSBabel unless explicitly provided on the command line.</para> |
| 293 |
</listitem> |
| 294 |
<listitem> |
| 295 |
<para>Common filter settings.</para> |
| 296 |
<para>As above, but for filters.</para> |
| 297 |
</listitem> |
| 298 |
<listitem> |
| 299 |
<para>Garmin categories</para> |
| 300 |
<para>This allows you to give readable names to the numeric categories |
| 301 |
used internally in some Garmin devices and the Mapsource formats |
| 302 |
such as GDB and MPS. This is information is also used by our GPX |
| 303 |
and garmin_txt formats as well.</para> |
| 304 |
</listitem> |
| 305 |
</itemizedlist> |
| 306 |
</para> |
| 307 |
<para>By default, GPSBabel tries at startup to load the file named |
| 308 |
|
| 309 |
<filename>gpsbabel.ini</filename> |
| 310 |
from the following locations:</para> |
| 311 |
<itemizedlist> |
| 312 |
<listitem> |
| 313 |
<para>current working directory</para> |
| 314 |
</listitem> |
| 315 |
<listitem> |
| 316 |
<para>Windows: all paths "APPDATA", "WINDIR", "SYSTEMROOT" declared in environment.</para> |
| 317 |
</listitem> |
| 318 |
<listitem> |
| 319 |
<para>Unix like OS'ses: |
| 320 |
<filename>${HOME}/.gpsbabel/</filename> |
| 321 |
, |
| 322 |
<filename>/usr/local/etc/</filename> |
| 323 |
and |
| 324 |
<filename>/etc/</filename></para> |
| 325 |
</listitem> |
| 326 |
</itemizedlist> |
| 327 |
<para>If the |
| 328 |
<option>-p</option> |
| 329 |
option is specified, the above locations are not searched. |
| 330 |
Only the filename specified by that option will be used.</para> |
| 331 |
<para>There may be situations where predefined values are not usable |
| 332 |
(i.e. wrapper applications using GPSBabel in the background). |
| 333 |
The inifile mechanism can be disabled with an empty filename. |
| 334 |
</para> |
| 335 |
<para> |
| 336 |
<userinput>gpsbabel -p "" -i gpx -f something.gpx -o tiger -F -</userinput> |
| 337 |
</para> |
| 338 |
</section> |
| 339 |
<section xml:id="tracking"> |
| 340 |
<title>Realtime tracking</title> |
| 341 |
<para>Introduced in GPSBabel 1.3.1, we now have an |
| 342 |
<emphasis>experimental</emphasis> |
| 343 |
feature for realtime tracking via the new |
| 344 |
<option>-T</option> |
| 345 |
option. This reads position reports from selected formats and writes an output file when a position report is received. </para> |
| 346 |
<para>As of this writing, |
| 347 |
<link linkend="fmt_garmin">Garmin's PVT |
| 348 |
protocol</link> |
| 349 |
and |
| 350 |
|
| 351 |
<link linkend="fmt_nmea">NMEA</link> |
| 352 |
are supported |
| 353 |
inputs. KML, NMEA, and the various XCSV formats are supported on |
| 354 |
output. Additional formats may be added by interested parties |
| 355 |
later.</para> |
| 356 |
<example xml:id="realtime_reading"> |
| 357 |
<title>Read realtime positioning from Garmin USB, write to Keyhole Markup</title> |
| 358 |
<para> |
| 359 |
<userinput>gpsbabel -T -i garmin -f usb: -o kml -F example.kml</userinput> |
| 360 |
</para> |
| 361 |
<para>Will read the USB-connected Garmin and rewrite 'example.kml' atomically, |
| 362 |
suitable for a self-refreshing network link in Google Earth. |
| 363 |
</para> |
| 364 |
</example> |
| 365 |
<example xml:id="realtime_reading_wintec"> |
| 366 |
<title>Read realtime positioning from Wintec WBT-201 via Bluetooth on Mac, write to Keyhole Markup</title> |
| 367 |
<para> |
| 368 |
<userinput>gpsbabel -T -i nmea -f /dev/cu.G-Rays2-SPPslave-1 -o kml -F example.kml</userinput> |
| 369 |
</para> |
| 370 |
<para>Will read the Wintec WBT-201 via Bluetooth, using the name that |
| 371 |
the Mac assigned it, and rewrite 'example.kml' atomically, |
| 372 |
suitable for a self-refreshing network link in Google Earth. |
| 373 |
</para> |
| 374 |
</example> |
| 375 |
<para>Be sure to substitute an device name appropriate for your device |
| 376 |
and OS, such as |
| 377 |
<filename>/dev/cu.usbserial</filename> |
| 378 |
or |
| 379 |
|
| 380 |
<filename>/dev/cu.BT-GPS-37A695-BT-GPSCOM-1</filename> |
| 381 |
for Mac, |
| 382 |
<filename>COM23:</filename> |
| 383 |
for Windows, or |
| 384 |
|
| 385 |
<filename>usb:</filename> |
| 386 |
for |
| 387 |
|
| 388 |
<link linkend="fmt_garmin">Garmin USB</link> |
| 389 |
. These names |
| 390 |
(except the "usb:" parlance for Garmin USB) are assigned by |
| 391 |
your operating system.</para> |
| 392 |
</section> |
| 393 |
<section xml:id="batchfile"> |
| 394 |
<title>Batch mode (command files)</title> |
| 395 |
<para>In addition to reading arguments from the command line, GPSBabel can |
| 396 |
read directions from batch (or command) files via the |
| 397 |
<option>-b</option> |
| 398 |
option.</para> |
| 399 |
<para>These files are ideal for holding long command lines, long file lists, complex filters |
| 400 |
and so on. You can use all GPSBabel options and combinations when writing |
| 401 |
such files. Nesting batch files by using the |
| 402 |
<option>-b</option> |
| 403 |
option within a batch file is supported.</para> |
| 404 |
<para>Here is an example demonstrating segmenting a large command line |
| 405 |
by placing the input and filtering directives in a file called 'all_my_files'. |
| 406 |
</para> |
| 407 |
<para> |
| 408 |
<userinput>gpsbabel -b all_my_files -o gdb -F all_my_tracks.gdb</userinput> |
| 409 |
</para> |
| 410 |
<para>'all_my_files' could look like this: |
| 411 |
</para> |
| 412 |
<simplelist columns="1"> |
| 413 |
<member>-i gpx</member> |
| 414 |
<member>-f saxony_in_summer_2004.gpx -f austria_2005.gpx</member> |
| 415 |
<member>-i gdb</member> |
| 416 |
<member>-f croatia_2006.gdb</member> |
| 417 |
<member>-x nuketypes,waypoints,routes</member> |
| 418 |
<member>-x track,pack,split,title="LOG # %Y%m%d"</member> |
| 419 |
</simplelist> |
| 420 |
</section> |
| 421 |
<section xml:id="all_options"> |
| 422 |
<title>List of Options</title> |
| 423 |
<para>The complete list of available options to GPSBabel can be obtained by |
| 424 |
running |
| 425 |
<command>gpsbabel -h</command> |
| 426 |
. While there are a number of |
| 427 |
options, most people will not use most of them, so don't be intimidated.</para> |
| 428 |
<para> |
| 429 |
<option>-p</option> Read preferences file. On startup, GPSBabel will look for a file named |
| 430 |
<filename>gpsbabel.ini</filename> |
| 431 |
containing preferences you have provided. This option lets you pick a different files. See |
| 432 |
<xref linkend="inifile"/> |
| 433 |
for more info.</para> |
| 434 |
<para> |
| 435 |
<option>-s</option> Write "smart" names. This option influences some - but not all - of our writers to try to build "smart" waypoint names. For example, in modules that know about geocaching, it may replace "GC1234" with the actual name of the geocache.</para> |
| 436 |
<para> |
| 437 |
<option>-r</option> Work on routes. This option has a subtly different meaning in different cases. As the very first formats in GPSBabel were for serial GPSes and routes and tracks were large and thus time-consuming to transfer, the default was waypoints only with this option to turn on the extra data. Some of our file formats use this option to mean "work only on routes, even if you have tracks/waypoints", but we're trying to discourage that behavior and in most cases, consider it a bug. </para> |
| 438 |
<para> |
| 439 |
<option>-t</option> Work on tracks. See |
| 440 |
<option>-r</option> |
| 441 |
for usage.</para> |
| 442 |
<para> |
| 443 |
<option>-w</option> Work on waypoints. This is the default. </para> |
| 444 |
<para> |
| 445 |
<option>-T</option> Enable Realtime tracking. This option isn't supported by the majority of our file formats, but repeatedly reads location from a GPS and writes it to a file as described in |
| 446 |
<xref linkend="tracking"/></para> |
| 447 |
<para> |
| 448 |
<option>-b</option> Process batch file. In addition to reading arguments from the command line, we can read them from files containing lists of commands as described in |
| 449 |
<xref linkend="batchfile"/></para> |
| 450 |
<para> |
| 451 |
<option>-x</option> <parameter class="command">filter</parameter> Run filter. This option lets use use one of of our many data filters. Position of this in the command line does matter - remember, we process left to right.</para> |
| 452 |
<para> |
| 453 |
<option>-D</option> Enable debugging. Not all formats support this. It's typically better supported by the various protocol modules because they just plain need more debugging. This option may be followed by a number. Zero means no debugging. Larger numbers mean more debugging. </para> |
| 454 |
<para> |
| 455 |
<option>-h</option>, |
| 456 |
<option>-?</option> Print help. </para> |
| 457 |
<para> |
| 458 |
<option>-V</option> Print version number. </para> |
| 459 |
</section> |
| 460 |
</chapter> |