Git Product home page Git Product logo

perl-geo-address-formatter's Introduction

Geo::Address::Formatter

A Perl module to take structured address data and format it according to the various global/country rules.

The module runs against a set of templates and test cases from the address-formatting project.

Build status

Build StatusCPAN Coverage Status Mastodon Follow

Usage

For docs please see the Geo::Address::Formatter page on search.metacpan.org or perldoc Geo::Address::Formatter.

Installation

To install into your Perl environment you can use the following command:

$ cpan Geo::Address::Formatter

or (recommended) use cpanm

The address-formatting repository is added as a git submodule. It is versioned, that means it won't automatically update when you run git pull. To point it to a newer version of the configuration run

  1. git submodule init
  2. git submodule update

This will give you the templates as versions with this repository. To fetch the latest templates available use git submodule foreach git pull origin master

See also: http://git-scm.com/book/en/Git-Tools-Submodules

To submit new countries/territories please see the details in the address-formatting repository, this module just processes the templates

DEVELOPMENT

# first install Dist::Zilla
dzil clean

# running the test-suite
dzil test --author

# don't forget to increase the version number in dist.ini and CHANGES file
dzil build

# git push, upload to CPAN
dzil release

COPYRIGHT AND LICENCE

Copyright OpenCage GmbH [email protected]

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10 or, at your option, any later version of Perl 5 you may have available.

Who is OpenCage GmbH?

We run a worldwide geocoding API and geosearch service based on open data. Learn more about us.

We also organize Geomob, a series of regular meetups for location based service creators, where we do our best to highlight geoinnovation. If you like geo stuff, you will probably enjoy the Geomob podcast.

perl-geo-address-formatter's People

Contributors

freyfogle avatar kaoru avatar mtmail avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

perl-geo-address-formatter's Issues

new() should fail when config file(s) not found

It's possible to call

my $GAF = Geo::Address::Formatter->new( conf_path => '/tmp/does-not-exist/' );

which leads to an error message

No such file or directory at [...]/YAML/XS.pm line 48.

and an error for each

my $lines = $GAF->format_address($rh_address, {abbreviate => 1});
Use of uninitialized value $template_text in hash element at [...]/Geo/Address/Formatter.pm line 208.

I would argue an invalid path to new() should lead to a fatal error so the script can't continue.

Newline info lost during formatting

While information on newlines is properly stored in the input file, it is lost and replaced with "," in the perl library. As "," can occur in addresses it is not possible to create a full postal address with proper newlines from that output.

However it seems that in some country specific postforma_replace rules, you rely on the fact that newlines are replaced with "," (or at least I assume that from replacements like ["Bogota, Bogota","Bogota"]).

Although having proper oneline addresses is already awesome, I think that having multiline addresses (as used for postal services) is even more valuable (e.g for business usage). This should obviously also be exposed in the OpenCage Geocoder API.

change to config to deal with dependant territories

I'd like to change the way we parse worldwide.yaml to better deal with territories that for whatever historic reason have their own country code but actually use the address format of another country. An example would be American Samoa and the US, somehow it should be straight forward to simply define American Samoa as using the US format rather than replicating configuration. Of course AS should still be able to have it's own post formatting, etc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.