Problems? Is your data what you think it is? PerlMonks

### Re: Getting Locations using Distance

by kvale (Monsignor)
 on Apr 12, 2006 at 17:28 UTC ( #542902=note: print w/replies, xml ) Need Help??

in reply to Getting Locations using Distance

The easiest approach is to traverse your list of locations and compute the distaance of each location from your designated position. To get locations of zip codes, try Geo::Coder::US:
```use Geo::Coder::US;
Geo::Coder::US->set_db( "geocoder.db" );
my (\$ora) = Geo::Coder::US->geocode(
"1005 Gravenstein Hwy N, 95472" );
print "O'Reilly is located at \$ora->{lat} degrees north, "
"\$ora->{long} degrees east.\n";
To compute distances, use Geo::Ellipsoid:
```use Geo::Ellipsoid;
@origin = ( 37.619002, -122.374843 );    # SFO
@dest = ( 33.942536, -118.408074 );      # LAX
( \$range, \$bearing ) = \$geo->to( @origin, @dest );
(\$lat,\$lon) = \$geo->at( @origin, 45.0, 2000 );
( \$x, \$y ) = \$geo->displacement( @origin, \$lat, \$lon );
@pos = \$geo->location( \$lat, \$lon, \$x, \$y );

-Mark

Create A New User
Node Status?
node history
Node Type: note [id://542902]
help
Chatterbox?
 [perldigious]: "for how I roll"... ahhh, I see what you did there stevieb. [MidLifeXis]: Has anyone been successful running prove under Windows with a --jobs parameter? It appears, even with (what appears to be) appropriately- configured parameters and up to date Test::Harness/TAP ::Harness that tests are still running serially.

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (13)
As of 2016-12-06 16:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
On a regular basis, I'm most likely to spy upon:

Results (112 votes). Check out past polls.