Skip Menu |

This queue is for tickets about the Geo-Ellipsoid CPAN distribution.

Report information
The Basics
Id: 105272
Status: resolved
Priority: 0/
Queue: Geo-Ellipsoid

People
Owner: Nobody in particular
Requestors: peter.john.acklam [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.12
Fixed in: 1.13



Subject: Change function calls to method calls for subclassing
For subclassing to work, please change from function calls, e.g., my($range,$bearing) = _inverse($self,@args); to method calls, e.g., my($range,$bearing) = $self->_inverse(@args); This must also be done in the constructor, e.g., set_units($self,$self->{units}); must become $self->set_units($self->{units}); This requires bless() to be called earlier. I have attached a patch which fixes all the code I needed to change to create my Geo::Sphere subclass of Geo::Ellipsoid.
Subject: Ellipsoid.pm.patch
--- /usr/local/lib/perl5/site_perl/5.14/Geo/Ellipsoid.pm 2008-07-05 01:13:47.000000000 +0200 +++ /usr/local/lib/perl5/site_perl/5.14/Geo/Ellipsoid.pm.modified 2015-06-16 20:26:37.963663000 +0200 @@ -171,16 +171,16 @@ carp("Unknown argument: $key => $args{$key}"); } } - set_units($self,$self->{units}); - set_ellipsoid($self,$self->{ellipsoid}); - set_distance_unit($self,$self->{distance_units}); - set_longitude_symmetric($self,$self->{longitude}); - set_bearing_symmetric($self,$self->{bearing}); + bless $self,$class; + $self->set_units($self->{units}); + $self->set_ellipsoid($self->{ellipsoid}); + $self->set_distance_unit($self->{distance_units}); + $self->set_longitude_symmetric($self->{longitude}); + $self->set_bearing_symmetric($self->{bearing}); print "Ellipsoid(units=>$self->{units},distance_units=>" . "$self->{distance_units},ellipsoid=>$self->{ellipsoid}," . "longitude=>$self->{longitude},bearing=>$self->{bearing})\n" if $DEBUG; - bless $self,$class; return $self; } @@ -338,7 +338,7 @@ }else{ croak("set_custom_ellipsoid called without semi-major radius parameter"); } - set_ellipsoid($self,$name); + $self->set_ellipsoid($name); } =head2 set_longitude_symmetric @@ -501,7 +501,7 @@ { my $self = shift; my @args = _normalize_input($self->{units},@_); - my($range,$bearing) = _inverse($self,@args); + my($range,$bearing) = $self->_inverse(@args); print "inverse(@_[1..4]) returns($range,$bearing)\n" if $DEBUG; return $range; } @@ -520,7 +520,7 @@ my $self = shift; my $units = $self->{units}; my @args = _normalize_input($units,@_); - my($range,$bearing) = _inverse($self,@args); + my($range,$bearing) = $self->_inverse(@args); print "inverse(@args) returns($range,$bearing)\n" if $DEBUG; my $t = $bearing; $self->_normalize_output('bearing',$bearing); @@ -545,7 +545,7 @@ my( $lat, $lon, $az ) = _normalize_input($units,@_[0,1,3]); my $r = $_[2]; print "at($lat,$lon,$r,$az)\n" if $DEBUG; - my( $lat2, $lon2 ) = _forward($self,$lat,$lon,$r,$az); + my( $lat2, $lon2 ) = $self->_forward($lat,$lon,$r,$az); print "_forward returns ($lat2,$lon2)\n" if $DEBUG; $self->_normalize_output('longitude',$lon2); $self->_normalize_output('latitude',$lat2); @@ -568,7 +568,7 @@ my $units = $self->{units}; my @args = _normalize_input($units,@_); print "to($units,@args)\n" if $DEBUG; - my($range,$bearing) = _inverse($self,@args); + my($range,$bearing) = $self->_inverse(@args); print "to: inverse(@args) returns($range,$bearing)\n" if $DEBUG; #$bearing *= $degrees_per_radian if $units eq 'degrees'; $self->_normalize_output('bearing',$bearing); @@ -598,7 +598,7 @@ print "displacement(",join(',',@_),"\n" if $DEBUG; my @args = _normalize_input($self->{units},@_); print "call _inverse(@args)\n" if $DEBUG; - my( $range, $bearing ) = _inverse($self,@args); + my( $range, $bearing ) = $self->_inverse(@args); print "disp: _inverse(@args) returns ($range,$bearing)\n" if $DEBUG; my $x = $range * sin($bearing); my $y = $range * cos($bearing);