Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Put yourself on the Monk Map

by Rudif (Hermit)
on Jan 12, 2001 at 02:29 UTC ( [id://51237]=note: print w/replies, xml ) Need Help??


in reply to Put yourself on the Monk Map

Put yourself on the Monk Map made even easier ;-)
#! perl -w use strict; my $usage = <<__EOT__; Usage: $0 [<latitude> <longitude>] [-test] Converts latitude and longitude (in degrees) to format suitable for Mo +nkMap. -test runs selftest __EOT__ my ($lat, $lon, $test) = (0, 0, 0); if (@ARGV == 2) { ($lat, $lon) = @ARGV; } elsif (@ARGV == 1 && $ARGV[0] eq '-test') { $test = 1; } else { die $usage; } if ($test) { selftest(); } else { printf "%s\n", ll2monkmap ($lat, $lon); } exit; sub ll2monkmap { my ($lat, $lon) = @_; sprintf "%12.5f%12.5f <!-- Location:latitude=%s,longitude=%s-->" +, $lat, $lon, dec2degminsec($lat), dec2degminsec($lon); } sub dec2degminsec { my $dec = shift; while ($dec < -180) { $dec += 360; } while ($dec > 180) { $dec -= 360; } my $neg = $dec < 0; $dec = - $dec if $neg; my $deg = int $dec; $dec -= $deg; $dec *= 60; my $min = int $dec; $dec -= $min; $dec *= 60; my $sec = int $dec; sprintf "%s%03d.%02d.%02d", $neg ? "-" : "", $deg, $min, $sec; } sub selftest { my @angles = ( -360, -270, -180, -90, 0, 90, 180, 270, 360 ); my @deltas = ( -0.445, 0, 0.555 ); for my $d (@deltas) { for my $a (@angles) { my $x = $a+$d; my $str = dec2degminsec($x); my $strll = ll2monkmap($x, $x); print "$strll\n"; } } } __END__ Author: rudif@bluemail.ch rudif@lecroy.com 46.20832 6.14296 <!-- Location:latitude=046.12.29,longitude= +006.08.34-->

HTH
Rudif

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://51237]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2025-03-26 17:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (68 votes). Check out past polls.

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.