NAME

Geo::Integer - Generates a single integer from Lat and Lon coordinates

SYNOPSIS

use Geo::Integer;
my $gi=Geo::Integer->new(); 
my $integer=$gint->integer($lat, $lon);
my ($lat, $lon)=$gint->center($int);

DESCRIPTION

This module generates a 32-bit integer which represents a two dimensional value. The defaults are latitude and longitude in degrees but there should be no limitation for using any Cartesian grid. The integer returned actually represents a rectangular area like the image below.

ul ---------------- ur
|....................|
|....................|
|.......center.......|
|....................|
|....................|
ll ---------------- lr

By definition the center and ll values are "in" the rectangle. ul, ur and lr are by definition "in" adjacent rectangles.

USAGE

CONSTRUCTOR

new

my $obj = Geo::Integer->new();
my $obj = Geo::Integer->new(latmin   =>  -90,   #defaults
                            lonmin   => -180,
                            latrange =>  180,
                            lonrange =>  360 );

METHODS

integer

Returns a 32-bit integer representing a rectangle that contains the given coordinates.

my $integer=$gint->integer($lat, $lon);

center

Returns the center of the rectangle given the integer.

my $center=$gint->center($integer);

ll

Returns the lower left coordinate of the retangle given the integer.

my ($lat, $lon)=$gint->ll($int);

ul

Returns the upper left coordinate of the retangle given the integer.

my ($lat, $lon)=$gint->ul($int);

ur

Returns the upper right coordinate of the retangle given the integer.

my ($lat, $lon)=$gint->ur($int);

lr

Returns the lower right coordinate of the retangle given the integer.

my ($lat, $lon)=$gint->lr($int);

METHODS - Internal (coordinates to integer)

interlace

Returns a single 32-bit integer from two 16-bit integers.

my $int32=$gint->interlace($int16l, $int16h);

int_lat

Returns 16-bit integer from a latitude.

int_lon

Returns 16-bit integer from a longitude.

METHODS - Internal (integer to coordinates)

unlace

Returns two 16-bit integers from a single 32-bit integer.

my ($int16l, $int16h)=gint->unlace($int32);

lat_int

Returns latitude from a 16-bit integer.

lon_int

Returns longitude from a 16-bit integer.

BUGS

SUPPORT

Try geo-perl email list

AUTHOR

Michael R. Davis
CPAN ID: MRDVT
account=>perl,tld=>com,domain=>michaelrdavis

COPYRIGHT

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

The full text of the license can be found in the LICENSE file included with this module.

SEE ALSO

Geo::Approx