The Trusted Leader in ZIP Code Data since 2002

View Cart  |   Help  |   Customer Login     
 
 
 
 
  Product Families

USA Data


Canadian Data


Mexican Data *new*


Programming Tools

  Calculation APIs
   • Distance Assistant
   • Radius Assistant
   • Distance & Radius API

  At QualifiedAddress.com
   • Address Verification API


ZIP Code Maps *new*


Desktop Applications


Bundled Packages





Can't find the solution
you're looking for?

Contact Sales Now!



Over the last 12 months
we've added 235 new
USPS ZIP Codes and 7,208 new
Canadian Postal Codes to our data?

  Programmer APIs - Distance & Radius Package Have a question?

Download Now!
Our Price: $59.95
List Price: $99.95
Last Updated: Version 1.1

Availability: Immediate Internet Download

License: Standard 

$59.95Distance & Radius Package
$79.95+ Source Code
$99.95+ SQL Server Stored Procedures

Tutorial

Overview

The problem with most "Nearest Dealer Locators" is that they are not efficient. The USA has just under 42,000 ZIP Codes, while Canada has a whopping 770,000+ postal codes. Imagine if, every time you wanted to find all ZIP Codes within 100 miles of any city, your server was required to calculate the distance between the city and all 42,000 ZIP Codes. It would take quite a while - and let's not even begin to think about Canada!

The Solution

So, how do you solve it? The genius is in the solution. What if you could draw a horizontal line on a map 100 miles north and 100 miles south of the city as well as a line 100 miles east & west of the same city? Notice the red square on the map? (see map link below) That's what you'd get.

Now you can easily find all ZIP Codes in that range using an efficient database query - simply find all records where the ZIP Code's latitude & longitude coordinates fall within that red square (see map).

A sample database query would look like this: SELECT * FROM ZIPCodes WHERE Latitude > BottomLine AND Latitude < TopLine AND Longitude > LeftLine AND Longitude < RightLine where TopLine, BottomLine, LeftLine, and RightLine are the appropriate lat or long coordinate.

Database Experts Note: The above query is where you could perform an INNER JOIN of your dealer list with the ZIP Code database. This will, in most cases, drastically reduce the number of records returned and thus make the entire process more efficient.

Finding the Exact Distance

Once you've retreived all ZIP Code records (with corresponding lat/long points), you can then run each record through the ZIP Code Distance Assistant to find the exact distance and see if it fall on the inside or outside of the blue circle on the map. And that's it! You've successfully (and efficiently) found all records within 100 miles of the city!

Summary & Review

To find all "dealers" - or simply postal codes within X miles of a city:

  1. Get the latitude & longitude coordinate (Point A) of a city
  2. Find the lines of latitude & longitude to the north, south, east and west of Point A (My City)
  3. Perform a database query which returns all records with the lines of lat/long to each side of Point A
  4. If needed, make the above query an INNER JOIN with your dealer database table.
  5. Loop through each returned record and calculate the distance between Point A and each record
  6. Records more than X miles are disposed of, and records less than or equal to X miles are included in a list
  7. Display results list to the user

 
 

Home |  Products |  Solutions |  Help |  About Us |  Our Guarantee |  Site Map |  Contact Us

Copyright © 2002 - 2008 ZIP Code Download, an Exact Wave Company. All rights reserved.
Use of this website signifies your agreement to the privacy policy.
ZIP Code Download is a non-exclusive licensee of the United States Postal Service and Canada Post. The price of our products is neither established, controlled, nor approved by the United States Postal Service. The following trademarks are owned by the United States Postal Service: USPS®, Postal Service™, Post Office™, United States Postal Service®, ZIP+4®