Geo-Code-XYZ
view release on metacpan or search on metacpan
lib/Geo/Code/XYZ.pm view on Meta::CPAN
package Geo::Code::XYZ;
use 5.006;
use warnings;
use Math::BigInt lib => 'GMP';
my %vowel = ('A' => '1','O' => '1','E' => '1','I' => '1','Y' => '1','U' => '1');
use constant DEBUG => 0;
use constant BASEN => 146300;
use constant BASEA => 36;
use constant BASEAEL => 26;
use constant PADD => 282699884614999;
use constant ALPHA => [ A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z ];
my %altmap = ( 'A'=>'0','B'=>'1','C'=>'2','D'=>'3','E'=>'4','F'=>'5','G'=>'6','H'=>'7','I'=>'8','J'=>'9','K'=>'10','L'=>'11','M'=>'12','N'=>'13','O'=>'14','P'=>'15','Q'=>'16','R'=>'17','S'=>'18','T'=>'19','U'=>'20','V'=>'21','W'=>'22','X'=>'23','Y'=>...
use constant ALPHANUMERIC => [ 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z ];
use constant GEONAMETRIPLE => [
ZERO,OC,OH,OY,OK,QY,UC,UX,XU,AH,AQ,AZ,BY,CE,DY,EF,EP,EQ,EX,HY,YD,YI,YM,IQ,YR,YS,AAH,AAS,ABB,ABC,ABL,ABN,ABP,ABS,ABV,ACC,ACY,ACT,ADC,ADJ,ADP,ADS,ADV,ADZ,AEQ,AER,AES,AFB,AFD,AFT,AGY,AGT,AHT,AIX,ALC,ALG,ALN,ALP,ALS,ALW,AMB,AMT,ANI,ANS,AOB,AOR,APH,APL,AP...
sub new {
my $class = shift;
my $self = {
};
bless ($self, $class);
return $self;
}
sub geodata {
my $self = shift;
$self->{geodata} = $_[0] if defined $_[0];
return $self->{geodata};
}
sub geocode {
my $self = shift;
my %params = @_;
my $lat = $params{lat} if defined $params{lat};
my $lon = $params{lon} if defined $params{lon};
my $el = $params{el} if defined $params{el};
my $code = uc $params{gc} if defined $params{gc}; #Geo::Code::XYZ is case insensitive
my $geo3name = $params{geoname} if defined $params{geoname};
if (defined $lat && defined $lon) {
if ($geo3name) {
$self->ngcode($lat,$lon,$geo3name,$el);
} else {
$self->gcode($lat,$lon);
}
} else {
$self->gll($code);
}
my $geodata = $self->geodata;
return $self->geodata;
}
sub gcode {
my $self = shift;
my ($lat,$lon) = @_;
my $geodata = &lltodec($lat,$lon);
return $self->geodata($geodata);
}
sub gll {
my $self = shift;
my $code = shift;
my $geodata = &dencd($code);
return $self->geodata($geodata);
}
( run in 0.890 second using v1.01-cache-2.11-cpan-39bf76dae61 )