pjacklam / p5-geo-ellipsoid Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
Hi,
The internal Fortran derived code has reverse bearing available, but it is commented out and not returned by the internal _forward and public "at" function. The reverse bearing is same as bearing available from "to" function for distances less than about 20 000 km (antipode), but becomes impossible to calculate for longer distances without return of the $baz variable from the _forward function.
Here is proposed patch, which adds "atb" function and reroutes existing "at" function to internally call "atb". "at" functionality is preserved and new "atb" can be called directly to get correct reverse bearing beyond antipode distance. I hope I did not break anything.
Regards,
Sami
--- Ellipsoid.pm.orig Tue Jan 19 15:33:31 2021
+++ Ellipsoid.pm Thu Jan 28 00:14:49 2021
@@ -775,15 +775,36 @@
sub at
{
my $self = shift;
+ my( $lat, $lon, $r, $az ) = @_;
+ print "at($lat,$lon,$r,$az)\n" if $DEBUG;
+ my( $lat2, $lon2, $baz ) = $self->atb($lat,$lon,$r,$az);
+ print "atb returns ($lat2,$lon2,$baz)\n" if $DEBUG;
+ return ( $lat2, $lon2 );
+}
+
+=pod
+
+=item atb
+
+Returns the list (latitude,longitude,reverse_bearing) in degrees or radians that is a
+specified range and bearing from a given location.
+
+ my( $lat2, $lon2, $baz ) = $geo->atb( $lat1, $lon1, $range, $bearing );
+
+=cut
+
+sub atb
+{
+ my $self = shift;
my $units = $self->{angle_unit};
my( $lat, $lon, $az ) = _normalize_input($units,@_[0,1,3]);
my $r = $_[2];
- print "at($lat,$lon,$r,$az)\n" if $DEBUG;
- my( $lat2, $lon2 ) = $self->_forward($lat,$lon,$r,$az);
- print "_forward returns ($lat2,$lon2)\n" if $DEBUG;
+ print "atb($lat,$lon,$r,$az)\n" if $DEBUG;
+ my( $lat2, $lon2, $baz ) = $self->_forward($lat,$lon,$r,$az);
+ print "_forward returns ($lat2,$lon2,$baz)\n" if $DEBUG;
$self->_normalize_output('longitude_symmetric',$lon2);
$self->_normalize_output('latitude_symmetric',$lat2);
- return ( $lat2, $lon2 );
+ return ( $lat2, $lon2, $baz );
}
=pod
@@ -1052,10 +1073,10 @@
$c = (((((-3.0*$c2a)+4.0)*$f)+4.0)*$c2a*$f)/16.0;
$d = (((($e*$cy*$c) + $cz)*$sy*$c)+$y)*$sa;
my $lon2 = $lon1 + $x - (1.0-$c)*$d*$f;
- #$baz = atan2($sa,$baz) + pi;
+ $baz = atan2($sa,$baz) + pi;
# return result
- return ($lat2,$lon2);
+ return ($lat2,$lon2,$baz);
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.