NAME

Geo::Code::XYZ - The GeoCode of a latitude,longitude,elevation point is a ten byte string, three geonames, or a hybrid code. This Perl module converts between them.

VERSION

Version 1.0

SYNOPSIS

 	use Geo::Code::XYZ;
	my $g = Geo::Code::XYZ->new();
	my $elevation = 0; #default
	my $geocode = $g->geocode(lat=>45.900,lon=>-64.363, el=>$elevation, geoname => 1);
 
        # geoname can take one of four values => {0,1,2,4}. 0 -> Alphanumeric, 1 -> three geonames, 2 -> hybrid string (one geoname and a string), 3 -> numeric code.
                     
	# Example 1 (Alphanumeric Geo::Code::XYZ)

	#!/usr/bin/perl
	use strict;
	use Geo::Code::XYZ;
	my $g = Geo::Code::XYZ->new();
	my $geocode = $g->geocode(lat=>45.900,lon=>-64.363, geoname => 0);

	print "The geocode is $geocode\n";

	#expected response
	The geocode is EHBSYSEIAH

        # Example 2 (Triple Name Geo::Code::XYZ)

        #!/usr/bin/perl
        use strict;
        use Geo::Code::XYZ;
        my $g = Geo::Code::XYZ->new();
        my $geocode = $g->geocode(lat=>45.900,lon=>-64.363, geoname => 1);

        print "The geocode is $geocode\n";

        #expected response
        The geocode is MONCTON-CAPDEP-UPPER


        # Example 3 (Hybrid Geo::Code::XYZ)

        #!/usr/bin/perl
        use strict;
        use Geo::Code::XYZ;
        my $g = Geo::Code::XYZ->new();
        my $geocode = $g->geocode(lat=>45.900,lon=>-64.363, geoname => 2);

        print "The geocode is $geocode\n";

        #expected response
        The geocode is MONCTON-5BCIZRD


        # Example 4 (Convert a Geo::Code back to Latitude,Longitude,Elevation)

        #!/usr/bin/perl
        use strict;
        use Geo::Code::XYZ;
        my $g = Geo::Code::XYZ->new();
	my $geocode='EHBSYSEIAH';
        my $xy = $g->geocode(gc=>$geocode);
	my ($lat,$lon,$el) = @$xy;
        print "The latitude,longitude,elevation of $geocode is ($lat,$lon,$el)\n";

        my $geocode='MONCTON-CAPDEP-UPPER';
        my $xy = $g->geocode(gc=>$geocode);
        my ($lat,$lon,$el) = @$xy;
        print "The latitude,longitude,elevation of $geocode is ($lat,$lon,$el)\n";

        my $geocode='MONCTON-5BCIZRD';
        my $xy = $g->geocode(gc=>$geocode);
        my ($lat,$lon) = @$xy;
        print "The latitude,longitude of $geocode is ($lat,$lon)\n";


        #expected response
        The latitude,longitude of EHBSYSEIAH is (45.90000,-64.36300)
	The latitude,longitude of MONCTON-CAPDEP-UPPER is (45.90000,-64.36300)
	The latitude,longitude of MONCTON-5BCIZRD is (45.90000,-64.36300)

DESCRIPTION

Geo::Code::XYZ is the 3d version of the perl5 module Geo::Code. It produces location codes for latitude,longitude,elevation triplets with a resolution of 1 meter for an elevation of up/down to +- 17576 metres.

It translates between (latitude,longitude,elevation) and four types of one dimensional string (one alphanumeric string, a triple geoname combination, a hybrid and a numeric triple).

A set of 146300 geonames has been selected from geonames.org with certain requirements such as: every geoname has phonetic/levenstein distance of at least 2 from every other geoname, the maximum length of e geoname is 12 (to accomodate some long geonames such as VALENCIENNES - however most geonames are no longer than 8 characters), major geonames are prioritized over less known ones to make the set more memorable, etc.

This module is explained in more detailed on GitHub. View on GitHub.

Online Demo. 3Geonames.org.

Also supported on Geocode.xyz.

METHODS

new

my $g = Geo::Code::XYZ->new();

geocode

my $code = $g->geocode(lat=>45.900,lon=>-64.363, geoname=>0); #if geoname is omited, the default is Alphanumeric Geo::Code. If elevation is omited, it default to 0 (ground level 0).

or

my $point = $g->geocode(gc=>'MONCTON-CAPDEP-UPPER');

geocode

REQUIREMENTS

Math::BigInt # lib => 'GMP'; make it run faster

SEE ALSO

https://3geonames.org, https://geocode.xyz

AUTHOR

Ervin Ruci, <eruci at geocode.xyz>

BUGS

Please report any bugs or feature requests to bug-geocode at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Geo::Code. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Geo::Code::XYZ

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2019 Ervin Ruci.

This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:

http://www.perlfoundation.org/artistic_license_2_0

Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.

If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.

This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.

This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.

Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

SEE ALSO Geo::Code Geo::OLC Geohash