Geo-Ellipsoids
view release on metacpan or search on metacpan
lib/Geo/Ellipsoids.pm view on Meta::CPAN
=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_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
=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 {
( run in 0.830 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )