Geo-Ellipsoids-0.16/0000755000076400007640000000000011015112606013610 5ustar mdavismdavisGeo-Ellipsoids-0.16/README0000644000076400007640000000014710531743212014477 0ustar mdavismdavisIf you have any comments I'd love to hear from you. Thanks, Mike (mrdvt92) qw/perl michaelrdavis com/ Geo-Ellipsoids-0.16/bin/0000755000076400007640000000000011015112606014360 5ustar mdavismdavisGeo-Ellipsoids-0.16/bin/example-simple.pl0000644000076400007640000000126710552607410017654 0ustar mdavismdavis#!/usr/bin/perl -w =head1 NAME example-simple.pl - Geo::Ellipsoids simple example =cut use strict; use lib qw{./lib ../lib}; use Geo::Ellipsoids; my $obj=Geo::Ellipsoids->new(); #defaults to WGS84 print "Short Name: ", $obj->shortname, "\n"; print "Long Name: ", $obj->longname, "\n"; print "Ellipsoid: ", "{a=>",$obj->a,",i=>",$obj->i,"}", "\n"; print "\n"; print "a=", $obj->a, "\n"; print "b=", $obj->b, "\n"; print "f=", $obj->f, "\n"; print "i=", $obj->i, "\n"; __END__ =head1 SAMPLE OUTPUT Short Name: WGS84 Long Name: World Geodetic System of 1984 Ellipsoid: {a=>6378137,i=>298.257223563} a=6378137 b=6356752.31424518 f=0.00335281066474748 i=298.257223563 =cut Geo-Ellipsoids-0.16/bin/example-list.pl0000644000076400007640000000661210552255702017340 0ustar mdavismdavis#!/usr/bin/perl -w =head1 NAME example-list.pl - Geo::Ellipsoids list method example =cut use strict; use lib qw{./lib ../lib}; use Geo::Ellipsoids; my $obj=Geo::Ellipsoids->new(); #defaults to WGS84 my $list=$obj->list; foreach (sort @$list) { $obj->set($_); print "Short Name: ", $obj->shortname, "\n"; print "Long Name: ", $obj->longname, "\n"; print "Ellipsoid: ", "{a=>",$obj->a,",b=>",$obj->b,"}", "\n"; print "\n"; } foreach (100,110,120,130) { $obj->set({a=>1,i=>$_}); print "Short Name: ", $obj->shortname, "\n"; print "Long Name: ", $obj->longname, "\n"; print "Ellipsoid: ", "{a=>",$obj->a,",b=>",$obj->b,"}", "\n"; print "\n"; } __END__ =head1 Sample Output Short Name: Airy 1858 Long Name: Airy 1858 Ellipsoid Ellipsoid: {a=>6377563.396,b=>6356256.90923729} Short Name: Airy Modified Long Name: Modified Airy Spheroid Ellipsoid: {a=>6377340.189,b=>6356034.448} Short Name: Australian National Long Name: Australian National Spheroid Ellipsoid: {a=>6378160,b=>6356774.71919531} Short Name: Bessel 1841 Long Name: Bessel 1841 Ellipsoid Ellipsoid: {a=>6377397.155,b=>6356078.96281819} Short Name: Clarke 1866 Long Name: Clarke Ellipsoid of 1866 Ellipsoid: {a=>6378206.4,b=>6356583.79999999} Short Name: Clarke 1880 Long Name: Clarke Ellipsoid of 1880 Ellipsoid: {a=>6378249.145,b=>6356514.966} Short Name: Everest 1830 Long Name: Everest Spheroid of 1830 Ellipsoid: {a=>6377276.345,b=>6356075.41314024} Short Name: Everest Modified Long Name: Modified Everest Spheroid Ellipsoid: {a=>6377304.063,b=>6356103.03899315} Short Name: Fisher 1960 Long Name: Fisher 1960 Ellipsoid: {a=>6378166,b=>6356784.28360711} Short Name: Fisher 1968 Long Name: Fisher 1968 Ellipsoid: {a=>6378150,b=>6356768.33724438} Short Name: GRS80 Long Name: Geodetic Reference System of 1980 Ellipsoid: {a=>6378137,b=>6356752.31414035} Short Name: Hough 1956 Long Name: Hough 1956 Ellipsoid: {a=>6378270,b=>6356794.34343434} Short Name: International (Hayford) Long Name: International (Hayford) Ellipsoid: {a=>6378388,b=>6356911.94612795} Short Name: Krassovsky 1938 Long Name: Krassovsky 1938 Ellipsoid: {a=>6378245,b=>6356863.01877305} Short Name: NWL-9D Long Name: NWL-9D Ellipsoid Ellipsoid: {a=>6378145,b=>6356759.76948868} Short Name: SA69 Long Name: South American 1969 Ellipsoid: {a=>6378160,b=>6356774.71919531} Short Name: SGS85 Long Name: Soviet Geodetic System 1985 Ellipsoid: {a=>6378136,b=>6356751.30156878} Short Name: UTM Long Name: Department of the Army Universal Transverse Mercator Ellipsoid: {a=>6378249.2,b=>6356515} Short Name: WGS72 Long Name: World Geodetic System 1972 Ellipsoid: {a=>6378135,b=>6356750.52001609} Short Name: WGS84 Long Name: World Geodetic System of 1984 Ellipsoid: {a=>6378137,b=>6356752.31424518} Short Name: WOS Long Name: War Office Spheroid Ellipsoid: {a=>6378300.58,b=>6356752.26722973} Short Name: Custom Long Name: Custom Ellipsoid {a=>1,i=>100} Ellipsoid: {a=>1,b=>0.99} Short Name: Custom Long Name: Custom Ellipsoid {a=>1,i=>110} Ellipsoid: {a=>1,b=>0.990909090909091} Short Name: Custom Long Name: Custom Ellipsoid {a=>1,i=>120} Ellipsoid: {a=>1,b=>0.991666666666667} Short Name: Custom Long Name: Custom Ellipsoid {a=>1,i=>130} Ellipsoid: {a=>1,b=>0.992307692307692} =cut Geo-Ellipsoids-0.16/MANIFEST0000644000076400007640000000022310546047732014755 0ustar mdavismdavisbin/example-list.pl bin/example-simple.pl CHANGES lib/Geo/Ellipsoids.pm LICENSE Makefile.PL MANIFEST This list of files META.yml README t/base.t Geo-Ellipsoids-0.16/Makefile.PL0000644000076400007640000000100710536416150015570 0ustar mdavismdavisuse ExtUtils::MakeMaker; WriteMakefile( NAME => q{Geo::Ellipsoids}, VERSION_FROM => q{lib/Geo/Ellipsoids.pm}, PREREQ_PM => { strict => 0, vars => 0, constant => 0, Geo::Functions => 0.03, Geo::Constants => 0.04, }, ($] >= 5.005 ? ( ABSTRACT_FROM => 'lib/Geo/Ellipsoids.pm', ) : () ), ); Geo-Ellipsoids-0.16/lib/0000755000076400007640000000000011015112606014356 5ustar mdavismdavisGeo-Ellipsoids-0.16/lib/Geo/0000755000076400007640000000000011015112606015070 5ustar mdavismdavisGeo-Ellipsoids-0.16/lib/Geo/Ellipsoids.pm0000644000076400007640000003616611015112425017550 0ustar mdavismdavispackage Geo::Ellipsoids; =head1 NAME Geo::Ellipsoids - Package for standard Geo:: ellipsoid a, b, f and 1/f values. =head1 SYNOPSIS 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"; =head1 DESCRIPTION =cut use strict; use vars qw($VERSION); use constant DEFAULT_ELIPS => 'WGS84'; use Geo::Constants qw{PI}; use Geo::Functions qw{rad_deg}; $VERSION = sprintf("%d.%02d", q{Revision: 0.16} =~ /(\d+)\.(\d+)/); =head1 CONSTRUCTOR =head2 new The new() constructor may be called with any parameter that is appropriate to the set method. my $obj = Geo::Ellipsoid->new(); =cut sub new { my $this = shift(); my $class = ref($this) || $this; my $self = {}; bless $self, $class; $self->initialize(@_); return $self; } =head1 METHODS =cut sub initialize { my $self = shift(); my $param = shift(); $self->set($param); } =head2 set Method sets the current ellipsoid. This method is called when the object is constructed (default is WGS84). $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 =cut sub set { my $self=shift(); my $param=shift()||DEFAULT_ELIPS; undef($self->{'shortname'}); undef($self->{'longname'}); if ("HASH" eq ref($param)) { return $self->_setref($param); } elsif ('' eq ref($param)) { return $self->_setname($param); } else { die("Error: Parameter must be the name of an ellipsoid or a hash reference"); } } =head2 list Method returns a list of known elipsoid names. my @list=$obj->list; my $list=$obj->list; while (@$list) { print "$_\n"; } =cut sub list { my $self=shift(); my $data=$self->data; my @keys=keys %$data; return wantarray ? @keys : \@keys; } =head2 a Method returns the value of the semi-major axis. my $a=$obj->a; =cut sub a { my $self=shift(); return $self->{'a'} || die('Error: $self->{"a"} must be defined here'); } =head2 b Method returns the value of the semi-minor axis. my $b=$obj->b; #b=a(1-f) =cut sub b { my $self=shift(); if (defined $self->{'b'}) { return $self->{'b'}; } elsif (defined $self->{'f'}) { return $self->{'a'}*(1-$self->{'f'}); } elsif (defined $self->{'i'}) { return $self->{'a'}*(1-1/$self->{'i'}); } else { return undef(); } } =head2 f Method returns the value of flatting my $f=$obj->f; #f=(a-b)/a =cut sub f { my $self=shift(); if (defined $self->{'f'}) { return $self->{'f'}; } elsif (defined $self->{'b'}) { return ($self->{'a'}-$self->{'b'})/$self->{'a'}; } elsif (defined $self->{'i'}) { return 1/$self->{'i'}; } else { return undef(); } } =head2 i Method returns the value of the inverse flatting my $i=$obj->i; #i=1/f=a/(a-b) =cut sub i { my $self=shift(); if (defined $self->{'i'}) { return $self->{'i'}; } elsif (defined $self->{'b'}) { if ($self->{'a'} == $self->{'b'}) { return undef(); } else { return $self->{'a'}/($self->{'a'}-$self->{'b'}); } } elsif (defined $self->{'f'}) { return 1/$self->{'f'}; } else { return undef(); } } =head2 invf Method synonym for the i method my $i=$obj->invf; #i=1/f =cut sub invf { my $self = shift(); return $self->i(@_); } =head2 e Method returns the value of the first eccentricity, e. This is the eccentricity of the earth's elliptical cross-section. my $e=$obj->e; =cut sub e { my $self=shift(); return sqrt($self->e2); } =head2 e2 Method returns the value of eccentricity squared (e.g. e^2). This is not the second eccentricity, e' or e-prime see the "ep" method. my $e=sqrt($obj->e2); #e^2 = f(2-f) = 2f-f^2 = 1-b^2/a^2 =cut sub e2 { my $self=shift(); my $f=$self->f(); return $f*(2 - $f); } =head2 ep Method 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; =cut sub ep { my $self=shift(); return sqrt($self->ep2); } =head2 ep2 Method returns the square of value of second eccentricity, e' (e-prime). This is more useful in almost all equations. my $ep=sqrt($obj->ep2); #ep2=(ea/b)^2=e2/(1-e2)=a^2/b^2-1 =cut sub ep2 { my $self=shift(); my $a=$self->a(); my $b=$self->b(); return $a**2/$b**2 - 1; } =head2 n Method returns the value of n given latitude (degrees). Typically represented by the Greek letter nu, this is the radius of curvature of the ellipsoid perpendicular to the meridian plane. It is also the distance from the point in question to the polar axis, measured perpendicular to the ellipsoid's surface. my $n=$obj->n($lat); Note: Some define a variable n as (a-b)/(a+b) this is not that variable. Note: It appears that n can also be calculated as n=a^2/sqrt(a^2 * cos($lat)^2 + $b^2 * sin($lat)^2); =cut sub n { my $self=shift(); my $lat=shift(); #degrees die("Error: Latitude (degrees) required.") unless defined $lat; return $self->n_rad(rad_deg($lat)); } =head2 n_rad Method returns the value of n given latitude (radians). my $n=$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 =cut sub n_rad { my $self=shift(); my $lat=shift(); #radians die("Error: Latitude (radians) required.") unless defined $lat; my $a=$self->a; my $e2=$self->e2; return $a / sqrt(1 - $e2 * sin($lat)**2); } =head2 rho rho is the radius of curvature of the earth in the meridian plane. my $rho=$obj->rho($lat); =cut sub rho { my $self=shift(); my $lat=shift(); #degrees die("Error: Latitude (degrees) required.") unless defined $lat; return $self->rho_rad(rad_deg($lat)); } =head2 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 =cut sub rho_rad { my $self=shift(); my $lat=shift(); #radians die("Error: Latitude (radians) required.") unless defined $lat; my $a=$self->a; my $e2=$self->e2; return $a * (1-$e2) / ( 1 - $e2 * sin($lat)**2 )**(3/2) #return $a * (1-$e2) / sqrt(1 - $e2 * sin($lat)**(3/2)); #Bad formula from somewhere } =head2 polar_circumference Method returns the value of the semi-minor axis times 2*PI. my $polar_circumference=$obj->polar_circumference; =cut sub polar_circumference { my $self=shift(); return 2 * PI() * $self->b(); } =head2 equatorial_circumference Method returns the value of the semi-major axis times 2*PI. my $equatorial_circumference=$obj->equatorial_circumference; =cut sub equatorial_circumference { my $self=shift(); return 2 * PI() * $self->a(); } sub _setref { my $self=shift(); my $param=shift(); if ('HASH' eq ref($param)) { if (defined($param->{'a'})) { $self->{'a'}=$param->{'a'}; $self->{'shortname'}='Custom' unless defined($self->shortname); if (defined $param->{'i'}) { $self->{'i'}=$param->{'i'}; undef($self->{'b'}); undef($self->{'f'}); $self->{'longname'}='Custom Ellipsoid {a=>'.$self->a.',i=>'.$self->i.'}' unless defined($self->longname); } elsif (defined $param->{'b'}){ $self->{'b'}=$param->{'b'}; undef($self->{'i'}); undef($self->{'f'}); $self->{'longname'}='Custom Ellipsoid {a=>'.$self->a.',b=>'.$self->b.'}' unless defined($self->longname); } elsif (defined $param->{'f'}){ $self->{'f'}=$param->{'f'}; undef($self->{'b'}); undef($self->{'i'}); $self->{'longname'}='Custom Ellipsoid {a=>'.$self->a.',f=>'.$self->f.'}' unless defined($self->longname); } else { $self->{'b'}=$param->{'a'}; undef($self->{'f'}); undef($self->{'i'}); $self->{'longname'}='Custom Sphere {a=>'.$self->a.'}' unless defined($self->longname); } } else { die("Error: a must be defined"); } } else { die('Error: a hash reference e.g. {a=>###, i=>###} must be define'); } return 1; } sub _setname { my $self=shift(); my $param=shift(); my $ref=$self->name2ref($param); if ("HASH" eq ref($ref)) { $self->{'shortname'}=$param; my $data=$self->data; my %data=map {$_, $data->{$_}->{'name'}} (keys %$data); $self->{'longname'} = $data{$param}; return $self->_setref($ref); } else { die("Error: Ellipsoid $param was not found"); } } =head2 shortname Method returns the shortname, which is the hash key, of the current ellipsoid my $shortname=$obj->shortname; =cut sub shortname { my $self = shift(); return $self->{'shortname'}; } =head2 longname Method returns the long name of the current ellipsoid my $longname=$obj->longname; =cut sub longname { my $self = shift(); return $self->{'longname'}; } =head2 data Method returns a hash reference for the ellipsoid definition data structure. my $datastructure=$obj->data; =cut sub data { #Information from # http://earth-info.nga.mil/GandG/coordsys/datums/datumorigins.html # http://www.ngs.noaa.gov/PC_PROD/Inv_Fwd/ return { WGS84=>{name=>'World Geodetic System of 1984', data=>{a=>6378137,i=>298.257223563}, alias=>[qw{WGS-84 NAD83 NAD-83}]}, GRS80=>{name=>'Geodetic Reference System of 1980', data=>{a=>6378137,i=>298.25722210088}, alias=>['GRS-80','GDA','Geocentric Datum of Australia']}, 'Clarke 1866'=>{name=>'Clarke Ellipsoid of 1866', data=>{a=>6378206.4,i=>294.9786982138}, alias=>[qw{NAD27 NAD-27}]}, 'Airy 1858'=>{name=>'Airy 1858 Ellipsoid', data=>{a=>6377563.396,i=>299.3249646}}, 'Airy Modified'=>{name=>'Modified Airy Spheroid', data=>{a=>6377340.189,b=>6356034.448}}, 'Australian National'=>{name=>'Australian National Spheroid of 1965', data=>{a=>6378160,i=>298.25}, alias=>["Australian 1965"]}, 'Bessel 1841'=>{name=>'Bessel 1841 Ellipsoid', data=>{a=>6377397.155,i=>299.1528128}}, 'Clarke 1880'=>{name=>'Clarke Ellipsoid of 1880', data=>{a=>6378249.145,b=>6356514.966}}, 'Clarke 1866'=>{name=>'Clarke Ellipsoid of 1866', data=>{a=>6378206.4,b=>6356583.8}}, 'Danish 1876'=>{name=>'Danish Spheroid of 1876', data=>{a=>3271883.25*1.94903631,i=>300.00}}, 'Everest 1830'=>{name=>'Everest Spheroid of 1830', data=>{a=>6377276.345,i=>300.8017}}, 'Everest Modified'=>{name=>'Modified Everest Spheroid', data=>{a=>6377304.063,i=>300.8017}}, 'Fisher 1960'=>{name=>'Fisher 1960', data=>{a=>6378166,i=>298.3}}, 'Fisher 1968'=>{name=>'Fisher 1968', data=>{a=>6378150,i=>298.3}}, 'Hough 1956'=>{name=>'Hough 1956', data=>{a=>6378270,i=>297}}, 'International (Hayford)'=>{name=>'International - 1924 (Hayford - 1909)', data=>{a=>6378388,i=>297}}, 'Krassovsky 1938'=>{name=>'Krassovsky 1938', data=>{a=>6378245,i=>298.3}, alias=>["Krasovsky 1940"]}, 'NWL-9D'=>{name=>'NWL-9D Ellipsoid', data=>{a=>6378145,i=>298.25}, alias=>['WGS-66'=>'World Geodetic System 1966']}, 'SA69'=>{name=>'South American 1969', data=>{a=>6378160,i=>298.25}, alias=>['SA-69']}, 'SGS85'=>{name=>'Soviet Geodetic System 1985', data=>{a=>6378136,i=>298.257}, alias=>['SGS-85']}, 'WGS72'=>{name=>'World Geodetic System 1972', data=>{a=>6378135,i=>298.26}, alias=>['WGS-72']}, 'WOS'=>{name=>'War Office Spheroid', data=>{a=>6378300.58,i=>296}}, 'UTM'=>{name=>'Department of the Army Universal Transverse Mercator', data=>{a=>6378249.2,b=>6356515.0}}, }; } =head2 name2ref Method returns a hash reference (e.g. {a=>6378137,i=>298.257223563}) when passed a valid ellipsoid name (e.g. 'WGS84'). my $ref=$obj->name2ref('WGS84') =cut sub name2ref { my $self=shift(); my $key=shift(); my $data=$self->data; return $data->{$key}->{'data'}; } 1; __END__ =head1 TODO What should we do about bad input? I tend to die in the module which for most situations is fine. I guess you could always overload die to handle exceptions for web based solutions and the like. Support for ellipsoid aliases in the data structure =head1 BUGS Please send to the geo-perl email list. =head1 LIMITS No guarantees that Perl handles all of the double precision calculations in the same manner as Fortran. =head1 AUTHOR Michael R. Davis qw/perl michaelrdavis com/ =head1 LICENSE Copyright (c) 2006 Michael R. Davis (mrdvt92) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO Geo::Forward Geo::Ellipsoid Geo::Coordinates::UTM Geo::GPS::Data::Ellipsoid GIS::Distance =cut __END__ #Information from # http://earth-info.nga.mil/GandG/coordsys/datums/datumorigins.html # http://www.ngs.noaa.gov/PC_PROD/Inv_Fwd/ # # @DATA=([DATA, 0, a, #, i|b|f, #], ...); # @NAME=([NAME, 0, short_name, long_name], ...); # @ALIAS=([ALIAS, 0, alias, alias, alias,...], ...); DATA:0:a:6378137:i:298.257223563 NAME:0:WGS84:World Geodetic System of 1984 ALIAS:0:WGS-84:NAD83:NAD-83 DATA:1:a:6378137:i:298.25722210088 NAME:1:GRS80:Geodetic Reference System of 1980 ALIAS:1:GRS-80 DATA:2:a:6378206.4:i:294.9786982138 NAME:2:Clarke 1866:Clarke Ellipsoid - 1866 ALIAS:NAD27:NAD-27 DATA:3:a:6377563.396:i:299.3249646 NAME:3:Airy 1858:Airy 1858 #DATA:4:a:6377340.189:i:299.3249646 DATA:4:a:6377340.189:b:6356034.448 NAME:4:Airy Modified:Modified Airy Spheroid DATA:5:a:6378160:i:298.25 NAME:5:Australian National:Australian National Spheroid DATA:6:a:6377397.155:i:299.1528128 NAME:6:Bessel 1841:Bessel 1841 #DATA:7:a:6378249.145:i:293.465 DATA:7:a:6378249.145:b:6356514.966 NAME:7:Clarke 1880:Clarke 1880 DATA:8:a:6377276.345:i:300.8017 NAME:8:Everest 1830:Everest Spheroid 1830 DATA:9:a:6377304.063:i:300.8017 NAME:9:Everest Modified:Modified Everest Spheroid DATA:10:a:6378166:i:298.3 NAME:10:Fisher 1960:Fisher 1960 DATA:11:a:6378150:i:298.3 NAME:11:Fisher 1968:Fisher 1968 DATA:12:a:6378270:i:297 NAME:12:Hough 1956:Hough 1956 DATA:13:a:6378388:i:297 NAME:13:International (Hayford):International (Hayford) DATA:14:a:6378245:i:298.3 NAME:14:Krassovsky 1938:Krassovsky 1938 DATA:15:a:6378145:i:298.25 NAME:15:NWL-9D:NWL-9D Ellipsoid ALIAS:15:WGS-66:World Geodetic System 1966 DATA:16:a:6378160:i:298.25 NAME:16:SA69:South American 1969 ALIAS:16:SA-69 DATA:17:a:6378136:i:298.257 NAME:17:SGS85:Soviet Geodetic System 1985 ALIAS:17:SGS-85 DATA:18:a:6378135:i:298.26 NAME:18:WGS72:World Geodetic System 1972 ALIAS:18:WGS-72 DATA:19:a:6378300.58:i:296 NAME:19:WOS:War Office Spheroid DATA:20:a:6378249.2:b:6356515.0 NAME:20:UTM:Department of the Army Universal Transverse Mercator Geo-Ellipsoids-0.16/LICENSE0000644000076400007640000000026010531743212014620 0ustar mdavismdavisCopyright (c) 2006 Michael R. Davis (mrdvt92) All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Geo-Ellipsoids-0.16/META.yml0000664000076400007640000000076711015112606015075 0ustar mdavismdavis# http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: Geo-Ellipsoids version: 0.16 version_from: lib/Geo/Ellipsoids.pm installdirs: site requires: constant: 0 Geo::Constants: 0.04 Geo::Functions: 0.03 strict: 0 vars: 0 distribution_type: module generated_by: ExtUtils::MakeMaker version 6.30 Geo-Ellipsoids-0.16/CHANGES0000644000076400007640000000125610571732420014617 0ustar mdavismdavis2006-03-01 v0.15 * Added test 2006-02-07 v0.14 * Added second eccentricity, e' = ep methods 2006-01-21 v0.13 * Documentation 2006-01-04 v0.12 * Documentation 2006-12-10 v0.11 * Documentation 2006-12-09 v0.10 * Documentation 2006-12-08 v0.09 * Added n_rad method * Changed prereq versions on Geo::* packages 2006-12-05 v0.08 * Added n method 2006-11-28 v0.06 * Added default for custom sphere case 2006-11-26 v0.05 * Added Documentation * Changed indent of one if statement 2006-11-26 v0.04 * Added Documentation 2006-11-26 v0.03 * Added Documentation * Added Example 2006-11-25 v0.02 * Fixed list method and example 2006-11-25 v0.01 * Original version Geo-Ellipsoids-0.16/t/0000755000076400007640000000000011015112606014053 5ustar mdavismdavisGeo-Ellipsoids-0.16/t/base.t0000644000076400007640000000516110571732706015174 0ustar mdavismdavis#!/usr/bin/perl -w # -*- perl -*- # # $Id: base.t,v 0.1 2006/02/21 eserte Exp $ # Author: Michael R. Davis # =head1 NAME base.t - Good examples concerning how to use this module =cut use strict; use lib q{lib}; use lib q{../lib}; use constant NEAR_DEFAULT => 7; sub near { my $x=shift(); my $y=shift(); my $p=shift()||NEAR_DEFAULT; if (($x-$y)/$y < 10**-$p) { return 1; } else { return 0; } } BEGIN { if (!eval q{ use Test; 1; }) { print "1..0 # tests only works with installed Test module\n"; exit; } } BEGIN { plan tests => 49 } # just check that all modules can be compiled ok(eval {require Geo::Ellipsoids; 1}, 1, $@); my $o = Geo::Ellipsoids->new(); ok(ref $o, "Geo::Ellipsoids"); my $obj=Geo::Ellipsoids->new(); $obj->set({a=>1,b=>1}); # a 1 unit sphere ok($obj->a, 1); ok($obj->b, 1); ok($obj->i, undef); ok($obj->f, 0); $obj->set({a=>1,b=>0.995}); ok($obj->a, 1); ok($obj->b, 0.995); ok($obj->i, 200); ok($obj->f, 0.005); $obj->set({a=>1,i=>200}); ok($obj->a, 1); ok($obj->b, 0.995); ok($obj->i, 200); ok($obj->f, 0.005); $obj->set({a=>1,f=>0.005}); ok($obj->a, 1); ok($obj->b, 0.995); ok($obj->i, 200); ok($obj->f, 0.005); $obj->set({a=>1}); ok($obj->a, 1); ok($obj->b, 1); ok($obj->i, undef()); ok($obj->f, 0); ok($obj->e, 0); ok near($obj->equatorial_circumference, 8 * atan2(1,1), 13); ok near($obj->polar_circumference, 8 * atan2(1,1), 13); $obj->set('WGS84'); ok($obj->a, 6378137); ok near($obj->b, 6356752.31424518, 13); ok($obj->i, 298.257223563); ok near($obj->f, 0.00335281066474748, 12); #For the Clarke 1866, e² is 0.006768658. $obj->set('Clarke 1866'); ok near($obj->e2, 0.006768658, 7); #For the GRS 80, e² is 0.0066943800. $obj->set('GRS80'); ok near($obj->e2, 0.0066943800, 6); $obj->set('WGS84'); ok($obj->shortname, "WGS84"); ok($obj->longname, "World Geodetic System of 1984"); ok near($obj->equatorial_circumference, 40075016.6855785, 13); ok near($obj->polar_circumference, 39940652.7422451, 13); #Just testing that n works. It is not my formula. ok(near $obj->n(39.56789), 6386817.167912991, 13); ok(near $obj->n_rad(0.690589958566939), 6386817.167912991, 13); my $a=$obj->a; my $b=$obj->b; my $i=$obj->i; my $f=$obj->f; my $e=$obj->e; my $e2=$obj->e2; my $ep2=$obj->ep2; #Run through a bunch of identities ok(near $i, 1/$f, 13); ok(near $i, $a/($a-$b), 13); ok(near $f, ($a-$b)/$a, 13); ok(near $b, $a*(1-$f), 13); ok(near 1, (1-$e2)*(1+$ep2), 13); ok(near $e2, $f*(2-$f), 13); ok(near $e2, 2*$f-$f**2, 13); ok(near $e2, 1-$b**2/$a**2, 13); ok(near $ep2, ($e*$a/$b)**2, 13); ok(near $ep2, $e2/(1-$e2), 13); ok(near $ep2, $a**2/$b**2-1, 13); ok(near $ep2, ($a**2-$b**2)/$b**2, 13);