NAME

Geo::Address::Formatter - take structured address data and format it according to the various global/country rules

VERSION

version 1.2.3

SYNOPSIS

#
# get the templates (or use your own) 
# git clone git@github.com:lokku/address-formatting.git
# 
my $GAF = Geo::Address::Formatter->new( conf_path => '/path/to/templates' );
my $components = { ... }
my $text = $GAF->format_address($components, { country => 'FR' } );

DESCRIPTION

You have a structured postal address (hash) and need to convert it into a readable address based on the format of the address country.

For example, you have:

{
  house_number => 12,
  street => 'Avenue Road',
  postcode => 45678,
  city => 'Deville'
}

you need:

Great Britain: 12 Avenue Road, Deville 45678  
France: 12 Avenue Road, 45678 Deville
Germany: Avenue Road 12, 45678 Deville
Latvia: Avenue Road 12, Deville, 45678

It gets more complicated with 100 countries and dozens more address components to consider.

This module comes with a minimal configuration to run tests. Instead of developing your own configuration please use (and contribute to) those in https://github.com/lokku/address-formatting which includes test cases.

Together we can address the world!

METHODS

new

my $GAF = Geo::Address::Formatter->new( conf_path => '/path/to/templates' );

Returns one instance. The conf_path is required.

format_address

my $text = $GAF->format_address(\%components, \%options );

Given a structures address (hashref) and options (hashref) returns a formatted address.

The only option you can set currently is 'country' which should be an uppercase ISO 3166-1 alpha-2 code, e.g. 'GB' for Great Britain. If ommited we try to find the country in the address components.

AUTHOR

edf <edf@opencagedata.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Lokku Limited.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.