homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

National Address Book

 6:08 pm on May 28, 2011 (gmt 0)

This post may sound a little creepy, but its not, I promise =)

When I ask my GPS for directions, the first thing I need to put in is the ZIP code. Based on the ZIP, it auto-populates the City and State fields. Then, I start typing in a street number. It does something similar to Google Suggest, and comes up with a list of addresses that match the one I started to type in.

What I'm looking for is this same thing, in a web page. Not for navigation purposes. Rather, so that my users require as few keystrokes as possible. In other words, they type in a ZIP code and the first few characters of the street address, and then all of the work is done for them.

I was thinking that this could be done utilizing the power of XML, with something like this. Am I off my rocker or is this feasible?





<name>Plymouth Ave</name>

<name>Emerson St</name>






 6:38 pm on May 28, 2011 (gmt 0)

I certainly would not store the address data as XML. A fast indexed database is essential, something SQL-powered, responding to queries generated via AJAX requests to the server.

You could deliver the search results in XML format to the client.
An alternative for easy consumption by a JavaScript autosuggest widget would be JSON.


 7:07 pm on May 28, 2011 (gmt 0)

So you would store the database like this?
TABLE address:
id | number | street ----------------| city -------| state | zip
01 | 60121 -| River Rd --------------| Anytown ----| RI ---| 12120
02 | 521 ---| Industrial Commerce Pl | Someville --| CO ---| 89071
03 | 9924 --| Elmhurst St ---------- | Exampleton -| OR ---| 62094

Once the database is established, it should be fairly simple to AJAX it in to place. But, the main question is, where will the data come from? Does such a database exist already? Who will maintain it?

Again, the idea is to reduce the number of keystrokes required to enter the data into a web form. The users of this system need to enter a large amount of data very quickly.


 7:24 pm on May 28, 2011 (gmt 0)

I wonder what the size of the database would be? With residential and business addresses included, I assume the US alone would stretch to at least 150 million entries.


 3:30 pm on May 30, 2011 (gmt 0)

I would have one column in the database for each field that the user might start entering. So, if someone is going to start by typing in a ZIP, have an indexed column with just ZIPs in it.

Then when someone is typing in the street address, you'll do queries like "SELECT * FROM addresses WHERE ZIP='50443' AND address LIKE '123 mai%' LIMIT 10", returning the matching rows results quickly to the web interface.

If you get the data separated with columns for number, street, city... then your queries will have some "OR" clauses in them.

And mind the inevitability of differences between "st", "st.", "street"... and spelling variations like "St. Mary Blvd N" and "Saint Mary Boulevard North". The canonical address you return in the autocompletion response will depend entirely on how the data is formatted.

good indexing and optimizing your queries is crucial for a fast response. You do not want any queries that require a scan of the entire table.

If you're using a pre-built autocompletion gadget, look to see how it triggers those AJAX requests. You do NOT want an AJAX request on every keyup event. The gadget should at least use some kind of throttling, but the best ones use a method called "debouncing" -- read about it here:

If the input field is a "mixed" text entry field, ie people would type "123 main street 50324 anytown KY" then you've got quite a challenge. Autocomplete may not be appropriate - or feasible - for that kind of input.

btw, I have no idea where you'd get the data. ZIP databases are easy to find, but I've never sought one with granular street addresses. Maybe the US government has something in the public domain.


 5:40 pm on May 30, 2011 (gmt 0)

There's a Google open source project to do with address formatting.

Some of that code might prove useful: [code.google.com...]


 1:28 am on Jun 14, 2011 (gmt 0)

In fact, Google Maps does precisely what I am looking for! When you go to maps.google.com and start typing in the address field, it looks for known addresses that match what you are typing. Is there a way to query the Gmaps API to emulate this on my website?

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved