« June 2007 | Main | August 2007 »

July 2007 Archives

July 7, 2007

Doing a Radius Search - Code

I've been asked a number of times how to construct a radius search in miles for point coordinates. This is a pretty simple thing to do once it is realized that true circles are hard to deal with using latitude and longitude coordinates. I've found the best method is not to use a circle and a radius but instead construct a circular polygon using a haversine formula to compute the verticies of the polygon from a center point. Here's an example using Perl to compute such a polygon for a radius of 20 miles with a zip code of 38654 as the center point (centroid courtesy of Google Map API Geocoder).

#!/usr/bin/perl -w
use strict ;

my $radius = 20 ;
my $clat = 34.918 ;
my $clng = -89.8215 ;
my $PI = 3.141593 ;
my $d2r = $PI/180 ;
my $r2d = 180/$PI ;
my $lat = ($radius/3963) * $r2d ;
my $lng = $lat/cos($clat * $d2r);
my @points = ( ) ;
my $i = 0 ;
my $x = '' ;
my $y = '' ;

for ($i = 0 ; $i < 13 ; $i++)
$y = sprintf("%0.6f",$clng + ($lng * cos($PI * ($i/6)))) ;
$x = sprintf("%0.6f",$clat + ($lat * sin($PI * ($i/6)))) ;
push( @points, [$x,$y] ) ;

foreach $x ( @points )
print "$$x[0],$$x[1]\n" ;

Results of this calculation:


This is how it looks on a map:

The same basic code in Javascript can be found in this example page:


Once the polygon has been constructed, the search method depends on the database being used. I prefer Postgres or PostGIS, both of which have exceptional spatial functions built in.

July 29, 2007

IP Requirement for purchasing hits

If you are interested in purchasing hits from our servers, here is important information for you to know:

The "hit" system is based on knowing your IP, which is a unique number that identifies your connection. Most servers, companies and home DS/Cable connections have an IP that rarely changes. Dial up users get a different IP each time they connect.

In order for us to apply "hits" you've purchased correctly, we need to know what IP your connection is using. If you are using a server and want to retrieve data from us, you should know your IP or should ask your administrator for this information. If you are using our services from a high speed connection, your IP will be attached automatically and added to an e-mail sent from our system (see link below).

After purchasing hits from one of the links provided on our salesdata page, please use the following link to send us an e-mail with the following information:

IP of your server
Name of application to be used (reverse geocoder, zip code inquiry, etc.)
Site of the application (maps.huge.info or usnaviguide.com)

High speed internet users don't need to know their IP, it is automatically attached to the e-mail.

Link: Send us your IP

Please allow up to 48 hours to have your request processed. Many times this will occur within an hour or less.

Australian Postcode Tiles Now Available!

We've just released postcode tiles for Australia in zoom levels 5-17. These tiles are available to use on your own site for a $250 signup fee plus the regular per hit charges that apply to all our programs. Each tile delivered counts as a single hit.

Here's a sample at zoom level 14: (Sydney Harbor)

Sydney Harbor

If you'd like to sign up to use these tiles on your site, send us an e-mail (click here) and we'll send you the details on how this can be accomplished.

Tiles for USPS Zip Codes and ZCTA's for the United States are also available...

About July 2007

This page contains all entries posted to maps.huge.info / USNaviguide LLC in July 2007. They are listed from oldest to newest.

June 2007 is the previous archive.

August 2007 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.31