zip code/location implementation

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
webcornea
Forum Newbie
Posts: 6
Joined: Thu Sep 20, 2007 3:51 pm

zip code/location implementation

Post by webcornea »

hello,

i am building a php based site and need to have search based on zip code and locations. what is the best possible solution for doing this?

i want to do searches like search within XX miles of zip code xxxxx

please help

thank you
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

I would use the Google Geocoding API to resolve the ZIP code to LAT/LON points, then pythagorize the SQL search against known LAT/LON points of interest.

Hint: Do the math in your query, SQL engines are waaayyyy more optimized than runtimes.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

I will second Kieran's suggestion. I tend to do the Google geocode lookup when the record is added and save the longitude/latitude in the record for use by searches.
(#10850)
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

I should mention that some DB engines have spatial functions for calculating distance, etc... but I have a feeling they're not installed by default.
webcornea
Forum Newbie
Posts: 6
Joined: Thu Sep 20, 2007 3:51 pm

There is a limit of 50,000 geocode requests per day per Maps

Post by webcornea »

There is a limit of 50,000 geocode requests per day per Maps API key.

we expect our site to be very high traffic and 50,000 will be exhausted pretty fast. any other suggestions you guys may have or is there a way to go around this issue? please help

i also wanted to clarify that i only want to implement search based on location like myspace.com or ebay.com where people can search for products and users within a certain area based on zip code

please help

thank you
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

First of all, it's not a hard limit, it's a request rate of 50,000 requests per day. that works out to about 1 request every 2 seconds.

Second of all, it's not a limit per se, they just ask you to notify them of the traffic hit if you plan to exceed that rate.

Finally, (and most importantly!) I highly doubt you'll need more than 50,000 requests per day. Why would you need to geocode that many points every day? I would have to guess it's because you're not caching them locally, which would preclude your "proximity" search entirely. It would also make your service hella slow.

Also, check out the Google Maps API documentation - I'm fairly certain they've exposed "local search" as an API.

Anywho, build it first. Worry about being too successful later.
webcornea
Forum Newbie
Posts: 6
Joined: Thu Sep 20, 2007 3:51 pm

Post by webcornea »

the google api is too fancy to do a simple search based on zip codes like myspace , dont you think?
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

nope - it's exactly perfect, IMO.

If you feel the syntax is heavy, you can use an abstraction library.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Have you coded anything yet?
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

Interesting... I'm building an application that needs to do the same thing. I'll have to remember this. :)
Post Reply