#!/usr/bin/env perl use strict; use warnings; use Geo::Ellipsoid; print "\nUsing Geo::Ellipsoid\n"; my $gel = Geo::Ellipsoid->new( ellipsoid => 'WGS84', units => 'degrees', distance_units => 'meter', longitude => 0, bearing => 0, ); my @curlatlon1 = (37.889086, 41.129166); my @curlatlon2 = (39.668930, 66.993292); # displacement from 1 to 2 my ($x,$y) = $gel->displacement(@curlatlon1, @curlatlon2); print "displacement from @curlatlon1 to @curlatlon2 = ($x,$y)\n"; my @newlatlon = $gel->location(@curlatlon1, $x, $y); print "moving from @curlatlon1 by ($x,$y) gets me to @newlatlon (corre +ct is @curlatlon2)\n"; print "dist: ".sqrt($x*$x+$y*$y) .", bearing: ".180*atan2($y,$x)/3.14." degrees\n"; # from 2 to 1 ($x,$y) = $gel->displacement(@curlatlon2, @curlatlon1); print "displacement from @curlatlon2 to @curlatlon1 = ($x,$y)\n"; @newlatlon = $gel->location(@curlatlon2, $x, $y); print "moving from @curlatlon2 by ($x,$y) gets me to @newlatlon (corre +ct is @curlatlon1)\n"; print "dist: ".sqrt($x*$x+$y*$y) .", bearing: ".180*atan2($y,$x)/3.14." degrees\n"; use Geo::Calc; print "\nUsing Geo::Calc\n"; my $cur1 = Geo::Calc->new(lat=>$curlatlon1[0], lon=>$curlatlon1[1]); my $bear = $cur1->bearing_to({lat=>$curlatlon2[0], lon=>$curlatlon2[1] +}); my $dist = $cur1->distance_to({lat=>$curlatlon2[0], lon=>$curlatlon2[1 +]}); my $newlatlon = $cur1->destination_point($bear, $dist); print "from (" .$cur1->get_lat().",".$cur1->get_lon() .") moving by $dist m and $bear degrees got me to (" .$newlatlon->{'lat'}.",".$newlatlon->{'lon'} .")\n";

In reply to Re: Determine lat/lon of geo location at given distance from other location by bliako
in thread Determine lat/lon of geo location at given distance from other location by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.