Parsing location string
I'm trying to guess the location (non US; could be street, postal code, neighborhood or city)
The user typed 开发者_JAVA技巧in a search box and I was wondering if you guys could give me some tips on how to go about this.
I currently have a 5 tables in my database:
Address (address and postal code fields)
Neighborhoods (neighborhood field)
Cities (city field)
States (abbreviation and state fields)
Countries (only one row at the moment, so I'd just ignore it)
The only fields I know the format would be state abbreviations which would be two chars and postal codes that would be 00000-000 or 00000000.
How would I deal with duplicate postal codes, addresses, neighborhoods and city names?
I know I could go the Gmaps route but I'm thinking it wouldn't play very nice with my database set..
What do you guys suggest?
You will get into troubles reinventing the wheel.
I would use Geocoder implementation for this problem, see this tutorial http://www.phpriot.com/articles/google-maps-geocoding/6
精彩评论