Part II: Simple example of shading zip-code boundaries using Virtual Earth

In the original article, I showed an example of plotting zip-code boundaries using Microsoft Virtual Earth and Ajax.Net.  I received some feedback from John (SoulSolutions) suggesting that the transmission of latitude and longitude points could be optimized by using googles compression algorithm (described here) which exploits that fact that lat/lons can benefit from compression when there is little difference between adjacent lat/longs within a given sequence.  I thought this was an interesting suggestion so I updated the example to include this compression algorithm.  Here is the rundown of the changes that I made:

  1. The ZipCodeService now returns an encoded string of lat/lons instead of the original format that had the individual lat/lons comma separated and the pair pipe separated
  2. The ZipCode.js file now contains a routine that decodes the result from the ZipCodeService and builds a VELatLong array from the decoded points
  3. I pulled over the javascript/C# source provided by John for encoding/decoding the points. 

Download Code

I used fiddler to check-out the difference in the payloads between the 4 sample zip-code datasets I was using - here are the results. 

 Zip-Code Content-Length With Encoding Content-Length Without
 32224  260  1066
 32246  197  823
 58103  254  1215
 58104  404  1820
     

Here is a sample transmission for the 32224 zip-code

Encoded Transmission

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/7.0
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Sun, 20 May 2007 13:52:50 GMT
Content-Length: 260

"w~`xDf{dpNSsq@cQkdA??rIcBjW{YvQgYrIiY~dAsDcGhJbGzJzYk\\fJrIoFfJfYjMrSzTRgTgT_NkH{Tv[wLnKoA??RdkAjnAe@?vVni@i@rX}HnFoFbLkRkCkH??vV_D~a@rI??Sve@v|AeB??fr@hh@vBzh@s{@ncCzTr`AcrA`t@k\\d`@sIn}@f@l_@fEdV??oeBzOs]nPwj@rb@ka@z@_DalJ~p@iHvLw`@kW{Eox@{@ksAf@_eAbGo_@{J"

Un-encoded Transmission

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/7.0
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Sun, 20 May 2007 13:51:36 GMT
Content-Length: 1066

"30.2582, -81.4721|30.3206, -81.4586|30.3207, -81.4505|30.3236, -81.4394|30.3236, -81.4394|30.3219, -81.4389|30.318, -81.4346|30.315, -81.4304|30.3133, -81.4262|30.3021, -81.4253|30.3034, -81.4271|30.3021, -81.429|30.2978, -81.4243|30.296, -81.426|30.2972, -81.4278|30.293, -81.4301|30.2897, -81.4336|30.2896, -81.4302|30.293, -81.4278|30.2945, -81.4243|30.2899, -81.4221|30.2879, -81.4217|30.2879, -81.4217|30.2878, -81.4339|30.2751, -81.4337|30.2751, -81.4375|30.2683, -81.4373|30.2642, -81.4357|30.263, -81.4345|30.2609, -81.4314|30.2616, -81.4299|30.2616, -81.4299|30.2578, -81.4291|30.2522, -81.4308|30.2522, -81.4308|30.2523, -81.437|30.2373, -81.4365|30.2373, -81.4365|30.2291, -81.4431|30.2285, -81.4498|30.2382, -81.471|30.2347, -81.4815|30.248, -81.49|30.2527, -81.4953|30.2544, -81.5053|30.2542, -81.5105|30.2532, -81.5142|30.2532, -81.5142|30.2696, -81.5169|30.2745, -81.5197|30.2815, -81.5254|30.287, -81.5257|30.2878, -81.4673|30.2798, -81.4658|30.2776, -81.4604|30.2815, -81.4593|30.2907, -81.459|30.3042, -81.4592|30.3154, -81.4605|30.3206, -81.4586"


TrackBack

TrackBack URL for this entry:
http://mattberseth.com/blog-mt/mt-tb.fcgi/22

Listed below are links to weblogs that reference Part II: Simple example of shading zip-code boundaries using Virtual Earth:

» Part II: Simple example of shading zip-code boundaries using Virtual E from DotNetKicks.com
You've been kicked (a good thing) - Trackback from DotNetKicks.com [Read More]

» August 2nd Links: ASP.NET AJAX and the ASP.NET AJAX Control Toolkit from ScottGu's Blog
Here is the latest in my semi-regular link-listing series . Today's links are all about ASP.NET AJAX [Read More]

» August 2nd Links: ASP.NET AJAX and the ASP.NET AJAX Control Toolkit from ASP.Net Resources
Here is the latest in my semi-regular link-listing series . Today's links are all about ASP.NET AJAX [Read More]

Comments


Posted by: joseph on November 21, 2007 12:00 AM

hi , i want to get zip code boundary on entering any US zip code. please help .......

Is there a way to buy the latest zip code boundary data in the US?
My data is around 5 years old.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Consulting Services

Yep - I also offer consulting services. And heck, I'll do just about anything. If you enjoy my blog just drop me an email describing the work you need done.

Recent Comments

  • Josh wrote: Is there a way to buy the latest zip code boundary data in the US? My data is around 5 years old. ...
  • joseph wrote: hi , i want to get zip code boundary on entering any US zip code. please help ....... ...