3 #=======================================================================
7 # ©opyleft 2002– Øyvind A. Holm <sunny@sunbase.org>
8 # License: GNU General Public License, see end of file for legal stuff.
9 #=======================================================================
16 our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
19 push(@main::version_array
, $rcs_id);
20 $VERSION = ($rcs_id =~ / (\d+) /, $1);
23 @EXPORT = qw(&list_nearest_waypoints &ddd_to_dms);
28 sub list_nearest_waypoints
{
30 my ($Lat, $Lon, $Count) = @_;
33 my $waypoint_file = "/home/sunny/gps/waypoints.gpx";
35 # FIXME: Incredible unfinished and kludgy.
36 if (open(WaypFP
, "$main::Cmd{'gpsbabel'} -i gpx -f $waypoint_file " .
37 "-x radius,lat=$Lat,lon=$Lon,distance=1000 " .
40 my $Str = join("", <WaypFP
>);
42 ^.*?
<wpt\s
.*?
>.*?
<name
>(.+?
)</name>.*?</wpt
>.*?
43 .*?
<wpt\s
.*?
>.*?
<name
>(.+?
)</name>.*?</wpt
>.*?
44 .*?
<wpt\s
.*?
>.*?
<name
>(.+?
)</name>.*?</wpt
>.*$
50 die("$main::progname: Cannot open $main::Cmd{'gpsbabel'} pipe: $!\n");
56 # Convert floating-point degrees into D°M'S.S" (ISO-8859-1).
57 # Necessary for import into GPSman. Based on toDMS() from
58 # gpstrans-0.39 to ensure compatibility.
62 my ($Hour, $Min, $Sec) =
66 ($ddd =~ /^\-?(\d*)(\.\d+)?$/) || return(undef);
67 length($ddd) || ($ddd = 0);
74 $ddd = ($ddd - $Hour) * 60.0;
76 $Sec = ($ddd - $Min) * 60.0;
86 $Retval = sprintf("%s%.0f\xB0%02.0f'%04.1f\"",