Geo-ECEF
view release on metacpan or search on metacpan
lib/Geo/ECEF.pm view on Meta::CPAN
package Geo::ECEF;
use strict;
use warnings;
use Geo::Ellipsoids;
use Geo::Functions qw{rad_deg deg_rad};
our $VERSION="1.10";
=head1 NAME
Geo::ECEF - Converts between ECEF (earth centered earth fixed) coordinates and latitude, longitude and height above ellipsoid.
=head1 SYNOPSIS
use Geo::ECEF;
my $obj=Geo::ECEF->new(); #WGS84 is the default
my ($x, $y, $z)=$obj->ecef(39.197807, -77.108574, 55); #Lat (deg), Lon (deg), HAE (meters)
print "X: $x\tY: $y\tZ: $z\n";
my ($lat, $lon, $hae)=$obj->geodetic($x, $y, $z); #X (meters), Y (meters), Z (meters)
print "Lat: $lat \tLon: $lon \tHAE $hae\n";
=head1 DESCRIPTION
Geo::ECEF provides two methods ecef and geodetic. The ecef method calculates the X,Y and Z coordinates in the ECEF (earth centered earth fixed) coordinate system from latitude, longitude and height above the ellipsoid. The geodetic method calculate...
The formulas were found at http://www.u-blox.ch/ and http://waas.stanford.edu/~wwu/maast/maastWWW1_0.zip.
This code is an object Perl rewrite of a similar package by Morten Sickel, Norwegian Radiation Protection Authority
=head1 CONSTRUCTOR
=head2 new
The new() constructor initializes the ellipsoid method.
my $obj=Geo::ECEF->new("WGS84"); #WGS84 is the default
=cut
sub new {
my $this = shift();
my $class = ref($this) || $this;
my $self = {};
bless $self, $class;
$self->initialize(@_);
return $self;
}
=head1 METHODS
=head2 initialize
=cut
sub initialize {
my $self = shift();
my $param = shift()||undef();
$self->ellipsoid($param);
}
=head2 ellipsoid
Method to set or retrieve the current ellipsoid object. The ellipsoid is a Geo::Ellipsoids object.
my $ellipsoid=$obj->ellipsoid; #Default is WGS84
$obj->ellipsoid('Clarke 1866'); #Built in ellipsoids from Geo::Ellipsoids
$obj->ellipsoid({a=>1}); #Custom Sphere 1 unit radius
=cut
sub ellipsoid {
my $self = shift();
if (@_) {
my $param=shift();
use Geo::Ellipsoids;
my $obj=Geo::Ellipsoids->new($param);
$self->{'ellipsoid'}=$obj;
}
return $self->{'ellipsoid'};
}
=head2 ecef
Method returns X (meters), Y (meters), Z (meters) from lat (degrees), lon (degrees), HAE (meters).
( run in 0.834 second using v1.01-cache-2.11-cpan-99c4e6809bf )