3 #=======================================================================
5 # File ID: 6ac1a50e-fafa-11dd-a267-000475e441b9
8 # ©opyleft 2002– Øyvind A. Holm <sunny@sunbase.org>
9 # License: GNU General Public License, see end of file for legal stuff.
10 #=======================================================================
17 our (@ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
20 @EXPORT = qw(&list_nearest_waypoints &ddd_to_dms);
25 sub list_nearest_waypoints
{
27 my ($Lat, $Lon, $Count) = @_;
30 my $waypoint_file = "/home/sunny/gps/waypoints.gpx";
32 # FIXME: Incredible unfinished and kludgy.
33 if (open(WaypFP
, "$main::Cmd{'gpsbabel'} -i gpx -f $waypoint_file " .
34 "-x radius,lat=$Lat,lon=$Lon,distance=1000 " .
37 my $Str = join("", <WaypFP
>);
39 ^.*?
<wpt\s
.*?
>.*?
<name
>(.+?
)</name>.*?</wpt
>.*?
40 .*?
<wpt\s
.*?
>.*?
<name
>(.+?
)</name>.*?</wpt
>.*?
41 .*?
<wpt\s
.*?
>.*?
<name
>(.+?
)</name>.*?</wpt
>.*$
47 die("$main::progname: Cannot open $main::Cmd{'gpsbabel'} pipe: $!\n");
53 # Convert floating-point degrees into D°M'S.S" (ISO-8859-1).
54 # Necessary for import into GPSman. Based on toDMS() from
55 # gpstrans-0.39 to ensure compatibility.
59 my ($Hour, $Min, $Sec) =
63 ($ddd =~ /^\-?(\d*)(\.\d+)?$/) || return(undef);
64 length($ddd) || ($ddd = 0);
71 $ddd = ($ddd - $Hour) * 60.0;
73 $Sec = ($ddd - $Min) * 60.0;
83 $Retval = sprintf("%s%.0f\xB0%02.0f'%04.1f\"",