Image-Maps-Plot-FromPostcode

 view release on metacpan or  search on metacpan

FromPostcode.pm  view on Meta::CPAN

package Image::Maps::Plot::FromPostcode; # where in the world are London.pm members?

our $VERSION = 2;
our $DATE = "Tue 12 Feb  2003 15:33 CET";#"Mon 28 May 09:59 2002 CET"; #"Fri 06 July 19:18 2001 BST";
use 5.006;
use strict;
use warnings;

use base "Image::Maps::Plot::FromLatLong";

our %locations;
our $ADDENTRY;	# Should be object field

=head1 NAME

Image::Maps::Plot::FromPostcode - from postcodes plot world/regional maps in JPEG/HTML

=head1 DESCRIPTION

This module is a sub-class of C<Image::Maps::Plot::FromLatLong>,
that uses the C<WWW::MapBlast> module to convert postcodes to
latitude and longitude.

=head1 OVER-RIDDEN METHODS

=head2 METHOD add_entry

A method that accepts: $name, $country, $postcode

Looks up on MapBlast.com the supplied details, and adds them to the db.

If an entry already exists for $name, will return C<undef> unless
the global scalar C<$ADDENTRY> is set to it's default value of C<MULTIPLE>,
in which case $name will be appended with $country and $postcode.

Does not save them to file - you must do that manually (L<"METHOD save_db">), but
note that you may wish to load the db before adding to it and saving.

Incidentaly returns a reference to the new key.

See also L<ADDING MAPS>.

=cut

sub add_entry { my ($self, $name,$country,$postcode) = (@_);
	eval('use WWW::MapBlast 0.02;');
	die "Can't add_entry without \$name, \$country, \$postcode "
		unless (defined $name and defined $country and defined $postcode);

	my ($lat,$lon,$address) = WWW::MapBlast::latlon($country,$postcode);
	$lat = 11111111 if not defined $lat or $lat eq '';
	$lon = 11111111 if not defined $lon or $lon eq '';
	if (not defined $address or $address eq ''){
		$address = "$postcode $country - MapBlast.com didn't know"
	}

	if (exists $locations{$name} ){
		if ($ADDENTRY ne 'MULTIPLE'){
			warn "Not adding duplicate entry for $name at $postcode, $country.\n" if $self->{chat};
			return undef;
		}
		$name .= " ($postcode $country)";
	}



( run in 0.508 second using v1.01-cache-2.11-cpan-e1769b4cff6 )