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 ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
20 push(@main::version_array
, $rcs_id);
21 $VERSION = ($rcs_id =~ / (\d+) /, $1);
24 @EXPORT = qw(&list_nearest_waypoints &ddd_to_dms);
29 sub list_nearest_waypoints
{
31 my ($Lat, $Lon, $Count) = @_;
34 my $waypoint_file = "/home/sunny/gps/waypoints.gpx";
36 # FIXME: Incredible unfinished and kludgy.
37 if (open(WaypFP
, "$main::Cmd{'gpsbabel'} -i gpx -f $waypoint_file " .
38 "-x radius,lat=$Lat,lon=$Lon,distance=1000 " .
41 my $Str = join("", <WaypFP
>);
43 ^.*?
<wpt\s
.*?
>.*?
<name
>(.+?
)</name>.*?</wpt
>.*?
44 .*?
<wpt\s
.*?
>.*?
<name
>(.+?
)</name>.*?</wpt
>.*?
45 .*?
<wpt\s
.*?
>.*?
<name
>(.+?
)</name>.*?</wpt
>.*$
51 die("$main::progname: Cannot open $main::Cmd{'gpsbabel'} pipe: $!\n");
57 # Convert floating-point degrees into D°M'S.S" (ISO-8859-1).
58 # Necessary for import into GPSman. Based on toDMS() from
59 # gpstrans-0.39 to ensure compatibility.
63 my ($Hour, $Min, $Sec) =
67 ($ddd =~ /^\-?(\d*)(\.\d+)?$/) || return(undef);
68 length($ddd) || ($ddd = 0);
75 $ddd = ($ddd - $Hour) * 60.0;
77 $Sec = ($ddd - $Min) * 60.0;
87 $Retval = sprintf("%s%.0f\xB0%02.0f'%04.1f\"",