# NAME

Geo::Approx - represents an approximate global position by a single number

# SYNOPSIS

``````  use Geo::Approx;
my \$ga = Geo::Approx(\$precision);
my \$pos = \$ga->latlon2int(\$lat,\$lon);
my (\$approx_lat,\$approx_lon) = \$ga->int2latlon(\$pos);``````

# DESCRIPTION

It is sometimes useful to condense the information present in a latitude and longitude into a single number (for example, when storing the position within a database). This module provides methods for this conversion. By default, the precision of the position is set at 32 bits (roughly

Assuming the surface area of the earth is 5.1 x 10^8 sq km, the area represented by the single number at each precision is as follows:

``````  0.12 sq km at 32 bits
0.24 sq km at 31 bits
0.47 sq km at 30 bits
0.95 sq km at 29 bits
and so on (5.1E8 / 2^precision)``````

These areas are constant across all latitudes and longitudes.

Thus, if you want to be fairly precise about positions, you can store fairly large numbers, whereas if you want to be fairly imprecise, you can use small numbers.

# CONSTRUCTOR

The constructor takes one optional argument - a number between zero and 32 indicating precision.

``  my \$ga = Geo::Aprox->new(24);``

By default, the precision is 32 bits.

# OBJECT METHODS

\$pos = \$ga->latlon2int(\$lat,\$lon);

Converts a latitude and longitude to an integer integer representing that position. Latitude must be between -90 and 90. Longitude must be between -180 and 180.

(\$lat,\$lon) = \$ga->int2latlon(\$pos);

Converts a position represented by an integer into a latitude and longitude.