Geo::WebService::OpenCellID - Perl API for the opencellid.org database


Geo-WebService-OpenCellID documentation Contained in the Geo-WebService-OpenCellID distribution.

Index


Code Index:

NAME

Top

Geo::WebService::OpenCellID - Perl API for the opencellid.org database

SYNOPSIS

Top

  use Geo::WebService::OpenCellID;
  my $gwo=Geo::WebService::OpenCellID->new(key=>$apikey);
  my $point=$gwo->cell->get(mcc=>$country,
                            mnc=>$network,
                            lac=>$locale,
                            cellid=>$cellid);
  printf "Lat:%s, Lon:%s\n", $point->latlon;

DESCRIPTION

Top

Perl Interface to the database at http://www.opencellid.org/

USAGE

Top

CONSTRUCTOR

Top

new

  my $obj = Geo::WebService::OpenCellID->new(
                                             key=>"myapikey",                   #default
                                             url=>"http://www.opencellid.org/", #default
                                            );

METHODS

Top

key

Sets and returns the API key.

url

Sets and returns the URL. Defaults to http://www.opencellid.org/

cell

Returns a Geo::WebService::OpenCellID::cell object.

measure

Returns a Geo::WebService::OpenCellID::measure object.

METHODS (INTERNAL)

Top

call

Calls the web service.

  my $data=$gwo->call($method_path, $response_class, %parameters);

data_xml

Returns a data structure given xml

  my $ref =$gwo->data_xml();

BUGS

Top

Submit to RT and email the Author

SUPPORT

Top

Try the Author or Try 8motions.com

AUTHOR

Top

    Michael R. Davis
    CPAN ID: MRDVT
    STOP, LLC
    domain=>michaelrdavis,tld=>com,account=>perl
    http://www.stopllc.com/

COPYRIGHT

Top

SEE ALSO

Top

URI, LWP::Simple, XML::Simple


Geo-WebService-OpenCellID documentation Contained in the Geo-WebService-OpenCellID distribution.
package Geo::WebService::OpenCellID;
use warnings;
use strict;
use base qw{Geo::WebService::OpenCellID::Base};
use Geo::WebService::OpenCellID::cell;
use Geo::WebService::OpenCellID::measure;
use LWP::Simple qw{};
use XML::Simple qw{};
use URI qw{};

our $VERSION = '0.05';

sub initialize {
  my $self=shift;
  %$self=@_;
  $self->url("http://www.opencellid.org/") unless $self->url; 
  $self->key("myapikey")                   unless $self->key;
}

sub key {
  my $self=shift;
  $self->{"key"}=shift if @_;
  return $self->{"key"};
}

sub url {
  my $self=shift;
  $self->{"url"}=shift if @_;
  return $self->{"url"};
}

sub cell {
  my $self=shift;
  unless (defined($self->{"cell"})) {
    $self->{"cell"}=Geo::WebService::OpenCellID::cell->new(parent=>$self);
  }
  return $self->{"cell"};
}

sub measure {
  my $self=shift;
  unless (defined($self->{"measure"})) {
    $self->{"measure"}=Geo::WebService::OpenCellID::measure->new(parent=>$self);
  }
  return $self->{"measure"};
}

sub call {
  my $self=shift;
  my $path=shift or die;
  my $class=shift or die;
  my $uri=URI->new($self->url);
  $uri->path($path);
  $uri->query_form(key=>$self->key, @_);
  my $content=LWP::Simple::get($uri->as_string);
  if ($content) {
    return $class->new(
                       content => $content,
                       url     => $uri,
                       data    => $self->data_xml($content),
                      );
  } else {
    return undef;
  }
}

sub data_xml {
  my $self=shift;
  my $xml=shift;
  return XML::Simple->new(ForceArray=>1)->XMLin($xml);
}

1;