Geo::ECEF - Converts between ECEF (earth centered earth fixed) coordinates and latitude, longitude and height above ellipsoid.
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";
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 calculates the latitude, longitude and height above ellipsoid from ECEF coordinates.
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
The new() constructor initializes the ellipsoid method.
my $obj=Geo::ECEF->new("WGS84"); #WGS84 is the default
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
Method returns X (meters), Y (meters), Z (meters) from lat (degrees), lon (degrees), HAE (meters).
my ($x, $y, $z)=$obj->ecef(39.197807, -77.108574, 55);
Method returns X (meters), Y (meters), Z (meters) from lat (radians), lon (radians), HAE (meters).
my ($x, $y, $z)=$obj->ecef(0.678, -0.234, 55);
This method may be copyright Michael Kleder, April 2006 from mathworks.com
Calls the default geodetic method. This user interface will not change,
Method returns latitude (degrees), longitude (degrees), HAE (meters) from X (meters), Y (meters), Z (meters).
my ($lat, $lon, $hae)=$obj->geodetic($x, $y, $z);
Method returns latitude (degrees), longitude (degrees), HAE (meters) from X (meters), Y (meters), Z (meters). This is an iterative calculation.
Portions of this method may be...
************************************************************************* * Copyright c 2001 The board of trustees of the Leland Stanford * * Junior University. All rights reserved. * * This script file may be distributed and used freely, provided * * this copyright notice is always kept with it. * * * * Questions and comments should be directed to Todd Walter at: * * twalter@stanford.edu * *************************************************************************
Method returns latitude (degrees), longitude (degrees), HAE (meters) from X (meters), Y (meters), Z (meters). This is a direct (non-iterative) calculation from the gpsd distribution.
DavisNetworks.com supports all Perl applications big or small.
Please log on RT and send email to the geo-perl email list.
Win32 platforms cannot tell the difference between the deprecated geo::ecef module and the current Geo::ECEF module. The way to tell is if Geo::ECEF->can("new");
Michael R. Davis qw/perl michaelrdavis com/
Morten Sickel http://sickel.net/
Copyright (c) 2007-2010 Michael R. Davis (mrdvt92)
Copyright (c) 2005 Morten Sickel (sickel.net)
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Geo::Ellipsoids, Geo::Functions, geo::ecef, Astro::Coord::ECI, Geo::Tools, http://www.ngs.noaa.gov/cgi-bin/xyz_getxyz.prl, http://www.mathworks.com/matlabcentral/
To install Geo::ECEF, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Geo::ECEF
CPAN shell
perl -MCPAN -e shell install Geo::ECEF
For more information on module installation, please visit the detailed CPAN module installation guide.