<para>
Delorme XMapHandHeld Street Atlas USA is another of the
billion <link linkend="fmt_csv"> CSV variants</link>.  
This is the format used by XmapHH SA USA on (at least) PocketPC O/S. 
</para>
<para> 
This XMap is not the same as the simpler 
<link linkend="fmt_xmap">XMap</link> format, which is used with Topo USA 4.0
and XMapHH for Palm. 
</para>
<para>
Delorme XMap Handheld .WPT for PocketPC is a bit of a kludge.  This 
chapter covers XMap Handheld Street Atlas USA edition.
</para>
<para>
XMap on the PocketPC stores its waypoints in individual .wpt files.
For example, waypoints generated by XMap on the PocketPC are stored
by default in the "My Documents" folder using the sequential names
"XMap1.wpt", "XMap2.wpt", ad nauseum.  Needless to say, this is not very
efficient.
</para>
<para>
As writing multiple waypoint files is outside of the scope of GPSBabel,
GPSBabel chooses to write one big file, one waypoint per line.  
Extracting lines from this file is left as an exercise for the end user.  
A simple Perl script to handle this conversion is included at the end 
of this chapter.
</para>
<para>
It should also be noted that <emphasis>reading</emphasis> multiple files 
is indeed possible, but if you have more than a few points, it can be a task. 
For example:
</para>
<para><userinput>gpsbabel -i xmapwpt -f Xmap1.wpt -f Xmap2.wpt -o mapsend -F mapsend.wpt</userinput></para>
<para>
will read the two Xmap .wpt files and write one mapsend file.  This
is fine for a small handful of points, but could be quite cumbersome
for folks like me who have 100+ waypoints loaded into XMap.  For *nix
folks, something as simple as:
</para>
<para><userinput>cat *.wpt > /tmp/foo.wpt</userinput>
<userinput>gpsbabel -i xmapwpt -f foo.wpt -o mapsend -F mapsend.wpt </userinput></para>
<para>
will do the trick just fine.  
</para>
<programlisting>
#!/full/path/to/perl
$INPUTFILE = @ARGV[0];
$TARGETDIR = @ARGV[1];
$FILENAME  = @ARGV[2];

if (! $FILENAME) {
    print "Usage: xmap_split.pl " . 
	"INPUT_FILE OUTPUT_DIRECTORY FILENAME_BASE\n";
    print " (i.e. xmapl_split.pl points.wpt /tmp/points GPSB)\n";
    print " (created GPSB0001-GPSBXXXX " .
	" in /tmp/points/ from points.wpt)\n";
    exit;
}

open (INFILE, $INPUTFILE) || die "Cannot open $INPUTFILE for read!\n";

while (&lt;INFILE&gt;) {
    $lc++;
    $filename = sprintf("%s/Gpsb%04d.wpt", $TARGETDIR, $lc);

    open (OUTFILE, "&gt;$filename") || 
	die "Cannot open $filename for write!\n";

    print OUTFILE $_;

    close(OUTFILE);
}

exit;

</programlisting>

<para>Contributed to GPSBabel by Alex Mottram.</para>
    
