This file is indexed.

/usr/bin/gpspoint2gpsdrive is in gpsdrive-scripts 2.10~pre4-6.dfsg-5.2ubuntu1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
#!/usr/bin/perl -w
#
# gpspoint2gpsdrive.pl
#
# Convert gpspoint track file to gpsdrive track file(s)
#
# Copyleft 2002 Stephen Merrony <steveATcygnetDOTcoDOTuk>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# Change log:
#
# Author         Version       Details
#---------------------------------------------------------------------------------
# S.Merrony       0.0.2        Fix bogus track extraction, add waypoint extraction
# S.Merrony       0.0.3        Fix case where no altitude, add version number to help
#
# $Log$
# Revision 1.4  2006/07/31 08:20:08  tweety
# lat/long space problem fix
# http://bugzilla.gpsdrive.cc/show_bug.cgi?id=78
#
# Revision 1.3  2005/04/13 19:58:30  tweety
# renew indentation to 4 spaces + tabstop=8
#
# Revision 1.2  2005/04/10 00:15:58  tweety
# changed primary language for poi-type generation to english
# added translation for POI-types
# added some icons classifications to poi-types
# added LOG: Entry for CVS to some *.pm Files
#

BEGIN {
    my $dir = $0;
    $dir =~s,[^/]+/[^/]+$,,;
    unshift(@INC,"$dir/perl_lib");

    # For Debug Purpose in the build Directory
    unshift(@INC,"./perl_lib");
    unshift(@INC,"./scripts/perl_lib");
    unshift(@INC,"../scripts/perl_lib");

    # For DSL
    unshift(@INC,"/opt/gpsdrive/share/perl5");
    unshift(@INC,"/opt/gpsdrive"); # For DSL
};

my $Version = '$Revision: 1553 $'; 
$Version =~ s/\$Revision:\s*(\d+)\s*\$/$1/; 

use strict;

my %opts;
use Getopt::Std;
getopts('hf:wv', \%opts);

$opts{h} = 0 if (!defined( $opts{h} ));
$opts{w} = 0 if (!defined( $opts{w} ));
$opts{v} = 0 if (!defined( $opts{v} ));

my $trackfnprefix = "track";
my $trackfnext    = ".sav";
my $pointformat   = "%10.6f %10.6f %10.0d %s\n";  # <=== This is the gpsdrive track format ===
my $wayptfilename = "way.txt";
my $wayptformat   = "%s %10.6f %10.6f\n";      # <=== This is the gpsdrive waypoint format ===

my $wayptcnt      = 0;
my $trackcount    = 0;

# Help!
if ($opts{h} ) {
    my $help = <<'ENDOFHELP';

    gpspoint2gpsdrive.pl:
    =====================

	Extract gpsdrive-compatible track file(s) from a gpspoint file.
	Optionally also extracts waypoints and appends them to way.txt.

	-h                     This help message - you guessed that!
	-f <gpspointfilename>  The file to extract tracks from.
	-w                     Extract waypoints and append to way.txt
	-v                     Verbose mode - yada yada yada

	Version $Version

ENDOFHELP
	print $help;
    exit;
}

if (!$opts{f} or $opts{f} eq "" ) {
    print "Error: You must enter a filename via the -f switch.\n";
    exit;
}

use FileHandle;

my $infile;

# open the file for reading if we can - else bail out
$infile = new FileHandle "< $opts{f}";
if (!defined( $infile )) {
    print "Error: Unable to open file '$opts{f}' for input\n";
    exit;
}

my $am_writing = 0;

my ($latitude, $longitude,  $timestamp, $wayptname);
my $altitude = 1.0;
my $thisline;
my $trackfilename;
my $trackfile = new FileHandle;
my $wayptfile = new FileHandle;
my $blocktype;
my $dummytime = 0;

# plough through the file
while (<$infile>) {

    $thisline = $_;
    chomp( $thisline ); # remove newline

    # Gpspoint files contain comments starting with a # symbol, blank lines
    # and lines with comma separated lists of values and name-value pairs
    # We only want certain name-value pairs...

    # ignore comments and blank or very short lines
    if ( (substr( $thisline, 0, 1 ) ne "#") &&
	 (length( $thisline ) > 5 ) ) {
	
	my (@pairs, $pair);

	@pairs = split( /\s+/, $thisline );
	foreach $pair ( @pairs ) {
	    my $name = "";
	    my $value = "";
	    ($name, $value) = split( '=', $pair );
	    if (defined( $name ) && defined( $value )) { # only process pairs
		$value = substr( $value, 1, length( $value ) - 2 );  # remove quotes

		# starting a new track?
		if (($name eq "type") && ($value eq "track" )) {
		    # $trackfile->close if ($am_writing);
		    $am_writing = 0;
		    $blocktype = "TRACK";
		    print "Info: Found start of track\n" if ($opts{v} eq 1);
		}
		# new set of waypoints?
		elsif (($name eq "type") && ($value eq "waypointlist") && $opts{w}) {
		    $am_writing = 0;
		    $blocktype = "WAYPOINTS";
		    print "Info: Found start of waypoint list\n" if ($opts{v} eq 1);
		    if (!$wayptfile->open( ">> $wayptfilename" )) {
			print "Error: Unable to append to waypoint file '$wayptfilename'\n";
			exit;
		    }
		    $am_writing = 1;
		    print "Info: Starting writing waypoint s to '$wayptfilename'\n" if ($opts{v} eq 1);
		}
		elsif (($name eq "type") && ($value eq "route")) {
		    # not interested in routes at this stage
		    $blocktype = "";
		    $am_writing = 0;
		}
		
		# trap other info types here?

		# name of a new track
		if (defined( $name ) && ($name eq "name") && defined( $blocktype ) && ($blocktype eq "TRACK")) {
		    $trackfilename = $trackfnprefix . $value . $trackfnext;
		    if (!$trackfile->open("> $trackfilename" )) {
			print "Error: Unable to open track output file '$trackfilename'\n";
			exit;
		    }
		    $am_writing = 1;
		    $trackcount++;
		    print "Info: Starting to write track '$trackfilename'\n" if ($opts{v} eq 1);
		}

		# name of a new waypoint
		if (($opts{w} eq 1) && ($blocktype eq "WAYPOINTS") && ($name eq "name")) {
		    $wayptname = $value;
		    $wayptcnt++;
		}

		if ($name eq "latitude" ) {
		    $latitude  = $value;
		}
		if ($name eq "longitude" ) {
		    $longitude = $value;
		}
		if ($name eq "altitude" ) {
		    $altitude  = $value;
		}
		if ($name eq "unixtime" ) {
		    $timestamp = localtime( $value );
		}
	    }
	    $latitude  = $1 if $thisline =~ m/latitude=\"\s*([\+\-\d\.\,]+)\"/;
	    $longitude = $1 if $thisline =~ m/longitude=\"\s*([\+\-\d\.\,]+)\"/;
	    $altitude  = $1 if $thisline =~ m/altitude=\"\s*([\+\-\d\.\,]+)\"/;
	} # end of name-value pair loop
	#print $thisline;
    } #end if

    # done with this line - write out a trackfile line if we have one
    if ($am_writing && defined( $longitude )  && ($blocktype eq "TRACK")) {
	# some tracks have no time info - so we'll insert an early timestamp
	$timestamp = localtime(0) if (!defined( $timestamp ));
	printf $trackfile $pointformat, ($latitude, $longitude, $altitude, $timestamp);
    }

    # done with this line - write out a waypoint line if we have one
    if ($am_writing && defined( $latitude )  && ($blocktype eq "WAYPOINTS")) {
	printf $wayptfile $wayptformat, ($wayptname, $latitude, $longitude);
    }

} # end of per-line loop

# clean up nicely
$infile->close;
$trackfile->close if ($opts{w} eq 1);

print "Info: All done.\n" if ($opts{v} eq 1);
print "$trackcount tracks and $wayptcnt waypoints extracted\n";

__END__


=head1 NAME

B<gpspoint2gpsdrive.pl>

=head1 DESCRIPTION

B<gpspoint2gpsdrive.pl>

Extract gpsdrive-compatible track file(s) from a gpspoint file.
Optionally also extracts waypoints and appends them to way.txt.

=head1 SYNOPSIS

B<Common usages:>

=head1 OPTIONS


=over 8

=item B<-h>

This help message - you guessed that!

=item B<-f> <gpspointfilename>

The file to extract tracks from.

=item B<-w>

Extract waypoints and append to way.txt

=item B<-v>

Verbose mode - yada yada yada


=head1 AUTHOR

Written by 

=head1 COPYRIGHT

This is free software.  You may redistribute copies of it under the terms of the GNU General Pub-
lic  License <http://www.gnu.org/licenses/gpl.html>.  There is NO WARRANTY, to the extent permit-
ted by law.

=head1 SEE ALSO

gpsdrive(1)

=cut