SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2001
    Posts
    441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Search by radius/distance of zip code

    I am not sure which forum to post this in but since I am having my site coded in php I'll try here.
    -------------------------------------------------------


    I am having someone code a site for me and one of the features is that the end-user will be able to search for flower shops based upon zip code and distance (from that zip code) they input.

    Does a zip code database need to be purchases or does something like google api do what I'm looking for?

    Also, if a zip code database is needed, what
    features must that DB have? Latitude and longitude?

    Thank you.

  2. #2
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming

  3. #3
    SitePoint Evangelist
    Join Date
    Oct 2001
    Posts
    441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I wonder how these zip code databases determine the point for their latitude and longitude for each zip.

    Mandes, do you use the database from code322?

  4. #4
    Maniacally depressed robot poncho's Avatar
    Join Date
    Dec 2004
    Location
    Belfast, N.Ireland
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey man,

    I haven't yet had to do this for US zip code, but I have done it for the UK. I spotted this zipcode class that may be of some use to you. It also has a bunch of SQL files to populate a database with zip code, state and long-lat values.

    Cheers;
    Poncho
    Perfecting the art of breaking stuff.
    Check 'em: CakePHP | TextMate

  5. #5
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by edprush View Post
    I wonder how these zip code databases determine the point for their latitude and longitude for each zip.

    Mandes, do you use the database from code322?
    No I dont use it personally (I'm in Europe) but I have a friend that was using it in the US, think he was happy.

    As to how you find distance from Long, Lat this MS SQL user defined function

    Code:
    CREATE FUNCTION [dbo].[calcLatLongDist] 
    (   
    @lat_A decimal(28, 16)   , 
    @long_A decimal(28, 16)   , 
    @lat_B decimal(28, 16)   , 
    @long_B decimal(28, 16) 
    ) 
    RETURNS decimal(28, 16) 
    AS BEGIN   
    DECLARE     
    @Distance decimal(28, 16)      
     
    SET @Distance = (Sin(Radians(@lat_A)) *
         Sin(Radians(@lat_B)) +
         Cos(Radians(@lat_A)) *
         Cos(Radians(@lat_B)) *
         Cos(Radians(@long_A - @long_B)))   
     
    SET @Distance = (Degrees(ACos(@Distance))) * 69.09   RETURN @Distance 
    END
    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming

  6. #6
    SitePoint Evangelist
    Join Date
    Oct 2001
    Posts
    441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mandes View Post
    I see that code322 gets their zip codes from:

    Includes over 42,000 ZIP codes (provided by Team Redline ).
    How do I know if the zip code database is correct/updated?

    I was looking at the Team Redline site and saw:

    2001-2005, All Rights Reserved, TeamRedLine
    That doesn't look too good.

    Who knows if if they're trustworthy?

    I wrote to the USPS.gov and asked how many zip codes there are and they repliled that they didn't know. -- Makes it hard to determine if a zip code database is properly updated.

  7. #7
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Look on the right hand side of the webpage for Team redline

    Latest News

    Zipcode data was last updated March 2007.
    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming

  8. #8
    SitePoint Evangelist
    Join Date
    Oct 2001
    Posts
    441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I saw that but they don't give any hard numbers. There's no way to determine that their database is reliable.

    How could they sell a nationwide (United States) up-to-date zip code database for $5 USD and other companies can charge up to $400 for the same database. Of course, there's no way to determine if those $400 databases are reliable either.


    Regarding Team Redline, I noticed that on the first day of each month they update their site to say "zipcode data was updated on"....

  9. #9
    SitePoint Evangelist
    Join Date
    Oct 2001
    Posts
    441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've sent 2 emails to the Team Redline site (4 days apart) and I never received any reply--that's probably not a good sign.

  10. #10
    SitePoint Wizard bronze trophy bigalreturns's Avatar
    Join Date
    Mar 2006
    Posts
    1,295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How often are zip codes likely to be updated? New ones maybe, but you could always have an unrecognised zip code feature that added a street address to your db.
    For $5 it's probably worth spending just to take a look at it, try it out and see if you have any issues.
    "The proper function of man is to live - not to exist."
    Get a Free TomTom


  11. #11
    SitePoint Evangelist
    Join Date
    Oct 2001
    Posts
    441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have been writing to the USPS.gov and they can't give me any information as to how many zip codes there are a this time nor can they tell me how many zip codes are added per year/month...

    So it is nearly impossible to determine any accuracy or reliability to a zip code database that you purchase.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •