<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Vishful thinking...</title>
	<atom:link href="http://viswaug.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://viswaug.wordpress.com</link>
	<description>Journey of a .NET GIS developer</description>
	<lastBuildDate>Fri, 20 Jan 2012 17:55:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='viswaug.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Vishful thinking...</title>
		<link>http://viswaug.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://viswaug.wordpress.com/osd.xml" title="Vishful thinking..." />
	<atom:link rel='hub' href='http://viswaug.wordpress.com/?pushpress=hub'/>
		<item>
		<title>MBTilesViewer</title>
		<link>http://viswaug.wordpress.com/2011/06/28/mbtilesviewer/</link>
		<comments>http://viswaug.wordpress.com/2011/06/28/mbtilesviewer/#comments</comments>
		<pubDate>Tue, 28 Jun 2011 22:26:28 +0000</pubDate>
		<dc:creator>viswaug</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ArcGIS]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[ESRI]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[Utilities]]></category>

		<guid isPermaLink="false">http://viswaug.wordpress.com/?p=711</guid>
		<description><![CDATA[I also created this bare bones MBTiles cache viewer to view the tile cache in MBTiles format. This application does not do much, just display the tilecache on a map. To view a MBTiles file, just fire up the viewer and start dragging and dropping MBTiles cache files on to it. You can drag and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=viswaug.wordpress.com&amp;blog=1059993&amp;post=711&amp;subd=viswaug&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I also created this bare bones MBTiles cache viewer to view the tile cache in MBTiles format. This application does not do much, just display the tilecache on a map. To view a MBTiles file, just fire up the viewer and start dragging and dropping MBTiles cache files on to it. You can drag and drop multiple MBTiles cache files at the same time if needed. And also, you can create MBTile caches with the <a title="TileCutter" href="http://viswaug.wordpress.com/2011/06/28/tilecutter-update-with-support-for-osm-and-wms-map-services/" target="_blank">TileCutter</a>. The viewer was created using the <a title="ESRI WPF Map Control" href="http://resources.arcgis.com/content/arcgis-api-silverlightwpf/1.2/about" target="_blank">ESRI WPF map control</a>. If you would like to see this viewer do more, let me know <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a title="MBTilesViewer" href="http://www.box.net/shared/e9pozshoovoy81ftp9yk" target="_blank">MBTilesViewer can be downloaded here.</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/viswaug.wordpress.com/711/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/viswaug.wordpress.com/711/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/viswaug.wordpress.com/711/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/viswaug.wordpress.com/711/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/viswaug.wordpress.com/711/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/viswaug.wordpress.com/711/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/viswaug.wordpress.com/711/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/viswaug.wordpress.com/711/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/viswaug.wordpress.com/711/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/viswaug.wordpress.com/711/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/viswaug.wordpress.com/711/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/viswaug.wordpress.com/711/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/viswaug.wordpress.com/711/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/viswaug.wordpress.com/711/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=viswaug.wordpress.com&amp;blog=1059993&amp;post=711&amp;subd=viswaug&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://viswaug.wordpress.com/2011/06/28/mbtilesviewer/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cde0d8ca836f3c2d78087cb8a5bd593e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">viswaug</media:title>
		</media:content>
	</item>
		<item>
		<title>TileCutter update &#8211; With support for OSM and WMS map services</title>
		<link>http://viswaug.wordpress.com/2011/06/28/tilecutter-update-with-support-for-osm-and-wms-map-services/</link>
		<comments>http://viswaug.wordpress.com/2011/06/28/tilecutter-update-with-support-for-osm-and-wms-map-services/#comments</comments>
		<pubDate>Tue, 28 Jun 2011 22:16:39 +0000</pubDate>
		<dc:creator>viswaug</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ArcGIS]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[ESRI]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[Utilities]]></category>

		<guid isPermaLink="false">http://viswaug.wordpress.com/?p=705</guid>
		<description><![CDATA[I just added support for creating MBTiles caches for WMS map services and also to download OSM tiles into the MBTiles format. MBTiles cache for WMS map services would improve map rendering performance, but why did i add support for OSM tile sets? Well, they will come in handy for disconnected/offline use cases. So, here [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=viswaug.wordpress.com&amp;blog=1059993&amp;post=705&amp;subd=viswaug&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I just added support for creating MBTiles caches for WMS map services and also to download OSM tiles into the MBTiles format. MBTiles cache for WMS map services would improve map rendering performance, but why did i add support for OSM tile sets? Well, they will come in handy for disconnected/offline use cases. So, here are some usage examples</p>
<p><strong>ArcGIS Dynamic Map Service:</strong></p>
<blockquote><p>TileCutter.exe -z=7 -Z=9 -x=-95.844727 -y=35.978006 -X=-88.989258 -Y=40.563895 -o=&#8221;C:\LocalCache\ags.s3db&#8221; -t=<strong>agsd</strong> -m=&#8221;http://server.arcgisonline.com/ArcGIS/rest/services/I3_Imagery_Prime_World_2D/MapServer&#8221;</p></blockquote>
<p><strong>WMS Map Service 1.1.1:</strong></p>
<blockquote><p>TileCutter.exe -z=7 -Z=9 -x=-95.844727 -y=35.978006 -X=-88.989258 -Y=40.563895 -o=&#8221;C:\LocalCache\wms111.s3db&#8221; -t=<strong>wms1.1.1</strong> -m=&#8221;http://sampleserver1-350487546.us-east-1.elb.amazonaws.com/ArcGIS/services/Specialty/ESRI_StateCityHighway_USA/MapServer/WMSServer&#8221;</p></blockquote>
<p><strong>WMS Map Service 1.3.0:</strong></p>
<blockquote><p>TileCutter.exe -z=7 -Z=9 -x=-95.844727 -y=35.978006 -X=-88.989258 -Y=40.563895 -o=&#8221;C:\LocalCache\wms130.s3db&#8221; -t=<strong>wms1.3.0</strong> -m=&#8221;http://sampleserver1-350487546.us-east-1.elb.amazonaws.com/ArcGIS/services/Specialty/ESRI_StateCityHighway_USA/MapServer/WMSServer&#8221;</p></blockquote>
<p><strong>OSM:</strong></p>
<blockquote><p>TileCutter.exe -z=7 -Z=9 -x=-95.844727 -y=35.978006 -X=-88.989258 -Y=40.563895 -o=&#8221;C:\LocalCache\osm.s3db&#8221; -t=<strong>osm</strong> -m=&#8221;http://tile.openstreetmap.org&#8221;</p></blockquote>
<p>And always just type &#8220;TileCutter -h&#8221; for usage information.</p>
<p>Want to customize the parameters with which the maps are being generated? Just use the &#8220;-s&#8221; command line option ans specify the setting in a query string format.</p>
<blockquote><p>TileCutter.exe -z=7 -Z=9 -x=-95.844727 -y=35.978006 -X=-88.989258 -Y=40.563895 -o=&#8221;C:\LocalCache\ags.s3db&#8221; -t=agsd -m=&#8221;http://server.arcgisonline.com/ArcGIS/rest/services/I3_Imagery_Prime_World_2D/MapServer&#8221; <strong>-s=&#8221;transparent=true&amp;format=jpeg&#8221;</strong></p></blockquote>
<p>Also, if some of the tile requests result in errors, the level, column, row and error message information would be logged into a text file in the same directory as the MBTiles cache.</p>
<p>And now, for the best new feature of TileCutter, the program does not store duplicate tiles. That is, if the area you are caching has a lot of empty tiles in the ocean etc, the MBTiles cache created by TileCutter will only store one tile for all those duplicated tile images. Should help save disk space <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a title="TileCutter" href="http://www.box.net/shared/s2hso12crexjr0h49yc1" target="_blank">TileCutter can be downloaded here</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/viswaug.wordpress.com/705/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/viswaug.wordpress.com/705/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/viswaug.wordpress.com/705/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/viswaug.wordpress.com/705/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/viswaug.wordpress.com/705/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/viswaug.wordpress.com/705/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/viswaug.wordpress.com/705/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/viswaug.wordpress.com/705/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/viswaug.wordpress.com/705/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/viswaug.wordpress.com/705/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/viswaug.wordpress.com/705/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/viswaug.wordpress.com/705/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/viswaug.wordpress.com/705/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/viswaug.wordpress.com/705/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=viswaug.wordpress.com&amp;blog=1059993&amp;post=705&amp;subd=viswaug&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://viswaug.wordpress.com/2011/06/28/tilecutter-update-with-support-for-osm-and-wms-map-services/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cde0d8ca836f3c2d78087cb8a5bd593e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">viswaug</media:title>
		</media:content>
	</item>
		<item>
		<title>TileCutter &#8211; A small utility to generate tile cache in the MBTiles format from ArcGIS Dynamic Map Services</title>
		<link>http://viswaug.wordpress.com/2011/06/12/tilecutter-a-small-utility-to-generate-tile-cache-in-the-mbtiles-format-from-arcgis-dynamic-map-services/</link>
		<comments>http://viswaug.wordpress.com/2011/06/12/tilecutter-a-small-utility-to-generate-tile-cache-in-the-mbtiles-format-from-arcgis-dynamic-map-services/#comments</comments>
		<pubDate>Sun, 12 Jun 2011 23:25:56 +0000</pubDate>
		<dc:creator>viswaug</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[ESRI]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://viswaug.wordpress.com/?p=694</guid>
		<description><![CDATA[Thought I would share a little utility I had written up to generate tile caches in the MBTiles format for ArcGIS Dynamic Map Services. The MBTiles cache format is very simple and makes moving caches between machines very easy since you just have to transfer one file instead of the thousands of files that need [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=viswaug.wordpress.com&amp;blog=1059993&amp;post=694&amp;subd=viswaug&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Thought I would share a little utility I had written up to generate tile caches in the <a title="MBTiles" href="http://mbtiles.org/" target="_blank">MBTiles </a>format for ArcGIS Dynamic Map Services. The <a title="MBTiles" href="http://mbtiles.org/" target="_blank">MBTiles </a>cache format is very simple and makes moving caches between machines very easy since you just have to transfer one file instead of the thousands of files that need to be copied for normal tile caches. The TileCutter is a console utility and accepts the scale range and the extent in <strong>latitude/longitude</strong> for which the cache should be generated. It also takes a few other options listed below.</p>
<blockquote>
<pre>Options:
  -h, --help                 Show this message and exits
  -m, --mapservice=VALUE     Url of the ArcGIS Dynamic Map Service to be
                               cached
  -o, --output=VALUE         Location on disk where the tile cache will be
                               stored
  -z, --minz=VALUE           Minimum zoom scale at which to begin caching
  -Z, --maxz=VALUE           Maximum zoom scale at which to end caching
  -x, --minx=VALUE           Minimum X coordinate value of the extent to cache
  -y, --miny=VALUE           Minimum Y coordinate value of the extent to cache
  -X, --maxx=VALUE           Maximum X coordinate value of the extent to cache
  -Y, --maxy=VALUE           Maximum Y coordinate value of the extent to cache
  -p, --parallelops=VALUE    Limits the number of concurrent operations run
                               by TileCutter
  -r, --replace=VALUE        Delete existing tile cache MBTiles database if
                               already present and create a new one.</pre>
</blockquote>
<p>Example Usage:</p>
<p>To just try it out, just run TileCutter.exe, it will download tiles for some default extents from an ESRI sample server</p>
<blockquote><p>TileCutter -z=7 -Z=10 -x=-95.844727 -y=35.978006 -X=-88.989258 -Y=40.563895 -o=&#8221;C:\LocalCache&#8221; -m=&#8221;http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer&#8221;</p></blockquote>
<p>The TileCutter does request tiles in parallel threads and allows to you controls the number of concurrent operations. I don&#8217;t want to write too much about it yet since i am still working to add more capabilities to it. I am planning on providing the ability to generate <a title="MBTiles" href="http://mbtiles.org/" target="_blank">MBTile </a>caches for WMS services, OSM tiles etc in the future and more if there is interest. Also, planning on implementing  a way to avoid storing duplicate tiles(for example, empty tiles in the ocean etc). I just wanted to get the tool out there early to get feedback and guage interest. So, if you have queries/interest/feature requests, let me know <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Also, I will blog about a little piece of code for a IHttpHandler that will serve up the MBTiles to web clients pretty soon. Stay tuned&#8230;</p>
<p><a title="TileCutter" href="http://www.box.net/shared/s2hso12crexjr0h49yc1" target="_blank">TileCutter can be download here.</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/viswaug.wordpress.com/694/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/viswaug.wordpress.com/694/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/viswaug.wordpress.com/694/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/viswaug.wordpress.com/694/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/viswaug.wordpress.com/694/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/viswaug.wordpress.com/694/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/viswaug.wordpress.com/694/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/viswaug.wordpress.com/694/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/viswaug.wordpress.com/694/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/viswaug.wordpress.com/694/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/viswaug.wordpress.com/694/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/viswaug.wordpress.com/694/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/viswaug.wordpress.com/694/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/viswaug.wordpress.com/694/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=viswaug.wordpress.com&amp;blog=1059993&amp;post=694&amp;subd=viswaug&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://viswaug.wordpress.com/2011/06/12/tilecutter-a-small-utility-to-generate-tile-cache-in-the-mbtiles-format-from-arcgis-dynamic-map-services/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cde0d8ca836f3c2d78087cb8a5bd593e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">viswaug</media:title>
		</media:content>
	</item>
		<item>
		<title>Moving away from the javascript module pattern</title>
		<link>http://viswaug.wordpress.com/2011/03/02/moving-away-from-the-javascript-module-pattern/</link>
		<comments>http://viswaug.wordpress.com/2011/03/02/moving-away-from-the-javascript-module-pattern/#comments</comments>
		<pubDate>Wed, 02 Mar 2011 02:45:16 +0000</pubDate>
		<dc:creator>viswaug</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://viswaug.wordpress.com/?p=684</guid>
		<description><![CDATA[A while ago I had written about using the javascript module pattern to organize code a little better. But off late, I have moved away from using the module pattern because of some reasons which i will outline below. But the pattern to use is really a matter of preference in my opinion. I have [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=viswaug.wordpress.com&amp;blog=1059993&amp;post=684&amp;subd=viswaug&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A while ago I had written about using the <a href="http://viswaug.wordpress.com/2008/11/19/writing-better-javascript-part-5/" target="_blank">javascript module pattern</a> to organize code a little better. But off late, I have moved away from using the module pattern because of some reasons which i will outline below. But the pattern to use is really a matter of preference in my opinion. I have now gone back to basics and am using the javascript prototype pattern and have been loving it. Here is why i made the switch</p>
<blockquote>
<ul>
<li>the &#8216;this&#8217; keyword in my class method means what I really expect/want it to mean</li>
<li>creating multiple instances of my class doesn&#8217;t consume more memory for creating more function instances since all instances use the functions on the prototype</li>
<li>the &#8216;instanceof&#8217; operator can be used to determine if any object is an instance of the class</li>
</ul>
</blockquote>
<p>Here is a simple example illustrating how to create a class. The snippet below creates a class called &#8216;MyClass&#8217; with the &#8216;getOption&#8217;, &#8216;calculatePay&#8217;, &#8216;getDisplayPay&#8217; methods.</p>
<blockquote>
<pre><span style="font-family:monospace;"><span class="oper">function</span> <span class="func">MyClass</span>(<span class="var">options</span>) {//constructor</span>
<code>  <span class="var">this</span>.<span class="var">options</span> <span class="oper">=</span> <span class="var">options</span>;
};

<span class="var">MyClass</span>.<span class="var">prototype</span>.<span class="var">getOption</span> <span class="oper">=</span> <span class="oper">function</span>(<span class="var">name</span>) {
  <span class="oper">return</span> <span class="var">this</span>.<span class="var">options</span>[<span class="var">name</span>];
};

<span class="var">MyClass</span>.<span class="var">prototype</span>.<span class="var">calculatePay</span> <span class="oper">=</span> <span class="oper">function</span>(<span class="var">hours</span>) {
  <span class="oper">return</span> <span class="var">hours</span> <span class="oper">*</span> <span class="var">this</span>.<span class="var">options</span>['<span class="string">hourlyRate</span>'];
};

<span class="var">MyClass</span>.<span class="var">prototype</span>.<span class="var">getDisplayPay</span> <span class="oper">=</span> <span class="oper">function</span>(<span class="var">hours</span>) {
  <span class="oper">return</span> <span class="var">this</span>.<span class="func">getOption</span>('<span class="string">name</span>') <span class="oper">+</span> "<span class="string"> - </span>" <span class="oper">+</span> <span class="var">this</span>.<span class="func">calculatePay</span>(<span class="var">hours</span>);
};
</code></pre>
</blockquote>
<p>To create an instance of the class above</p>
<blockquote><p>var inst = new MyClass({&#8216;name&#8217; : &#8217;Jeff&#8217;, &#8217;hourlyRate&#8217; : 1000});</p></blockquote>
<p>Also, the following works too</p>
<blockquote><p>inst.constructor === MyClass; //returns true</p>
<p>if( inst instanceof MyClass ) //evaluates to true</p></blockquote>
<p>Pretty simple and sweet. Here are a couple of examples of classes written like above</p>
<p style="text-align:center;"><a href="http://vishfulthinking.appspot.com/static/js/g2kml.js" target="_blank">g2kml</a></p>
<p style="text-align:center;"><a href="http://vishfulthinking.appspot.com/static/js/g2geojson.js" target="_blank">g2geojson</a></p>
<p>I am also using the standalone <a href="http://yuilibrary.com/yuitest/" target="_blank">YUITest for unit testing</a> javascript which doesn&#8217;t require the <a href="http://developer.yahoo.com/yui/" target="_blank">YUI framework</a> which looks more attractive in <a href="http://developer.yahoo.com/yui/3/" target="_blank">YUI3</a>. It was a very close call between YUITest and QUnit for the unit testing framework. I went with YUITest because it came with Selenium drivers</p>
<p style="text-align:center;"><a href="http://vishfulthinking.appspot.com/static/tests/g2kmlTests.html" target="_blank">YUITest example for g2kml</a></p>
<p style="text-align:center;"><a href="http://vishfulthinking.appspot.com/static/tests/g2geojsonTests.html" target="_blank">YUITest example for g2geojson</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/viswaug.wordpress.com/684/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/viswaug.wordpress.com/684/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/viswaug.wordpress.com/684/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/viswaug.wordpress.com/684/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/viswaug.wordpress.com/684/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/viswaug.wordpress.com/684/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/viswaug.wordpress.com/684/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/viswaug.wordpress.com/684/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/viswaug.wordpress.com/684/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/viswaug.wordpress.com/684/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/viswaug.wordpress.com/684/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/viswaug.wordpress.com/684/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/viswaug.wordpress.com/684/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/viswaug.wordpress.com/684/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=viswaug.wordpress.com&amp;blog=1059993&amp;post=684&amp;subd=viswaug&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://viswaug.wordpress.com/2011/03/02/moving-away-from-the-javascript-module-pattern/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cde0d8ca836f3c2d78087cb8a5bd593e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">viswaug</media:title>
		</media:content>
	</item>
		<item>
		<title>Digging a little deeper into Google Fusion Tables &#8211; A technical GIS perspective</title>
		<link>http://viswaug.wordpress.com/2011/02/14/digging-a-little-deeper-into-google-fusion-tables-a-technical-gis-perspective/</link>
		<comments>http://viswaug.wordpress.com/2011/02/14/digging-a-little-deeper-into-google-fusion-tables-a-technical-gis-perspective/#comments</comments>
		<pubDate>Mon, 14 Feb 2011 22:23:01 +0000</pubDate>
		<dc:creator>viswaug</dc:creator>
				<category><![CDATA[GIS]]></category>

		<guid isPermaLink="false">http://viswaug.wordpress.com/?p=669</guid>
		<description><![CDATA[Before I start getting into too much details about Google Fusion Tables, I will provide a link out to Google Fusion Tables. If you haven&#8217;t heard/played around with it yet, i would strongly encourage that you take a little time to do so. It will definitely not disappoint you and is definitely worth the time. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=viswaug.wordpress.com&amp;blog=1059993&amp;post=669&amp;subd=viswaug&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Before I start getting into too much details about Google Fusion Tables, I will provide a link out to <a href="http://tables.googlelabs.com" target="_blank">Google Fusion Tables</a>. If you haven&#8217;t heard/played around with it yet, i would strongly encourage that you take a little time to do so. It will definitely not disappoint you and is definitely worth the time. It is still in &#8216;Beta&#8217;, but it is looking good.</p>
<p>The &#8216;Map&#8217; and the &#8216;Intensity Map&#8217; visualization of the table data should be of special interest to all the GIS folks. It makes the process of mapping data real easy. The &#8216;Location&#8217; field type in Fusion Tables supports both street address strings and KML string representation of geometries. The street addresses entered into the location field get automatically geocoded and are viewable on the map visualization.</p>
<blockquote>
<ul>
<li><span style="color:#800000;">Even though the documentation doesn&#8217;t explicitly state it, the Location field supports the &#8216;</span><a href="http://code.google.com/apis/kml/documentation/kmlreference.html#multigeometry" target="_blank"><span style="color:#800000;">MultiGeometry</span></a><span style="color:#800000;">&#8216; representation in it&#8217;s Location field alongside the Point, LineString and the Polygon representations</span></li>
<li><span style="color:#800000;">This might be pretty obvious, but it supports only the WGS 84 Geographic coordinate system just like KML. </span></li>
</ul>
</blockquote>
<p>The map visualization also currently simple thematic rendering of maps based on certain column values. Some of the documentation on how to acheive it and available options are not very easy to find. So, I thought <a href="http://www.google.com/support/fusiontables/bin/answer.py?answer=185991" target="_blank">a link to the documentation</a> might help later. The <a href="http://www.google.com/fusiontables/DataSource?dsrcid=308519" target="_blank">list</a> of the available <a href="http://www.google.com/fusiontables/DataSource?snapid=99003" target="_blank">map markers are here</a>. There are also a very good collection of publicly available data on Fusion Tables also. Check out the <a href="http://www.google.com/support/fusiontables/bin/answer.py?answer=1182141&amp;cbid=lahf2mcned64&amp;src=cb&amp;lev=%20index" target="_blank">USA State and County boundaries</a> here. There is also a wealth of other information out there already on Fusion Tables that are publicly available and can be easily location with a simple search. You can also upload &#8216;.csv&#8217;, &#8216;.kml&#8217;, spreadsheet files to Fusion Tables. The &#8216;<a href="http://shpescape.com/" target="_blank">ShpEscape</a>&#8216; site also allows us to upload &#8216;.shp&#8217; files to Fusion Tables. Once uploaded, data can simply be shared via an URL rather than emailing &#8216;.shp&#8217; files around as attachments. Government agencies are also taking to Fusion Tables. Check out data from <a href="http://soils.usda.gov/" target="_blank">USDA NRCS</a>, <a href="http://data.ca.gov/" target="_blank">State of California</a> and <a href="http://blog.thematicmapping.org/2011/02/natural-earth-vectors-in-cloud.html" target="_blank">Natural Earth Vector data</a>. I am hoping that the list gets bigger. Apart from just sharing data, it allows us to easily apply different chart visualizations to the data to glean useful trends and analytics for better informed decision making. Pretty powerful tools to unleash the power of data.</p>
<p>Fusion Tables also allows us to merge/join two tables in Fusion Tables based on a shared key. Fusion Tables also allows us to create views from base tables where only a filtered list of rows or columns are visible.</p>
<blockquote><p><span style="color:#800000;">The views feature in Fusion Tables enables us to set user permissions based on columns and rows. To accomplish this, keep the base table private and create views that display only a filtered set of rows or columns. Now, the views alone can be shared with users. Users get access to different views as per their permission set.</span></p></blockquote>
<p>The Google Fusion Tables also provides a <a href="http://code.google.com/apis/fusiontables/docs/developers_guide.html" target="_blank">simple and powerful API</a> over HTTP to administer and manage your data in Fusion Tables. Public tables can be easily managed via simple HTTP requests to Fusion Tables identifying the table. Private tables can also be managed pretty easily using OAuth authenticated requests. The API does have some missing features also. The major one being that Fusion Tables does not support &#8216;OR&#8217; queries. This missing functionality arises from the fact that Fusion Tables is built on top of Google&#8217;s DataStore.</p>
<blockquote>
<ul>
<li><span style="color:#800000;">Views cannot be created from Merged tables, but only from base tables</span></li>
<li><span style="color:#800000;">The resulting data from querying data from Fusion Tables is a comma delimited list of field values. Text column values are not normally not inside quotes unless they contain commas as a part of their field value. The Location field values are returned as KML string representations and they can contain commas in them. So, beware of this return format which throws a monkey wrench into the code needed for splitting the field values from the Fusion Tables response.</span></li>
</ul>
</blockquote>
<p>Google maps api v3 also <a href="http://code.google.com/apis/maps/documentation/javascript/overlays.html#FusionTables" target="_blank">supports displaying Fusion Tables data as overlays</a>. The maps api pop-up bubble can be customized via Fusion Tables using any built-in templates or by providing custom HTML templates. The data being displayed on the map can also be filtered by providing a query string.</p>
<blockquote>
<ul>
<li><span style="color:#800000;">Note that the </span><a href="http://code.google.com/apis/maps/documentation/javascript/overlays.html#FusionTablesQueries" target="_blank"><span style="color:#800000;">Fusion Tables query</span></a><span style="color:#800000;"> used in the maps api does not like queries of the type &#8216;Select * FROM&#8217;. It doesn&#8217;t like the &#8216;*&#8217; and requires a column name to be specified</span></li>
<li><span style="color:#800000;">All Fusion Tables layers on the map get drawn on the map as a single overlay. That is, even if you have 10 Fusion Tables layers added to your google map, the api does not make &#8216;n&#8217; tile requests for the 10 layers individually making the number of images being requested n*10, but the api only request &#8216;n&#8217; tiles for all the Fusion Tables layers. This is just like how KML layers are handled in the maps api.</span></li>
</ul>
</blockquote>
<p>Fusion Tables does cluster your data into points on the map automatically at high scale levels. There are also some data serialization limits built-in to the Fusion Tables API. There is currently no way to display private Fusion Tables data overlayed in the google maps api v3. But that feature is supposed to be coming for google maps premier customer. I have submitted a list of Feature Requests (see below) with the Fusion Tables team, please star them if you would like to see them also.</p>
<blockquote>
<ul>
<li><a href="http://code.google.com/p/fusion-tables/issues/detail?id=72&amp;q=vish&amp;colspec=ID%20Type%20Status%20Summary%20Stars%20Component" target="_blank">Enable mapping private fusion tables with the FusionTablesLayer in the maps API</a></li>
<li><a href="http://code.google.com/p/fusion-tables/issues/detail?id=110&amp;q=vish&amp;colspec=ID%20Type%20Status%20Summary%20Stars%20Component" target="_blank">Need reporting feature in Fusion Tables</a></li>
<li><a href="http://code.google.com/p/fusion-tables/issues/detail?id=249&amp;q=vish&amp;colspec=ID%20Type%20Status%20Summary%20Stars%20Component" target="_blank">Would like ability to run multiple queries in single request</a></li>
<li><a href="http://code.google.com/p/fusion-tables/issues/detail?id=32&amp;q=vish&amp;colspec=ID%20Type%20Status%20Summary%20Stars%20Component">Data projection</a></li>
<li><a href="http://code.google.com/p/fusion-tables/issues/detail?id=277&amp;q=vish&amp;colspec=ID%20Type%20Status%20Summary%20Stars%20Component">Create MERGED Tables Views through the API</a></li>
<li><a href="http://code.google.com/p/fusion-tables/issues/detail?id=290" target="_blank">need ability to set table map styles thru the api</a></li>
</ul>
</blockquote>
<p>That said, Fusion Tables is teh awesome.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/viswaug.wordpress.com/669/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/viswaug.wordpress.com/669/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/viswaug.wordpress.com/669/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/viswaug.wordpress.com/669/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/viswaug.wordpress.com/669/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/viswaug.wordpress.com/669/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/viswaug.wordpress.com/669/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/viswaug.wordpress.com/669/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/viswaug.wordpress.com/669/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/viswaug.wordpress.com/669/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/viswaug.wordpress.com/669/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/viswaug.wordpress.com/669/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/viswaug.wordpress.com/669/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/viswaug.wordpress.com/669/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=viswaug.wordpress.com&amp;blog=1059993&amp;post=669&amp;subd=viswaug&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://viswaug.wordpress.com/2011/02/14/digging-a-little-deeper-into-google-fusion-tables-a-technical-gis-perspective/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cde0d8ca836f3c2d78087cb8a5bd593e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">viswaug</media:title>
		</media:content>
	</item>
		<item>
		<title>Well Known Text (WKT) representation for MultiPoint</title>
		<link>http://viswaug.wordpress.com/2011/02/13/well-known-text-wkt-representation-for-multipoint/</link>
		<comments>http://viswaug.wordpress.com/2011/02/13/well-known-text-wkt-representation-for-multipoint/#comments</comments>
		<pubDate>Sun, 13 Feb 2011 02:24:36 +0000</pubDate>
		<dc:creator>viswaug</dc:creator>
				<category><![CDATA[GIS]]></category>
		<category><![CDATA[SQL Server 2008]]></category>

		<guid isPermaLink="false">http://viswaug.wordpress.com/?p=663</guid>
		<description><![CDATA[Adding to my experience with Oracle from the last post. Turns out that the &#8216;Well Known Text&#8217; (WKT) representation of MultiPoint geometries differs between Oracle and MS SQL Server,MySQL. Consider the &#8216;STMPointFromText&#8216; method in MS SQL Server, the representation of the MultiPoint geometry it expects is like the example shown below. MULTIPOINT(-122.360 47.656, -122.343 47.656) [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=viswaug.wordpress.com&amp;blog=1059993&amp;post=663&amp;subd=viswaug&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Adding to my experience with Oracle from the last post. Turns out that the &#8216;Well Known Text&#8217; (WKT) representation of MultiPoint geometries differs between Oracle and MS SQL Server,MySQL. Consider the &#8216;<a href="http://msdn.microsoft.com/en-us/library/bb933997.aspx" target="_blank">STMPointFromText</a>&#8216; method in MS SQL Server, the representation of the MultiPoint geometry it expects is like the example shown below.</p>
<blockquote>
<pre><span style="color:#800000;">MULTIPOINT(-122.360 47.656, -122.343 47.656)</span></pre>
</blockquote>
<p>As you can see, the Latitude &amp; Longitudes are separated by a space and the coordinate pairs are separated by a comma and that&#8217;s it. Here is how Oracle expects the WKT for a MultiPoint geometry to be represented.</p>
<blockquote>
<pre><span style="color:#800000;">MULTIPOINT((-122.360 47.656), (-122.343 47.656))</span></pre>
</blockquote>
<p>Oracle expects the coordinate pairs to also be enclosed with parenthesis. <a href="http://en.wikipedia.org/wiki/Well-known_text" target="_blank">Wikipedia</a> seems to agree with the Oracle representation also. Apparently, the initial OGC specifications were not clear and the community started using the first representation for MultiPoint geometries. Some of the .NET GIS libraries I work with use the first version of the MultiPoint geometry WKT. But OGC has clarified the specifications and accordingly, the second version used by Oracle is the correct one. MS SQL Server and MySQL use the first version of the MultiPoint geometry WKT. This has turned out to be a pain for us and probably for other gis developers out there also.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/viswaug.wordpress.com/663/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/viswaug.wordpress.com/663/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/viswaug.wordpress.com/663/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/viswaug.wordpress.com/663/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/viswaug.wordpress.com/663/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/viswaug.wordpress.com/663/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/viswaug.wordpress.com/663/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/viswaug.wordpress.com/663/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/viswaug.wordpress.com/663/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/viswaug.wordpress.com/663/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/viswaug.wordpress.com/663/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/viswaug.wordpress.com/663/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/viswaug.wordpress.com/663/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/viswaug.wordpress.com/663/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=viswaug.wordpress.com&amp;blog=1059993&amp;post=663&amp;subd=viswaug&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://viswaug.wordpress.com/2011/02/13/well-known-text-wkt-representation-for-multipoint/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cde0d8ca836f3c2d78087cb8a5bd593e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">viswaug</media:title>
		</media:content>
	</item>
		<item>
		<title>Oracle spatial and the web mercator spatial reference system</title>
		<link>http://viswaug.wordpress.com/2011/02/11/oracle-spatial-and-the-web-mercator-spatial-reference-system/</link>
		<comments>http://viswaug.wordpress.com/2011/02/11/oracle-spatial-and-the-web-mercator-spatial-reference-system/#comments</comments>
		<pubDate>Fri, 11 Feb 2011 04:31:53 +0000</pubDate>
		<dc:creator>viswaug</dc:creator>
				<category><![CDATA[ArcGIS]]></category>
		<category><![CDATA[ESRI]]></category>
		<category><![CDATA[GIS]]></category>

		<guid isPermaLink="false">http://viswaug.wordpress.com/?p=657</guid>
		<description><![CDATA[We have been attempting to streamline the way we store and process spatial data in Oracle. Normally, we would create our spatial tables as FeatureClasses from ArcCatalog and create plain old Oracle tables for our business/attribute data that would be joined with the spatial data in the FeatureClasses through a shared key field to create [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=viswaug.wordpress.com&amp;blog=1059993&amp;post=657&amp;subd=viswaug&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>We have been attempting to streamline the way we store and process spatial data in Oracle. Normally, we would create our spatial tables as FeatureClasses from ArcCatalog and create plain old Oracle tables for our business/attribute data that would be joined with the spatial data in the FeatureClasses through a shared key field to create a <a title="sde spatial view" href="http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Using_database_views&amp;anchor=viewsspatial" target="_blank">SDE spatial view</a>. This works just fine, but there are some drawbacks to this approach</p>
<blockquote>
<ul>
<li>SDE creates unnecessary fields on the FeatureClass table in Oracle, like the field cad annotation that just don&#8217;t need to be there.</li>
<li>Creating FeatureClasses manually from ArcCatalog is a process that cannot be automated as a part of the build process. Ideally, we like to execute a command from our build scripts that will delete our entire model from the database and run another command to recreate the entire model to start off with a clean slate for testing our every build. These scripts will also be used during the deployment process when the database needs to be recreated in another environment.</li>
<li>FeatureClasses will need to be edited through ArcObjects (versioned/unversioned) or ArcMap(versioned) which would need an ESRI license on any client machine wanting to edit the spatial data. In a web environment, this would mean a ESRI license on the web server.</li>
</ul>
</blockquote>
<p>We wanted our setup to try and work around some of the drawbacks above. So, we wrote SQL scripts that would</p>
<ol>
<li>Create the spatial table</li>
<li>Insert metadata about the spatial table into the Oracle geometry metadata table USER_SDO_GEOM_METADATA</li>
<li>Create a spatial index on the table</li>
<li>Register the Oracle spatial table with ArcSDE as a FeatureClass using the &#8216;sdelayer -0 register&#8217; command</li>
</ol>
<p>Here is some sample SQL scripts to perform the first three steps with Oracle</p>
<blockquote>
<pre><span style="color:#800000;">CREATE TABLE customers (
  customer_id NUMBER,
  last_name VARCHAR2(30),
  first_name VARCHAR2(30),
  street_address VARCHAR2(40),
  city VARCHAR2(30),
  state_province_code VARCHAR2(2),
  postal_code VARCHAR2(9),
  cust_geo_location SDO_GEOMETRY);</span>
<span style="color:#800000;"> </span>
<span style="color:#0000ff;">INSERT INTO USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID)
   VALUES ('CUSTOMERS', 'CUST_GEO_LOCATION',
   SDO_DIM_ARRAY
     (SDO_DIM_ELEMENT('LONG', -180.0, 180.0, 0.5),
     SDO_DIM_ELEMENT('LAT', -90.0, 90.0, 0.5)),
   8307);</span>

<span style="color:#008000;">CREATE INDEX customers_sidx ON customers(cust_geo_location)
  INDEXTYPE IS mdsys.spatial_index;</span></pre>
</blockquote>
<p>The sample sde command to register the table as a multi-polygon FeatureClass with ArcSDE specifying the bounds</p>
<blockquote><p><span style="color:#ff0000;">sdelayer -o register -l CUSTOMERS,CUST_GEO_LOCATION -e a+M -C CUSTOMER_ID -i sde:oracle11g -s SERVER_NAME -u XXX -p YYY@orcl -t SDO_GEOMETRY -P High -x -180,-90,11132000</span></p></blockquote>
<p>As you can see from the commands above the spatial table is registered with Oracle to have an SRID (spatial reference id) of 8307 which denotes the WGS 84 Geographic Coordinate Systems. Oracle maintains its own CS_SRS table where it maintains a list of Oracle supported spatial reference systems. The SRID specified when adding the geometry metadata with Oracle is expected to be present in the CS_SRS table, else Oracle will insert the metadata into its tables. The bounds specified when registering the spatial table as a FeatureClass with ArcSDE also reflects the WGS 84 GCS.</p>
<p>So far so good. The above solution works like a charm. Now that the ArcGIS Online base maps have moved to the Web Mercator projection system used by google and bing, we also wanted to maintain our data in Web Mercator so that the GIS server doesn&#8217;t have to reproject the data when rendering maps and also so that we could serve out spatial data as GeoJSON/ArcJSON from our custom web services to consumed by web clients. Here is where trouble started. Oracle does not have a SRID for the web mercator projection system. We ran through the CS_SRS table to check for it maintained under a different id but with no luck. The process of registering a new SRID with Oracle is not documented anywhere as far as I can tell. Apparently, it is not as simple as adding an entry into the CS_SRS table which we tried unsuccessfully.</p>
<p>So, to work around this issue, we registered our spatial table with the Oracle geometry metadata table without an SRID. So, Oracle thinks the SRID for the spatial table in NULL. This becomes a problem when we try to insert geometries with ESRI&#8217;s SRID 102113 into the spatial table. Oracle doesn&#8217;t let us insert geometries into the spatial table whose is not NULL to match the entry in its geometry metadata tables. So, we are forced to insert geometries with a NULL SRID into the table. But ArcSDE needs to know that the spatial table is in the Web Mercator projection system. To do this, we registered the spatial table using the &#8216;sdelayer -o register&#8217; specifying the projection file &#8220;WGS 1984 Web Mercator (Auxiliary Sphere).prj&#8221; from ESRI. See the sample below</p>
<blockquote><p><span style="color:#ff0000;">sdelayer -o register -l CUSTOMERS,CUST_GEO_LOCATION -e a+M -C CUSTOMER_ID -i sde:oracle11g -s SERVER_NAME -u XXX -p YYY@orcl -t SDO_GEOMETRY -P High -G file=&#8221;C:\TEMP\WGS 1984 Web Mercator (Auxiliary Sphere).prj&#8221;</span></p></blockquote>
<p>The insert statement for the Oracle geometry metadata tables look like this</p>
<blockquote><p><span style="color:#000080;">INSERT INTO USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO)</span></p>
<p><span style="color:#000080;">VALUES (&#8216;CUSTOMERS&#8217;, &#8216;CUST_GEO_LOCATION&#8217;,</span></p>
<p><span style="color:#000080;">SDO_DIM_ARRAY</span></p>
<p><span style="color:#000080;">(SDO_DIM_ELEMENT(&#8216;X&#8217;, -20037700, 20037700, 0.1),</span></p>
<p><span style="color:#000080;">SDO_DIM_ELEMENT(&#8216;Y&#8217;, -20037700, 20037700, 0.1)));</span></p></blockquote>
<p>This is ugly, but it works. We were able to view and edit the data in ArcMap just fine.</p>
<p>Here are some more things discovered along the way</p>
<ul>
<li>Oracle makes all the table names and the field names all upper case by default even when you specify the names in lower case in the SQL statements. We can force Oracle to use lower cases alphabets in the table/field names by specifying the table/field names in the SQL statements by enclosing them in quotes.</li>
<li>If you use the technique above to use table/field names in lower case for the spatial tables, you will not be able to register the geometry metadata for the table with Oracle. This is because Oracle expects the spatial table/field name to be in all upper case for insertion into the geometry metadata table. This is just a crazy crazy thing and i can&#8217;t imagine this requirement being intentional.</li>
<li>Oracle spatial SQL syntax is ugly. Very ugly. They can definitely learn from the sweet SQL syntax in MS SQL SERVER 2008.</li>
<li>The free version of Oracle called Oracle XE does support the spatial data types. That is, in Oracle XE we can store columns whose data type is MDSYS.SDO_GEOMETRY. Oracle XE also allows us to perform some spatial operations on these spatial columns but not all spatial operations that are available in the enterprise edition of Oracle. The spatial features that are available in the XE edition is not documented anywhere as far as I can tell. Oracle spatial extensions bring more spatial features to Oracle enterprise edition like raster support etc.</li>
<li>The MDSYS.Oracle ST_GEOMETRY is different from the ESRI ST_GEOMETRY and is a wrapper around MDSYS.SDO_GEOMETRY</li>
</ul>
<p>If you are aware of a better way to do things with Oracle and SDE for the web mercator projection, please let me know, I am all ears. I hope this post save some other poor soul some pain and suffering.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/viswaug.wordpress.com/657/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/viswaug.wordpress.com/657/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/viswaug.wordpress.com/657/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/viswaug.wordpress.com/657/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/viswaug.wordpress.com/657/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/viswaug.wordpress.com/657/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/viswaug.wordpress.com/657/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/viswaug.wordpress.com/657/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/viswaug.wordpress.com/657/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/viswaug.wordpress.com/657/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/viswaug.wordpress.com/657/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/viswaug.wordpress.com/657/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/viswaug.wordpress.com/657/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/viswaug.wordpress.com/657/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=viswaug.wordpress.com&amp;blog=1059993&amp;post=657&amp;subd=viswaug&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://viswaug.wordpress.com/2011/02/11/oracle-spatial-and-the-web-mercator-spatial-reference-system/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cde0d8ca836f3c2d78087cb8a5bd593e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">viswaug</media:title>
		</media:content>
	</item>
		<item>
		<title>Drag &amp; Drop support for graphics in the ESRI Silverlight API</title>
		<link>http://viswaug.wordpress.com/2010/06/30/drag-drop-support-for-graphics-in-the-esri-silverlight-api/</link>
		<comments>http://viswaug.wordpress.com/2010/06/30/drag-drop-support-for-graphics-in-the-esri-silverlight-api/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 00:31:20 +0000</pubDate>
		<dc:creator>viswaug</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">https://viswaug.wordpress.com/2010/06/30/drag-drop-support-for-graphics-in-the-esri-silverlight-api/</guid>
		<description><![CDATA[I have recently added drag and drop support for graphics in the ESRI Silverlight API to the ESRI Silverlight API Contrib library. The library has also been upgraded to ESRI Silverlight API Beta 2. Will soon upgrade it to RC. The drag &#38; drop functionality can be added to specific graphics or to all the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=viswaug.wordpress.com&amp;blog=1059993&amp;post=656&amp;subd=viswaug&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have recently added drag and drop support for graphics in the <a href="http://resources.esri.com/arcgisserver/apis/silverlight/" target="_blank">ESRI Silverlight API</a> to the <a href="http://esrislcontrib.codeplex.com/" target="_blank">ESRI Silverlight API Contrib</a> library. The library has also been upgraded to ESRI Silverlight API Beta 2. Will soon upgrade it to RC. The drag &amp; drop functionality can be added to specific graphics or to all the graphics in a graphics layer. Enabling drag and drop is real easy. Just call the ‘MakeDraggable(map)’ method on either a Graphic object or a GraphicsLayer object. ‘MakeDraggable’ is an extension method that takes a reference to the ESRI Silverlight API map control to do it’s magic. The return from the method call is an ‘IDisposable’. To stop the graphic or the graphics on the graphics layer from being draggable, just call ‘Dispose’ on the ‘IDisposable’ object returned above. The map remains entirely usable when the graphics are draggable, so no worries there.</p>
<p>I am also currently looking into adding custom drawing tools to the library that will have the map be pannable when drawing and allow adding new drawing tools like circle etc if needed. If you want to see some new interesting features added to the <a href="http://esrislcontrib.codeplex.com/" target="_blank">ESRI Silverlight API Contrib</a> library, <a href="http://www.contactify.com/b6241" target="_blank">let me know <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/viswaug.wordpress.com/656/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/viswaug.wordpress.com/656/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/viswaug.wordpress.com/656/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/viswaug.wordpress.com/656/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/viswaug.wordpress.com/656/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/viswaug.wordpress.com/656/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/viswaug.wordpress.com/656/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/viswaug.wordpress.com/656/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/viswaug.wordpress.com/656/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/viswaug.wordpress.com/656/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/viswaug.wordpress.com/656/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/viswaug.wordpress.com/656/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/viswaug.wordpress.com/656/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/viswaug.wordpress.com/656/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=viswaug.wordpress.com&amp;blog=1059993&amp;post=656&amp;subd=viswaug&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://viswaug.wordpress.com/2010/06/30/drag-drop-support-for-graphics-in-the-esri-silverlight-api/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cde0d8ca836f3c2d78087cb8a5bd593e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">viswaug</media:title>
		</media:content>
	</item>
		<item>
		<title>Helper classes for mock testing WebClient</title>
		<link>http://viswaug.wordpress.com/2010/05/17/helper-classes-for-mock-testing-webclient/</link>
		<comments>http://viswaug.wordpress.com/2010/05/17/helper-classes-for-mock-testing-webclient/#comments</comments>
		<pubDate>Mon, 17 May 2010 02:28:41 +0000</pubDate>
		<dc:creator>viswaug</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">https://viswaug.wordpress.com/2010/05/17/helper-classes-for-mock-testing-webclient/</guid>
		<description><![CDATA[The WebClient class in .NET and Silverlight is used for fetching (GET) resources from the web or sometimes locally. This scenario inherently does not lend itself very well to unit testing since it means the component being written is dependent on an external resource. Unit testing seeks to test the component by itself and eliminate [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=viswaug.wordpress.com&amp;blog=1059993&amp;post=655&amp;subd=viswaug&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The WebClient class in .NET and Silverlight is used for fetching (GET) resources from the web or sometimes locally. This scenario inherently does not lend itself very well to unit testing since it means the component being written is dependent on an external resource. Unit testing seeks to test the component by itself and eliminate the request to the external resource. Mock testing comes to our rescue in such scenarios by letting us mock the touch-points where the component interfaces with the external resource. But, the use of WebClient to make the request to the external resource makes mocking tricky, since WebClient does not implement interfaces or virtual methods to expose its functionality. Most of the widely used mocking frameworks can only mock members of an interface or virtual methods. To overcome this short-comming, I have created and used the following helpers classes to help mock web requests made using WebClient. It consists of a &#8216;WrappedWebClient&#8217; class that wraps the methods supported by WebClient and implements interfaces defined alongside to help with the mocking of those methods.</p>
<p>The sample below contains a service class that fetches stories from the Digg web service using a search term.</p>
<p>
<div style="border-bottom:#000080 1px solid;border-left:#000080 1px solid;font-family:'Courier New', courier, monospace;color:#000;font-size:10pt;border-top:#000080 1px solid;border-right:#000080 1px solid;">
<div style="background:#fff;overflow:auto;">
<ol style="white-space:nowrap;background:#000000;margin:0;padding:0 0 0 5px;">
<li><span style="background:#000000;color:#ff8040;">public</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ff8040;">interface</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ffff9b;">IServiceRequest</span><span style="background:#000000;color:#00ffff;">&lt;</span><span style="background:#000000;color:#ffffff;">T, K</span><span style="background:#000000;color:#00ffff;">&gt;</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#00ffff;">{</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ff8040;">void</span><span style="background:#000000;color:#ffffff;"> Run( T input );</span>
<li style="background:#0c0c0c;">&nbsp;
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ff8040;">event</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ffff9b;">EventHandler</span><span style="background:#000000;color:#00ffff;">&lt;</span><span style="background:#000000;color:#ffff9b;">ServiceRequestEventArgs</span><span style="background:#000000;color:#00ffff;">&lt;</span><span style="background:#000000;color:#ffffff;">K</span><span style="background:#000000;color:#00ffff;">&gt;&gt;</span><span style="background:#000000;color:#ffffff;"> SelectionCompleted;</span>
<li style="background:#0c0c0c;">&nbsp;
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ff8040;">object</span><span style="background:#000000;color:#ffffff;"> State</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; {</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ff8040;">get</span><span style="background:#000000;color:#ffffff;">;</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ff8040;">set</span><span style="background:#000000;color:#ffffff;">;</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; }</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">}</span> </li>
</ol>
</div>
</div>
<p>
<div style="border-bottom:#000080 1px solid;border-left:#000080 1px solid;font-family:'Courier New', courier, monospace;color:#000;font-size:10pt;border-top:#000080 1px solid;border-right:#000080 1px solid;">
<div style="background:#fff;overflow:auto;">
<ol style="white-space:nowrap;background:#000000;margin:0;padding:0 0 0 5px;">
<li><span style="background:#000000;color:#ff8040;">public</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ff8040;">class</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ffff9b;">DiggSearchService</span><span style="background:#000000;color:#ffffff;"> : </span><span style="background:#000000;color:#ffff9b;">IServiceRequest</span><span style="background:#000000;color:#00ffff;">&lt;</span><span style="background:#000000;color:#ff8040;">string</span><span style="background:#000000;color:#ffffff;">, </span><span style="background:#000000;color:#ffff9b;">IEnumerable</span><span style="background:#000000;color:#00ffff;">&lt;</span><span style="background:#000000;color:#ffff9b;">DiggStory</span><span style="background:#000000;color:#00ffff;">&gt;&gt;</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#00ffff;">{</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ff8040;">string</span><span style="background:#000000;color:#ffffff;"> template </span><span style="background:#000000;color:#00ffff;">=</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#cacef9;">&#8220;http://services.digg.com/search/stories?query={0}&amp;count={1}&amp;appkey=http://www.vishcio.us&#8221;</span><span style="background:#000000;color:#ffffff;">;</span>
<li style="background:#0c0c0c;">&nbsp;
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ff8040;">public</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ffff9b;">IWebDownloader</span><span style="background:#000000;color:#ffffff;"> WebDownloader</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; {</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ff8040;">get</span><span style="background:#000000;color:#ffffff;">;</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ff8040;">set</span><span style="background:#000000;color:#ffffff;">;</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; }</span>
<li style="background:#0c0c0c;">&nbsp;
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ff8040;">public</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ff8040;">int</span><span style="background:#000000;color:#ffffff;"> StoryCount</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; {</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ff8040;">get</span><span style="background:#000000;color:#ffffff;">;</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ff8040;">set</span><span style="background:#000000;color:#ffffff;">;</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; }</span>
<li style="background:#0c0c0c;">&nbsp;
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ff8040;">public</span><span style="background:#000000;color:#ffffff;"> DiggSearchService()</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; {</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WebDownloader </span><span style="background:#000000;color:#00ffff;">=</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ff8040;">new</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ffff9b;">WrappedWebClient</span><span style="background:#000000;color:#ffffff;">();</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StoryCount </span><span style="background:#000000;color:#00ffff;">=</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ffff00;">10</span><span style="background:#000000;color:#ffffff;">;</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; }</span>
<li style="background:#0c0c0c;">&nbsp;
<li><span style="background:#000000;color:#8080ff;">&nbsp;&nbsp;&nbsp; #region</span><span style="background:#000000;color:#ffffff;"> IServiceRequest&lt;string,IEnumerable&lt;DiggStory&gt;&gt; Members</span>
<li style="background:#0c0c0c;">&nbsp;
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ff8040;">public</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ff8040;">void</span><span style="background:#000000;color:#ffffff;"> Run( </span><span style="background:#000000;color:#ff8040;">string</span><span style="background:#000000;color:#ffffff;"> input )</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; {</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WebDownloader</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">DownloadStringCompleted </span><span style="background:#000000;color:#00ffff;">+=</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ff8040;">new</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ffff9b;">EventHandler</span><span style="background:#000000;color:#00ffff;">&lt;</span><span style="background:#000000;color:#ffff9b;">WrappedDownloadStringCompletedEventArgs</span><span style="background:#000000;color:#00ffff;">&gt;</span><span style="background:#000000;color:#ffffff;">( WebDownloader_DownloadStringCompleted );</span>
<li style="background:#0c0c0c;">&nbsp;
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ffff9b;">Uri</span><span style="background:#000000;color:#ffffff;"> address </span><span style="background:#000000;color:#00ffff;">=</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ff8040;">new</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ffff9b;">Uri</span><span style="background:#000000;color:#ffffff;">(</span><span style="background:#000000;color:#ff8040;">string</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">Format(template, input,StoryCount));</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WebDownloader</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">DownloadStringAsync( address, State );</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; }</span>
<li style="background:#0c0c0c;">&nbsp;
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ff8040;">void</span><span style="background:#000000;color:#ffffff;"> WebDownloader_DownloadStringCompleted( </span><span style="background:#000000;color:#ff8040;">object</span><span style="background:#000000;color:#ffffff;"> sender, </span><span style="background:#000000;color:#ffff9b;">WrappedDownloadStringCompletedEventArgs</span><span style="background:#000000;color:#ffffff;"> e )</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; {</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ff8040;">if</span><span style="background:#000000;color:#ffffff;">( e</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">Error </span><span style="background:#000000;color:#00ffff;">!=</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ff8040;">null</span><span style="background:#000000;color:#ffffff;"> )</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RaiseSelectionCompletedEvent( </span><span style="background:#000000;color:#ff8040;">null</span><span style="background:#000000;color:#ffffff;">, e</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">Error );</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ff8040;">return</span><span style="background:#000000;color:#ffffff;">;</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span>
<li style="background:#0c0c0c;">&nbsp;
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ffff9b;">XDocument</span><span style="background:#000000;color:#ffffff;"> xmlStories </span><span style="background:#000000;color:#00ffff;">=</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ffff9b;">XDocument</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">Parse( e</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">Result );</span>
<li style="background:#0c0c0c;">&nbsp;
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ffff9b;">IEnumerable</span><span style="background:#000000;color:#00ffff;">&lt;</span><span style="background:#000000;color:#ffff9b;">DiggStory</span><span style="background:#000000;color:#00ffff;">&gt;</span><span style="background:#000000;color:#ffffff;"> stories </span><span style="background:#000000;color:#00ffff;">=</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ff8040;">from</span><span style="background:#000000;color:#ffffff;"> story </span><span style="background:#000000;color:#ff8040;">in</span><span style="background:#000000;color:#ffffff;"> xmlStories</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">Descendants( </span><span style="background:#000000;color:#cacef9;">&#8220;story&#8221;</span><span style="background:#000000;color:#ffffff;"> )</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ff8040;">select</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ff8040;">new</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ffff9b;">DiggStory</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Id </span><span style="background:#000000;color:#00ffff;">=</span><span style="background:#000000;color:#ffffff;"> ( </span><span style="background:#000000;color:#ff8040;">int</span><span style="background:#000000;color:#ffffff;"> ) story</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">Attribute( </span><span style="background:#000000;color:#cacef9;">&#8220;id&#8221;</span><span style="background:#000000;color:#ffffff;"> ),</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Title </span><span style="background:#000000;color:#00ffff;">=</span><span style="background:#000000;color:#ffffff;"> ( ( </span><span style="background:#000000;color:#ff8040;">string</span><span style="background:#000000;color:#ffffff;"> ) story</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">Element( </span><span style="background:#000000;color:#cacef9;">&#8220;title&#8221;</span><span style="background:#000000;color:#ffffff;"> ) )</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">Trim(),</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Description </span><span style="background:#000000;color:#00ffff;">=</span><span style="background:#000000;color:#ffffff;"> ( ( </span><span style="background:#000000;color:#ff8040;">string</span><span style="background:#000000;color:#ffffff;"> ) story</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">Element( </span><span style="background:#000000;color:#cacef9;">&#8220;description&#8221;</span><span style="background:#000000;color:#ffffff;"> ) )</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">Trim(),</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HrefLink </span><span style="background:#000000;color:#00ffff;">=</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ff8040;">new</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ffff9b;">Uri</span><span style="background:#000000;color:#ffffff;">( ( </span><span style="background:#000000;color:#ff8040;">string</span><span style="background:#000000;color:#ffffff;"> ) story</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">Attribute( </span><span style="background:#000000;color:#cacef9;">&#8220;link&#8221;</span><span style="background:#000000;color:#ffffff;"> ) ),</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NumDiggs </span><span style="background:#000000;color:#00ffff;">=</span><span style="background:#000000;color:#ffffff;"> ( </span><span style="background:#000000;color:#ff8040;">int</span><span style="background:#000000;color:#ffffff;"> ) story</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">Attribute( </span><span style="background:#000000;color:#cacef9;">&#8220;diggs&#8221;</span><span style="background:#000000;color:#ffffff;"> ),</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UserName </span><span style="background:#000000;color:#00ffff;">=</span><span style="background:#000000;color:#ffffff;"> ( </span><span style="background:#000000;color:#ff8040;">string</span><span style="background:#000000;color:#ffffff;"> ) story</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">Element( </span><span style="background:#000000;color:#cacef9;">&#8220;user&#8221;</span><span style="background:#000000;color:#ffffff;"> )</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">Attribute( </span><span style="background:#000000;color:#cacef9;">&#8220;name&#8221;</span><span style="background:#000000;color:#ffffff;"> )</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">Value,</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RaiseSelectionCompletedEvent( stories, </span><span style="background:#000000;color:#ff8040;">null</span><span style="background:#000000;color:#ffffff;"> );</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; }</span>
<li>&nbsp;
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ff8040;">public</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ff8040;">event</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ffff9b;">EventHandler</span><span style="background:#000000;color:#00ffff;">&lt;</span><span style="background:#000000;color:#ffff9b;">ServiceRequestEventArgs</span><span style="background:#000000;color:#00ffff;">&lt;</span><span style="background:#000000;color:#ffff9b;">IEnumerable</span><span style="background:#000000;color:#00ffff;">&lt;</span><span style="background:#000000;color:#ffff9b;">DiggStory</span><span style="background:#000000;color:#00ffff;">&gt;&gt;&gt;</span><span style="background:#000000;color:#ffffff;"> SelectionCompleted;</span>
<li>&nbsp;
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ff8040;">public</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ff8040;">object</span><span style="background:#000000;color:#ffffff;"> State</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; {</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ff8040;">get</span><span style="background:#000000;color:#ffffff;">;</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ff8040;">set</span><span style="background:#000000;color:#ffffff;">;</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; }</span>
<li>&nbsp;
<li style="background:#0c0c0c;"><span style="background:#000000;color:#8080ff;">&nbsp;&nbsp;&nbsp; #endregion</span>
<li>&nbsp;
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ff8040;">private</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ff8040;">void</span><span style="background:#000000;color:#ffffff;"> RaiseSelectionCompletedEvent( </span><span style="background:#000000;color:#ffff9b;">IEnumerable</span><span style="background:#000000;color:#00ffff;">&lt;</span><span style="background:#000000;color:#ffff9b;">DiggStory</span><span style="background:#000000;color:#00ffff;">&gt;</span><span style="background:#000000;color:#ffffff;"> data, </span><span style="background:#000000;color:#ffff9b;">Exception</span><span style="background:#000000;color:#ffffff;"> ex )</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; {</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ff8040;">if</span><span style="background:#000000;color:#ffffff;">( SelectionCompleted </span><span style="background:#000000;color:#00ffff;">!=</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ff8040;">null</span><span style="background:#000000;color:#ffffff;"> )</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SelectionCompleted( </span><span style="background:#000000;color:#ff8040;">this</span><span style="background:#000000;color:#ffffff;">, </span><span style="background:#000000;color:#ff8040;">new</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ffff9b;">ServiceRequestEventArgs</span><span style="background:#000000;color:#00ffff;">&lt;</span><span style="background:#000000;color:#ffff9b;">IEnumerable</span><span style="background:#000000;color:#00ffff;">&lt;</span><span style="background:#000000;color:#ffff9b;">DiggStory</span><span style="background:#000000;color:#00ffff;">&gt;&gt;</span><span style="background:#000000;color:#ffffff;">( data, ex ) );</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; }</span>
<li><span style="background:#000000;color:#ffffff;">}</span> </li>
</ol>
</div>
</div>
<p>The service class above uses the WrappedWebClient instead of the WebClient class itself. This enables the service class to be unit tested by mocking out the web request to the digg service. The WrappedWebClient implements the following interfaces</p>
<ul>
<li>IWebDownloader
<li>IWebUploader
<li>IWebReader
<li>IWebWriter</li>
</ul>
<p>This enables us to mock the various types of operations that can be performed by the WebClient. The Digg service class above exposes an IWebDownloader property which makes it clear that the service class uses the &#8216;DownloadStringAsync&#8217; method on the WebClient to access the service. To test the service class above, a sample response for the request can be downloaded beforehand and saved as a XML file. This file can then be compiled as a &#8216;Resource&#8217; into the test assembly. During the test, the XML file can be retrieved from the test assembly and can be used as the return value from the mock object for the IWebDownloader interface. The Silverlight unit test below illustrates how the service class can be unit tested using the helper classes and the Silverlight mocking framework &#8216;Moq&#8217;.</p>
<p>
<div style="border-bottom:#000080 1px solid;border-left:#000080 1px solid;font-family:'Courier New', courier, monospace;color:#000;font-size:10pt;border-top:#000080 1px solid;border-right:#000080 1px solid;">
<div style="background:#fff;overflow:auto;">
<ol style="white-space:nowrap;background:#000000;margin:0;padding:0 0 0 5px;">
<li><span style="background:#000000;color:#ffffff;">[</span><span style="background:#000000;color:#ffff9b;">TestClass</span><span style="background:#000000;color:#ffffff;">]</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ff8040;">public</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ff8040;">class</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ffff9b;">DiggSearchServiceTest</span><span style="background:#000000;color:#ffffff;"> : </span><span style="background:#000000;color:#ffff9b;">SilverlightTest</span>
<li><span style="background:#000000;color:#ffff9b;">{</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; [</span><span style="background:#000000;color:#ffff9b;">Asynchronous</span><span style="background:#000000;color:#ffffff;">]</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; [</span><span style="background:#000000;color:#ffff9b;">TestMethod</span><span style="background:#000000;color:#ffffff;">]</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ff8040;">public</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ff8040;">void</span><span style="background:#000000;color:#ffffff;"> DiggSearchServiceSuccessTest()</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; {</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ffff9b;">DiggSearchService</span><span style="background:#000000;color:#ffffff;"> target </span><span style="background:#000000;color:#00ffff;">=</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ff8040;">new</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ffff9b;">DiggSearchService</span><span style="background:#000000;color:#ffffff;">();</span>
<li>&nbsp;
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ffff9b;">StringBuilder</span><span style="background:#000000;color:#ffffff;"> sb </span><span style="background:#000000;color:#00ffff;">=</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ff8040;">new</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ffff9b;">StringBuilder</span><span style="background:#000000;color:#ffffff;">();</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ffff9b;">StringWriter</span><span style="background:#000000;color:#ffffff;"> sw </span><span style="background:#000000;color:#00ffff;">=</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ff8040;">new</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ffff9b;">StringWriter</span><span style="background:#000000;color:#ffffff;">( sb );</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ffff9b;">XDocument</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">Load( </span><span style="background:#000000;color:#cacef9;">&#8220;/WrappedWebClient;component/Tests/stories.xml&#8221;</span><span style="background:#000000;color:#ffffff;"> )</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">Save( sw );</span>
<li>&nbsp;
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ff8040;">var</span><span style="background:#000000;color:#ffffff;"> mock </span><span style="background:#000000;color:#00ffff;">=</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ff8040;">new</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ffff9b;">Mock</span><span style="background:#000000;color:#00ffff;">&lt;</span><span style="background:#000000;color:#ffff9b;">IWebDownloader</span><span style="background:#000000;color:#00ffff;">&gt;</span><span style="background:#000000;color:#ffffff;">();</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mock</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">Setup( foo </span><span style="background:#000000;color:#00ffff;">=&gt;</span><span style="background:#000000;color:#ffffff;"> foo</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">DownloadStringAsync( </span><span style="background:#000000;color:#ff8040;">null</span><span style="background:#000000;color:#ffffff;"> ) )</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">Verifiable();</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; target</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">WebDownloader </span><span style="background:#000000;color:#00ffff;">=</span><span style="background:#000000;color:#ffffff;"> mock</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">Object;</span>
<li>&nbsp;
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ff8040;">bool</span><span style="background:#000000;color:#ffffff;"> isLoaded </span><span style="background:#000000;color:#00ffff;">=</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ff8040;">false</span><span style="background:#000000;color:#ffffff;">;</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ffff9b;">IEnumerable</span><span style="background:#000000;color:#00ffff;">&lt;</span><span style="background:#000000;color:#ffff9b;">DiggStory</span><span style="background:#000000;color:#00ffff;">&gt;</span><span style="background:#000000;color:#ffffff;"> result </span><span style="background:#000000;color:#00ffff;">=</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ff8040;">null</span><span style="background:#000000;color:#ffffff;">;</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; target</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">SelectionCompleted </span><span style="background:#000000;color:#00ffff;">+=</span><span style="background:#000000;color:#ffffff;"> ( sender, e ) </span><span style="background:#000000;color:#00ffff;">=&gt;</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; isLoaded </span><span style="background:#000000;color:#00ffff;">=</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ff8040;">true</span><span style="background:#000000;color:#ffffff;">;</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#4b9300;">//Get the results from the service</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; result </span><span style="background:#000000;color:#00ffff;">=</span><span style="background:#000000;color:#ffffff;"> e</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">EventData;</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; target</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">Run( </span><span style="background:#000000;color:#cacef9;">&#8220;LSU&#8221;</span><span style="background:#000000;color:#ffffff;"> );</span>
<li>&nbsp;
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EnqueueDelay( </span><span style="background:#000000;color:#ffff00;">1000</span><span style="background:#000000;color:#ffffff;"> );</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#4b9300;">//Mock the service request results</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EnqueueCallback( () </span><span style="background:#000000;color:#00ffff;">=&gt;</span><span style="background:#000000;color:#ffffff;"> mock</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">Raise</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bar </span><span style="background:#000000;color:#00ffff;">=&gt;</span><span style="background:#000000;color:#ffffff;"> bar</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">DownloadStringCompleted </span><span style="background:#000000;color:#00ffff;">+=</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ff8040;">null</span><span style="background:#000000;color:#ffffff;">,</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background:#000000;color:#ff8040;">new</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ffff9b;">WrappedDownloadStringCompletedEventArgs</span><span style="background:#000000;color:#ffffff;">( sb</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">ToString(), </span><span style="background:#000000;color:#ff8040;">null</span><span style="background:#000000;color:#ffffff;">, </span><span style="background:#000000;color:#ff8040;">false</span><span style="background:#000000;color:#ffffff;">, </span><span style="background:#000000;color:#ff8040;">null</span><span style="background:#000000;color:#ffffff;"> )</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ) );</span>
<li>&nbsp;
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EnqueueConditional( () </span><span style="background:#000000;color:#00ffff;">=&gt;</span><span style="background:#000000;color:#ffffff;"> isLoaded );</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EnqueueCallback( () </span><span style="background:#000000;color:#00ffff;">=&gt;</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ffff9b;">Assert</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">IsNotNull( result ) );</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EnqueueCallback( () </span><span style="background:#000000;color:#00ffff;">=&gt;</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ffff9b;">Assert</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">IsTrue( result</span><span style="background:#000000;color:#00ffff;">.</span><span style="background:#000000;color:#ffffff;">Count</span><span style="background:#000000;color:#00ffff;">&lt;</span><span style="background:#000000;color:#ffff9b;">DiggStory</span><span style="background:#000000;color:#00ffff;">&gt;</span><span style="background:#000000;color:#ffffff;">() </span><span style="background:#000000;color:#00ffff;">==</span><span style="background:#000000;color:#ffffff;"> </span><span style="background:#000000;color:#ffff00;">10</span><span style="background:#000000;color:#ffffff;"> ) );</span>
<li><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EnqueueTestComplete();</span>
<li style="background:#0c0c0c;"><span style="background:#000000;color:#ffffff;">&nbsp;&nbsp;&nbsp; }</span>
<li><span style="background:#000000;color:#ffffff;">}</span> </li>
</ol>
</div>
</div>
<p>Suggestions welcome&#8230;</p>
<p><a href="http://www.box.net/shared/xcrxb5lsm6" target="_blank">Download the source code with the helper classes here</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/viswaug.wordpress.com/655/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/viswaug.wordpress.com/655/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/viswaug.wordpress.com/655/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/viswaug.wordpress.com/655/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/viswaug.wordpress.com/655/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/viswaug.wordpress.com/655/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/viswaug.wordpress.com/655/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/viswaug.wordpress.com/655/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/viswaug.wordpress.com/655/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/viswaug.wordpress.com/655/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/viswaug.wordpress.com/655/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/viswaug.wordpress.com/655/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/viswaug.wordpress.com/655/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/viswaug.wordpress.com/655/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=viswaug.wordpress.com&amp;blog=1059993&amp;post=655&amp;subd=viswaug&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://viswaug.wordpress.com/2010/05/17/helper-classes-for-mock-testing-webclient/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cde0d8ca836f3c2d78087cb8a5bd593e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">viswaug</media:title>
		</media:content>
	</item>
		<item>
		<title>Issues encountered and solved while building a comprehensive web-based map printing solution</title>
		<link>http://viswaug.wordpress.com/2010/03/30/issues-encountered-and-solved-while-building-a-comprehensive-web-based-map-printing-solution/</link>
		<comments>http://viswaug.wordpress.com/2010/03/30/issues-encountered-and-solved-while-building-a-comprehensive-web-based-map-printing-solution/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 22:04:52 +0000</pubDate>
		<dc:creator>viswaug</dc:creator>
				<category><![CDATA[ArcGIS]]></category>
		<category><![CDATA[ESRI]]></category>
		<category><![CDATA[GIS]]></category>

		<guid isPermaLink="false">http://viswaug.wordpress.com/?p=641</guid>
		<description><![CDATA[Web-based map printing has been one of those problems that, so far, doesn&#8217;t have a COMPLETE solution that meets all the needs of the different users out there. We had created various solutions in the past to meet web-based printing needs on a per-project basis. But, we didn&#8217;t have one single comprehensive solution that was [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=viswaug.wordpress.com&amp;blog=1059993&amp;post=641&amp;subd=viswaug&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Web-based map printing has been one of those problems that, so far, doesn&#8217;t have a COMPLETE solution that meets all the needs of the different users out there. We had created various solutions in the past to meet web-based printing needs on a per-project basis. But, we didn&#8217;t have one single comprehensive solution that was capable enough to meet all requirements regardless of the unique complexities involved in each of them. A little while ago, we set out to build one such comprehensive web-based map printing solution and ran into some issues along the way that I thought might be worth sharing here. I am not going to go into what we built here, but just the issues/oddities we encountered&#8230;</p>
<p>Here are the issues we faced while developing the printing component and some details into how we worked-around them.</p>
<ul>
<li><strong>Printing token secure layers -</strong> This is a problem that we initially didn&#8217;t see coming because we were using the Silverlight client api to print. When using token layers, the client (which is the browser) requests a token from the GIS server using it&#8217;s IP address (or a web address) as the optional ClientID. When using a token generated with a ClientID, the AGS server checks for the origin of the request to confirm identity. So, when we tried to use the token generated by the client browser with it&#8217;s IP address as the ClientID in the server-side printing component, the requests were denied by AGS as it rightfully should since the server&#8217;s IP address doesn&#8217;t match the one in the token. We did not initially see this problem with Silverlight clients because, Silverlight clients currently request tokens without the optional ClientID. To work around this, we had to request token without the ClientID or had to spoof the Referrer in the HTTP request for the image.</li>
<li><strong>Max Image Size constraints -</strong> The size of map image requests that need to be made can get quite large depending on the size of the map on the print layout and also on the DPI required on the map print output. AGS has default max image size limits set to 2048 X 2048. Bing maps maximum image size is around ~800. Increasing the maximum image size limit in AGS will only take you so far. Eventually, your image size requests can be big enough (think plotter size) to either cause AGS to crash or just take an unacceptably long time to return. So, to work around this limitation, we had to resort to cutting the big image requests into a series reasonably sized tile requests. Once all the tiles to cover the big area arrive, the tiles can be stitched back together using GDI+ to produce a seamless big image that the map print layout needs.</li>
<li><strong>Bing logo -</strong> The above solution to split big image requests into works for AGS MapServices and WMS services, but Bing map layers add another twist to the problem. Image responses from Bing contain the Bing logo on the bottom right corner of the image. This caused the Bing logo to appear multiple times on the map when the numerous smaller tile images were stitched together. To solve this issue, we had to get special permission from Bing to access their tile images directly which do not have the Bing logo on them and stitch those together to produce the seamless image required.</li>
<li><strong>Custom legends -</strong> The swatches for legend image for an AGS MapService can be obtained pretty easily using the AGS SOAP API. But more custom work is needed to stitch together the swatch and legend text information from multiple map services. Also, to add to it, there was no easy way to generate swatches for graphics layers. So, we ended up writing a custom Server Object Extension (we call it LegendServer) exposed over SOAP that takes in the information needed to produce swatches for the graphics layers and produces swatch images. The legend service consumed the swatches information from the AGS MapService and the custom SOE and stitched them together into one legend image handling the font styles etc and wrapping as necessary. We still have the issues here that ArcObjects is not able to generate the swatches at the required DPI. For e.g. we can&#8217;t request for swatches in 300 DPI etc.</li>
<li><strong>Missing legend symbol markers in AGS -</strong> When writing the custom Server Object Extension described above to produce legend swatches, we discovered that ArcObjects doesn&#8217;t support triangle markers. But triangle markers were supported on the client-side APIs. So, to overcome that limitation, we can handle just the triangle markers as picture marker symbols and handle it with a special image service that produces a triangle image in the required dimensions, fill and border color.</li>
<li><strong>Overflowing legends -</strong> Sometimes the legend for a map just can&#8217;t fit on a single page. In those cases, we had to make sure that we build the legend in parts that can fit on the page and stick the overflowing legend into new pages as needed. The trick here is to not build one single legend image and chop it to overflow to the next page. Because, we decide to chop off the legend at an arbitrary height, we might end up chopping the text or swatch on the legend. So, we will have to build the legend in parts and then assemble them into the different pages.</li>
<li><strong>Printing Graphics layers -</strong> Printing graphics layers on the map turned out to be a little tricker than expected. We went down the path of rendering the graphic layers as PDF graphics on top of the map. It seemed to do everything we needed until we had to print polygons with holes in it. Then we used the AGS SOAP API to generate an image for the graphics on the map and overlay it on top of the map. We ended up pulling back that solution because that technique did not support transparency in graphics. So, eventually, we ended up writing a custom Server Object Extension (we call it GraphicsServer) that produces images from the graphics layer geometries and symbology respecting their transparency.</li>
<li><strong>Overview Map -</strong> Printing overview map doesn&#8217;t sound too complicated until you consider the fact that we might have a totally different set of layers on the overview map than we do on the map itself. Also, the overview map can be static or dynamic, meaning it can always be at the same extent (world extent for example) or it may have it&#8217;s extent set at levels that closely follow the extent of the map itself. Also, keep in mind that the overview map will also need to have a small rectangle graphic inside it that highlights to current extent of the map.</li>
<li><strong>Print Rendering -</strong> In most cases, we will want to have the option of being able to render to PDF or an image as the user requires. When implementing these renderers, please keep in mind that the co-ordinates axis for the PDF and the image GDI graphics are reversed. PDF is bottom-up and image GDI graphics is top-down.</li>
</ul>
<p>I am pretty sure that I am leaving out some more. I will add them to the list above as and when I remember them. But I am happy to say that we did solve/work-around all the problems that came our way and have been re-using the printing component in various projects with great success. The printing component is also being used by all Silverlight, Flex and Javascript clients.</p>
<p>Please let me know, if you ran across other issues when you implemented your print feature or if you solved any of the issues above in a different way.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/viswaug.wordpress.com/641/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/viswaug.wordpress.com/641/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/viswaug.wordpress.com/641/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/viswaug.wordpress.com/641/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/viswaug.wordpress.com/641/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/viswaug.wordpress.com/641/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/viswaug.wordpress.com/641/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/viswaug.wordpress.com/641/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/viswaug.wordpress.com/641/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/viswaug.wordpress.com/641/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/viswaug.wordpress.com/641/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/viswaug.wordpress.com/641/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/viswaug.wordpress.com/641/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/viswaug.wordpress.com/641/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=viswaug.wordpress.com&amp;blog=1059993&amp;post=641&amp;subd=viswaug&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://viswaug.wordpress.com/2010/03/30/issues-encountered-and-solved-while-building-a-comprehensive-web-based-map-printing-solution/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cde0d8ca836f3c2d78087cb8a5bd593e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">viswaug</media:title>
		</media:content>
	</item>
	</channel>
</rss>
