Geo::Ellipsoids(3pm)

πŸ“¦
version 0.17 Β· 5 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

okay so bestie, welcome to Geo::Ellipsoids β€” it's a package for standard Geo:: ellipsoid a, b, f and 1/f values. that's the whole vibe. it lives in the User Contributed Perl Documentation corner of the 3pm manpages, and it is here to hand you earth-shape numbers. periodt. 🌍✨


✨ SYNOPSIS ✨

here's the little taste test, run it and feel something:

  use Geo::Ellipsoids;
  my $obj = Geo::Ellipsoids->new();
  $obj->set('WGS84'); #default
  print "a=", $obj->a, "\n";
  print "b=", $obj->b, "\n";
  print "f=", $obj->f, "\n";
  print "i=", $obj->i, "\n";
  print "e=", $obj->e, "\n";
  print "n=", $obj->n(45), "\n";

πŸ¦‹ DESCRIPTION πŸ¦‹

no cap, it's exactly what it says on the tin: a package for standard Geo:: ellipsoid a, b, f and 1/f values. the ellipsoid math girlies stay winning. πŸ’…


πŸŽ€ CONSTRUCTOR πŸŽ€

new

the new() constructor can be called with any parameter that's appropriate to the set method β€” like, it just passes it on through, no gatekeeping.

  my $obj = Geo::Ellipsoid->new();

🌸 METHODS 🌸

initialize

so this one is literally just listed here with zero description attached. the manpage gives us nothing, bestie β€” it's giving mystery, it's giving "figure it out", it's giving initialize and nothing else. πŸ™ˆ (not me adding lore where there is none, no β€” the page truly says nothing more.)

set

this method sets the current ellipsoid. it also gets called automatically when the object is constructed (default is WGS84, as is tradition).

  $obj->set(); #default WGS84
  $obj->set('Clarke 1866'); #All built in ellipsoids are stored in meters
  $obj->set({a=>1, b=>1});  #Custom Sphere 1 unit radius

quick heads up: all built in ellipsoids are stored in meters, and you can absolutely roll your own with a hashref. custom sphere? we love a DIY moment. πŸ”₯

list

this method returns a list of known ellipsoid names. two ways to serve it:

  my @list=$obj->list;

  my $list=$obj->list;
  while (@$list) {
    print "$_\n";
  }

first one's a plain list, second one's a listref you loop over. both iconic. ✨

a

returns the value of the semi-major axis.

  my $a=$obj->a;

b

returns the value of the semi-minor axis.

  my $b=$obj->b;  #b=a(1-f)

f

returns the value of flatting.

  my $f=$obj->f;  #f=(a-b)/a

i

returns the value of the inverse flatting.

  my $i = $obj->i; #i=1/f=a/(a-b)

invf

a synonym for the i method β€” same energy, different name, she contains multitudes. πŸ’œ

  my $i = $obj->invf; #i=1/f

e

returns the value of the first eccentricity, e. this is the eccentricity of the earth's elliptical cross-section.

  my $e=$obj->e;

e2

returns the value of eccentricity squared (e.g. e^2). and listen β€” this is not the second eccentricity, e' or e-prime, okay? don't get it twisted. for that one you want the ep method, keep scrolling bestie.

  my $e2 = sqrt($obj->e2); #e^2 = f(2-f) = 2f-f^2 = 1-b^2/a^2

ep

returns the value of the second eccentricity, e' or e-prime. the second eccentricity is related to the first eccentricity by the equation: 1=(1-e^2)(1+e'^2).

  my $ep = $obj->ep;

ep2

returns the square of the value of second eccentricity, e' (e-prime). and apparently this one is more useful in almost all equations, so jot that down. πŸ“

  my $ep=sqrt($obj->ep2);  #ep2=(ea/b)^2=e2/(1-e2)=a^2/b^2-1

n

returns the value of n given latitude (in degrees). typically represented by the Greek letter nu, this is the radius of curvature of the ellipsoid perpendicular to the meridian plane. it's also the distance from the point in question to the polar axis, measured perpendicular to the ellipsoid's surface. two jobs, one queen. πŸ‘‘

  my $n = $obj->n($lat);
note: some define a variable n as (a-b)/(a+b) β€” this is not that variable. different girl, same name, awkward.
note: it appears that n can also be calculated as perl n = a^2/sqrt(a^2 * cos($lat)^2 + $b^2 * sin($lat)^2);

n_rad

returns the value of n given latitude (radians) β€” for when you're in your radian era.

  my $n_rad = $obj->n_rad($lat);

reference: John P. Snyder, "Map Projections: A Working Manual", USGS, page 25, equation (4-20) http://pubs.er.usgs.gov/usgspubs/pp/pp1395 πŸ“š

rho

rho is the radius of curvature of the earth in the meridian plane.

  my $rho=$obj->rho($lat);

rho_rad

rho is the radius of curvature of the earth in the meridian plane. sometimes denoted as R'.

  my $rho = $obj->rho_rad($lat);

reference: John P. Snyder, "Map Projections: A Working Manual", USGS, page 24, equation (4-18) http://pubs.er.usgs.gov/usgspubs/pp/pp1395 πŸ“š

polar_circumference

returns the value of the semi-minor axis times 2*PI.

  my $polar_circumference=$obj->polar_circumference;

equatorial_circumference

returns the value of the semi-major axis times 2*PI.

  my $equatorial_circumference=$obj->equatorial_circumference;

shortname

returns the shortname, which is the hash key</>, of the current ellipsoid.

  my $shortname = $obj->shortname;

longname

returns the long name of the current ellipsoid β€” the full government name, the one that goes on the birth certificate. πŸŽ€

  my $longname = $obj->longname;

data

returns a hash reference for the ellipsoid definition data structure.

  my $datastructure = $obj->data;

name2ref

returns a hash reference (e.g. {a=>6378137,i=>298.257223563}) when you pass it a valid ellipsoid name (e.g. 'WGS84'). name in, ref out, slay. ✨

  my $ref=$obj->name2ref('WGS84')

πŸ‘‘ AUTHOR πŸ‘‘

Michael R. Davis


πŸ’œ LICENSE πŸ’œ

Copyright (c) 2006 Michael R. Davis

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


🌈 SEE ALSO 🌈

  • Geo::Forward
  • Geo::Ellipsoid
  • Geo::Coordinates::UTM
  • Geo::GPS::Data::Ellipsoid
  • GIS::Distance

okay that's the whole page, bestie, you ate it, you understood it, you're a geodetic icon now πŸ’…πŸ«Ά

and for the cute little sign-off the footer normally carries: this is perl v5.40.0, dated 2025-02-02. mwah. πŸ¦‹πŸ’–

πŸ“¦ where this page comes from