<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Zip Codes in Web Apps: A Tutorial on Validating Cities &amp; Calculating Distance</title>
	<atom:link href="http://www.htmlist.com/development/zip-codes-in-web-apps-a-tutorial-on-validating-cities-calculating-distance/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.htmlist.com/development/zip-codes-in-web-apps-a-tutorial-on-validating-cities-calculating-distance/</link>
	<description>A Web Development Blog by Synapse Studios</description>
	<lastBuildDate>Mon, 15 Mar 2010 03:22:38 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: anon</title>
		<link>http://www.htmlist.com/development/zip-codes-in-web-apps-a-tutorial-on-validating-cities-calculating-distance/comment-page-1/#comment-38</link>
		<dc:creator>anon</dc:creator>
		<pubDate>Tue, 01 Jul 2008 00:29:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.htmlist.com/?p=51#comment-38</guid>
		<description>you are missing a closing paren somewhere.</description>
		<content:encoded><![CDATA[<p>you are missing a closing paren somewhere.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Edgar Hassler</title>
		<link>http://www.htmlist.com/development/zip-codes-in-web-apps-a-tutorial-on-validating-cities-calculating-distance/comment-page-1/#comment-30</link>
		<dc:creator>Edgar Hassler</dc:creator>
		<pubDate>Fri, 20 Jun 2008 19:56:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.htmlist.com/?p=51#comment-30</guid>
		<description>Matthew, not really, no.  There was something like an API (required an API key and dolla dolla bills) a while ago but I don&#039;t notice it on their current site either. But thanks for reading anyway.
-Edgar</description>
		<content:encoded><![CDATA[<p>Matthew, not really, no.  There was something like an API (required an API key and dolla dolla bills) a while ago but I don&#8217;t notice it on their current site either. But thanks for reading anyway.<br />
-Edgar</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matthew Brand</title>
		<link>http://www.htmlist.com/development/zip-codes-in-web-apps-a-tutorial-on-validating-cities-calculating-distance/comment-page-1/#comment-29</link>
		<dc:creator>Matthew Brand</dc:creator>
		<pubDate>Wed, 18 Jun 2008 15:04:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.htmlist.com/?p=51#comment-29</guid>
		<description>You say &quot;Even the USPS has a “Web 2.0″-ish web service that does much of what we want&quot; but I can&#039;t seem to find a web service offered by the USPS that returns ZIP codes within a given radius.  All I can find is address/ZIP lookups.  Can you point me to the location that you found the USPS service?</description>
		<content:encoded><![CDATA[<p>You say &#8220;Even the USPS has a “Web 2.0″-ish web service that does much of what we want&#8221; but I can&#8217;t seem to find a web service offered by the USPS that returns ZIP codes within a given radius.  All I can find is address/ZIP lookups.  Can you point me to the location that you found the USPS service?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe Law</title>
		<link>http://www.htmlist.com/development/zip-codes-in-web-apps-a-tutorial-on-validating-cities-calculating-distance/comment-page-1/#comment-22</link>
		<dc:creator>Joe Law</dc:creator>
		<pubDate>Thu, 05 Jun 2008 01:03:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.htmlist.com/?p=51#comment-22</guid>
		<description>Nice article Here is a similar solution that contains a simple yet effective zip code radius search algorithm. The solution contains a Stored Procedure that accepts a zip code and mile radius and returns all zip codes within that radius. (Example: Give me all the zip codes within a 10-mile radius of 10023). The Solution comes with and a dataload script that will create a SQL Server database, the Stored Procedure containing the algorithm, and load over 42,000 zip codes.

http://www.spikesolutions.net/ViewSolution.aspx?ID=1e7d197c-7441-40f4-8e87-5ecc3ef5ab60</description>
		<content:encoded><![CDATA[<p>Nice article Here is a similar solution that contains a simple yet effective zip code radius search algorithm. The solution contains a Stored Procedure that accepts a zip code and mile radius and returns all zip codes within that radius. (Example: Give me all the zip codes within a 10-mile radius of 10023). The Solution comes with and a dataload script that will create a SQL Server database, the Stored Procedure containing the algorithm, and load over 42,000 zip codes.</p>
<p><a href="http://www.spikesolutions.net/ViewSolution.aspx?ID=1e7d197c-7441-40f4-8e87-5ecc3ef5ab60" rel="nofollow">http://www.spikesolutions.net/ViewSolution.aspx?ID=1e7d197c-7441-40f4-8e87-5ecc3ef5ab60</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brandon Ching</title>
		<link>http://www.htmlist.com/development/zip-codes-in-web-apps-a-tutorial-on-validating-cities-calculating-distance/comment-page-1/#comment-20</link>
		<dc:creator>Brandon Ching</dc:creator>
		<pubDate>Wed, 04 Jun 2008 21:59:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.htmlist.com/?p=51#comment-20</guid>
		<description>Nice post Edgar. I&#039;ve had a bit of experience with distance and mapping applications and I have to say that unless you are willing to pay for an solution, a practical system is difficult to develop. 

I think TIGER lat/lng zip code data is nice but not very useful for applications that require comparisons of distances for actual locations (i.e. stores, homes, movie theaters, etc.) from a given starting lat/lng. Most people might want to find distances from their home to the nearest drug store or even to list all drug stores within a given radius. From a development perspective, this is problematic because given a single starting point, there can be any number of target points within a certain search result set. Now throw in the variable that the start point maybe chosen at random by the user and you could be left with a very high number of point-to-point comparisons for distance. Doing these calculations on the fly is rather expensive and depending on the scale of your deployed application, even caching (MySQL or higher) can prove rather useless given the variability of start and end points. 

The ability to find a result set given a radius can be especially difficult given large data sets. It is impractical to compare the distance from every point to every other point, even if your starting lat/lng remains constant. What I have worked with and maintained in the past is the creation of a bounding box to gather all points within a given radius. It is relatively inexpensive to calculate the top, bottom, left, and right lat/lng values of given start point and to query only the points that fit within that &quot;box&quot; then calculate the distance of each. On a small scale(.5-10 mile radius), this works pretty well, but as you start to increase this distance, your result set begins to get less accurate due to the inclusion of points beyond your desired radius. The distance from the center to the top, bottom, left, and right points of the &quot;box&quot; remain accurate but as the radius distance increases the corners of the &quot;box&quot; extend further and further beyond the desired radius.

For all of the radius searches, you&#039;re looking at about 78% area accuracy (22% falls outside of the circle and into the square areas of the bounding box).  But the accuracy falls a lot more when you work with the linear distances from the center of your radius.  The distance from center, along the diagonals of the search box to one of the corners (the furthest possible point), the numbers start looking like...

radius(in miles)  &#124;  dist to box corner
0.25  &#124;  ~0.35  =&gt;   0.10 miles extra
0.50  &#124;  ~0.71  =&gt;   0.21 miles extra
0.75  &#124;  ~1.06  =&gt;   0.31 miles extra
1.00  &#124;  ~1.41  =&gt;   0.41 miles extra
1.25  &#124;  ~1.76  =&gt;   0.49 miles extra
1.50  &#124;  ~2.12  =&gt;   0.62 miles extra
1.75  &#124;  ~2.47  =&gt;   0.72 miles extra
2.00  &#124;  ~2.83  =&gt;   0.82 miles extra
2.50  &#124;  ~3.54  =&gt;   1.04 miles extra

The numbers show that the searchable radius can be, at its absolute worst, 40% off for all radius distances. Maybe this level of error is acceptable but probably not for most of us. 

This does not even include the apsect of mapping. Getting lat/lng data and distances from points of interest is good but are usually only useful when mapped for the user. Unfortunately, lat/lng data does not always correlate well with all map rendering applications. For instance, Google maps uses different map data vendors like Europa and Tele Atlas depending on if you are using their maps.google.com application or the development API. I can tell you from experience that the same lat/lng can and often DOES map differently on each. 

So in sum...just pay for it ;)</description>
		<content:encoded><![CDATA[<p>Nice post Edgar. I&#8217;ve had a bit of experience with distance and mapping applications and I have to say that unless you are willing to pay for an solution, a practical system is difficult to develop. </p>
<p>I think TIGER lat/lng zip code data is nice but not very useful for applications that require comparisons of distances for actual locations (i.e. stores, homes, movie theaters, etc.) from a given starting lat/lng. Most people might want to find distances from their home to the nearest drug store or even to list all drug stores within a given radius. From a development perspective, this is problematic because given a single starting point, there can be any number of target points within a certain search result set. Now throw in the variable that the start point maybe chosen at random by the user and you could be left with a very high number of point-to-point comparisons for distance. Doing these calculations on the fly is rather expensive and depending on the scale of your deployed application, even caching (MySQL or higher) can prove rather useless given the variability of start and end points. </p>
<p>The ability to find a result set given a radius can be especially difficult given large data sets. It is impractical to compare the distance from every point to every other point, even if your starting lat/lng remains constant. What I have worked with and maintained in the past is the creation of a bounding box to gather all points within a given radius. It is relatively inexpensive to calculate the top, bottom, left, and right lat/lng values of given start point and to query only the points that fit within that &#8220;box&#8221; then calculate the distance of each. On a small scale(.5-10 mile radius), this works pretty well, but as you start to increase this distance, your result set begins to get less accurate due to the inclusion of points beyond your desired radius. The distance from the center to the top, bottom, left, and right points of the &#8220;box&#8221; remain accurate but as the radius distance increases the corners of the &#8220;box&#8221; extend further and further beyond the desired radius.</p>
<p>For all of the radius searches, you&#8217;re looking at about 78% area accuracy (22% falls outside of the circle and into the square areas of the bounding box).  But the accuracy falls a lot more when you work with the linear distances from the center of your radius.  The distance from center, along the diagonals of the search box to one of the corners (the furthest possible point), the numbers start looking like&#8230;</p>
<p>radius(in miles)  |  dist to box corner<br />
0.25  |  ~0.35  =&gt;   0.10 miles extra<br />
0.50  |  ~0.71  =&gt;   0.21 miles extra<br />
0.75  |  ~1.06  =&gt;   0.31 miles extra<br />
1.00  |  ~1.41  =&gt;   0.41 miles extra<br />
1.25  |  ~1.76  =&gt;   0.49 miles extra<br />
1.50  |  ~2.12  =&gt;   0.62 miles extra<br />
1.75  |  ~2.47  =&gt;   0.72 miles extra<br />
2.00  |  ~2.83  =&gt;   0.82 miles extra<br />
2.50  |  ~3.54  =&gt;   1.04 miles extra</p>
<p>The numbers show that the searchable radius can be, at its absolute worst, 40% off for all radius distances. Maybe this level of error is acceptable but probably not for most of us. </p>
<p>This does not even include the apsect of mapping. Getting lat/lng data and distances from points of interest is good but are usually only useful when mapped for the user. Unfortunately, lat/lng data does not always correlate well with all map rendering applications. For instance, Google maps uses different map data vendors like Europa and Tele Atlas depending on if you are using their maps.google.com application or the development API. I can tell you from experience that the same lat/lng can and often DOES map differently on each. </p>
<p>So in sum&#8230;just pay for it ;)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
