-
-
05 Sep 2003 15:23:55 UTC
- Distribution: Geo-Approx
- Module version: 0.8
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues (1)
- Testers (551 / 0 / 0)
- Kwalitee
Bus factor: 0- 90.00% Coverage
- License: unknown
- Activity
24 month- Tools
- Download (3.33KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- Test::More
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
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.
SEE ALSO
http://lists.burri.to/pipermail/geowanking/2003-August/000301.html - the post that raised my interest.
COPYRIGHT
Copyright (C) 2002,2003 Nigel Wetters. All Rights Reserved.
NO WARRANTY. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Module Install Instructions
To install Geo::Approx, copy and paste the appropriate command in to your terminal.
cpanm Geo::Approx
perl -MCPAN -e shell install Geo::Approx
For more information on module installation, please visit the detailed CPAN module installation guide.