Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: How do I compute the longitude and latitude of a point at a certain distance?

by I0 (Priest)
on Apr 22, 2003 at 08:37 UTC ( #252219=note: print w/ replies, xml ) Need Help??


in reply to How do I compute the longitude and latitude of a point at a certain distance?

($latitude,$longitude)=ll( MILES=>5, LATITUDE=>51+29/60, LONGITUDE=>0+0/60, DIRECTION=>315, ); if( $latitude < 0 ){ $latitude *= -1; $ns='S'; }else{ $ns='N'; } if( $longitude < 0 ){ $longitude *= -1; $ew='W'; }else{ $ew='E'; } print int $latitude,"",60*($latitude-int $latitude),"' $ns\n", int $longitude,"",60*($longitude-int $longitude),"' $ew\n"; use Math::Trig; sub ll{ my %l=@_; use constant PI=>4*atan2(1,1); my $nm = $l{MILES}*.87; my $A=$l{DIRECTION}*PI/180; my $b=(90-$l{LATITUDE})*PI/180; my $c=$nm/60/180*PI; my $a=acos(cos($b)*cos($c)+sin($b)*sin($c)*cos($A)); my $latitude=90-180/PI*$a; my $C=asin(sin($c)*sin($A)/sin($a)); my $longitude=$l{LONGITUDE}+180/PI*$C; return $latitude,$longitude; }


Comment on Re: How do I compute the longitude and latitude of a point at a certain distance?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (16)
As of 2014-07-24 16:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (162 votes), past polls