Welcome Guest, Not a member yet? Register   Sign In
ZIP Code proximity - how to calculate?
#1

[eluser]spheroid[/eluser]
Anyone know of any good PHP libraries to figure out ZIP code proximity?
#2

[eluser]Mirage[/eluser]
[quote author="spheroid" date="1209688468"]Anyone know of any good PHP libraries to figure out ZIP code proximity?[/quote]

I wrote something like that for a client. Buy a Zip Code db that includes Latitude and Longintude for the various codes. I get mine at ZipCode Download. Then in what ever table you're tracking add columns for Latitude and Longitude and update the the table with values for the zipcode table. Doing it that way saves you a time consuming join when doing the query.

Then the secret bit of salt is a SQL query that can approximate all included latitude/longitude coordinates given your starting point. Check it out at Endless Summer - a site I wrote in CI.

Cheers!
#3

[eluser]elvix[/eluser]
I found an open source Zip php class by Micha Carrick. It's a little old (2005) and only includes a DB table for US zip codes, but it includes the distance functions I think you're looking for.

http://www.micahcarrick.com/04-19-2005/p...tml#more-6

Another solution to buying a Zip code DB is to use Google Map's geocoder. I extracted the geocoding functions from a CI-enabled Google Maps API library I found, and just do queries for the Zips as they're needed, saving the results in a DB table so I don't have to look them up again. Works great and handles US, Canada, Japan, Europe -- well, anywhere Google goes. Smile

Google returns validated zip code data, along with city, state, country and lat/long.
#4

[eluser]missionsix[/eluser]
There's also a great website, geocoder.us: a free US geocorder for zipcode / lat / long lookup.




Theme © iAndrew 2016 - Forum software by © MyBB