<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>geographika</title>
	
	<link>http://geographika.co.uk</link>
	<description>Developing geo-technologies</description>
	<lastBuildDate>Fri, 09 Sep 2011 09:45:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/geographika_feed" /><feedburner:info uri="geographika_feed" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Building MapServer &amp; MapScript on Windows</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/UQWVD-Ix_G8/building-mapserver-mapscript-on-windows</link>
		<comments>http://geographika.co.uk/building-mapserver-mapscript-on-windows#comments</comments>
		<pubDate>Sun, 24 Jul 2011 20:40:52 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[mapserver]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[gdal]]></category>
		<category><![CDATA[mapscript]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=925</guid>
		<description><![CDATA[There are already Windows packages available for MapServer ready for deployment. However if you need to make a modification to the source files, apply a patch, or just want to see how MapServer is made then you can build MapServer from its C source files. Thanks to the ready made build kits this process should <a href='http://geographika.co.uk/building-mapserver-mapscript-on-windows'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p align="justify">
<p align="justify"><a href="http://geographika.co.uk/wp-content/uploads/2011/07/image.png"><img style="margin: 3px; display: inline; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/07/image_thumb.png" alt="image" width="244" height="72" align="left" border="0" /></a>There are already <a href="http://www.gisinternals.com/sdk/" target="_blank">Windows packages</a> available for MapServer ready for deployment. However if you need to make a modification to the source files, apply a patch, or just want to see how MapServer is made then you can build MapServer from its C source files. Thanks to the <a href="http://www.gisinternals.com/sdk/" target="_blank">ready made build kits</a> this process should only take 10-15 minutes from start to finish.</p>
<p align="justify"><em>Prerequisites: Microsoft Visual Studio with C++</em></p>
<p align="justify">1. Download the MapServer SDK (Software Development Kit) from <a title="http://www.gisinternals.com/sdk/" href="http://www.gisinternals.com/sdk/">http://www.gisinternals.com/sdk/</a>. I’m using Visual Studio 2010, and building on a 32-bit Windows machine (still using XP..), so I’m using <a href="http://www.gisinternals.com/sdk/PackageList.aspx?file=release-1600-dev.zip">release-1600-dev</a></p>
<p align="justify">These build kits, provided by one of MapServer’s developers <a href="http://szekerest.blogspot.com/" target="_blank">Tamas Szekeres</a>,  contain everything you need to compile both MapServer and <a href="http://www.gdal.org/" target="_blank">GDAL</a>. Checking out all the files from the <a href="http://trac.osgeo.org/mapserver/browser" target="_blank">MapServer SVN repository</a> is not enough, as this does not contain the GDAL or RegEx dependencies (DLLs that MapServer depends on), or SWIG – a tool used to create MapScript files for each of the different scripting languages available in MapServer such as Python, Ruby, PHP, Perl etc.</p>
<div align="justify"><span id="more-925"></span></div>
<p align="justify">2. Unzip the MapServer SDK on your hard-drive. Make a cup of tea as this takes awhile. In this example I’ve extracted the files to D:\MapServer. You should see a folder structure similar to below.</p>
<p align="justify"><a href="http://geographika.co.uk/wp-content/uploads/2011/07/image1.png"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/07/image_thumb1.png" alt="image" width="185" height="207" border="0" /></a></p>
<p align="justify">3. Open up a WIndows command prompt. Navigate to the folder you extracted the files. Now run the following command:</p>
<p align="justify">&#8220;C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat&#8221;</p>
<p align="justify">This is a Windows batch file that sets up environment variables so you can use the MS Visual Studio tools in your current command session.</p>
<p align="justify">If this file is not present then make sure you have Microsoft Visual Studio C++ 2010 installed. You can check this in Add/Remove programs, or through the About menu in Visual Studio. It is not installed by default so you may have to go and find your installation disks or ISO.</p>
<p align="justify"><a href="http://geographika.co.uk/wp-content/uploads/2011/07/image2.png"><img style="display: inline; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/07/image_thumb2.png" alt="image" width="153" height="244" border="0" /></a> <a href="http://geographika.co.uk/wp-content/uploads/2011/07/image3.png"><img style="display: inline; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/07/image_thumb3.png" alt="image" width="494" height="129" border="0" /></a></p>
<p align="justify">4. The <a href="http://msdn.microsoft.com/en-us/library/dd9y37ha%28v=VS.100%29.aspx" target="_blank">nmake</a> tool is a Microsoft program that builds projects based on the contents of a <a href="http://en.wikipedia.org/wiki/Make_%28software%29" target="_blank">Makefile</a>. It’s the command line equivalent of pressing F5 in Visual Studio. You can look at the contents of the Makefile in a text editor – this is where all the hard work is done. Run the following command:</p>
<p align="justify">nmake ms</p>
<p align="justify">Sit back and watch the compilation! If you want to record what happened to a log file you can use the command:</p>
<p align="justify">nmake ms &gt;&gt; my_log.txt</p>
<p align="justify">After this build there should be a new folder D:\MapServer\release-1600\ containing all the files you need to deploy MapServer. When unzipped this folder already contained a build, but the timestamps for the DLLS should now be from a few minutes ago.</p>
<p align="justify"><a href="http://geographika.co.uk/wp-content/uploads/2011/07/image4.png"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/07/image_thumb4.png" alt="image" width="244" height="179" border="0" /></a></p>
<h2 align="justify">Rebuilding MapScript</h2>
<p align="justify">The Makefile D:\MapServer\Makefile contains details on how to build MapScript. The Makefile commands are great to follow if you want to just rebuild Python MapScript rather than the whole of MapServer. Just search for “ms-python” and you’ll see all the DOS commands you need to rebuild Python. You can then run these “by-hand” as shown below.</p>
<p align="justify">My original build produced MapScript for Python 2.6, but I also wanted to create a build for 2.7. To create a Python 2.7 compatible MapScript follow these steps:</p>
<p align="justify">1. Open the D:\MapServer\mapserver-6-0\mapscript\python\setup.py file in a Python editor such as IDLE. Change the library_dirs to read:</p>
<p align="justify">library_dirs = ['../../','../../../release-1600/lib/']</p>
<p align="justify"><a href="http://geographika.co.uk/wp-content/uploads/2011/07/image5.png"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/07/image_thumb5.png" alt="image" width="419" height="131" border="0" /></a>It should be possible to set these paths outside the setup.py on the command line, but I was not able to get this to work. This change adds in the folder containing all the .lib files that were created when we built MapServer. Check these files are present!</p>
<p align="justify">2. Navigate to the D:\MapServer\mapserver-6-0\mapscript\python directory.</p>
<p align="justify">3. Run the following commands (taken from the Makefile):</p>
<p align="justify"><strong>SET DISTUTILS_USE_SDK=1<br />
SET MSSdk=1<br />
SET LIB=%LIB%;$D:\MapServer\release-1600\lib</strong></p>
<p align="justify">4. Run the following command:</p>
<p align="justify">python.exe setup.py build</p>
<p align="justify"><a href="http://geographika.co.uk/wp-content/uploads/2011/07/image6.png"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/07/image_thumb6.png" alt="image" width="483" height="94" border="0" /></a> You should now have two new files – mapscript.py and _mapscript.pyd (a .pyd file is a DLL <a href="http://docs.python.org/faq/windows.html#is-a-pyd-file-the-same-as-a-dll" target="_blank">with a couple of differences</a>).</p>
<p align="justify"><a href="http://geographika.co.uk/wp-content/uploads/2011/07/image7.png"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/07/image_thumb7.png" alt="image" width="362" height="83" border="0" /></a></p>
<h2 align="justify">Here be Errors</h2>
<p align="justify">I took out all the twists, turns, and errors I encountered along the way to make the process appear simple, and me to appear to be an expert..however I ran into a myriad of problems, the error messages of which I’ve included below, along with how to fix them.</p>
<p align="justify"><em>&#8216;nmake&#8217; is not recognized as an internal or external command, operable program or batch file.</em></p>
<p align="justify">- Make sure you have run the &#8220;C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat&#8221; file in your current Windows command session.</p>
<p align="justify"><em>LINK : fatal error LNK1181: cannot open input file &#8216;gd.lib&#8217;<br />
error: command &#8216;link.exe&#8217; failed with exit status 1181</em></p>
<p align="justify">- You need to edit the setup.py file to include the folder with the .lib files – see “Rebuilding MapScript step 2.” Also make sure you have built MapServer and the gd.lib file is in your D:\MapServer\release-1600\lib folder.</p>
<p align="justify"><em>building &#8216;_mapscript&#8217; extension<br />
error: Unable to find vcvarsall.bat</em></p>
<p align="justify">- When building MapScript you need to set the correct environment variables – see “Rebuilding MapScript step 3”</p>
<p align="justify"><em>_mapscript.pyd.manifest : general error c1010070: Failed to load and parse the manifest. The system cannot </em><em>find the file specified. error: command &#8216;mt.exe&#8217; failed with exit status 31</em></p>
<p align="justify">- Try cleaning the Python MapScript build folders with the following command:</p>
<p align="justify"><strong>D:\MapServer\mapserver-6-0\mapscript\python&gt;python.exe setup.py clean</strong></p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/UQWVD-Ix_G8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/building-mapserver-mapscript-on-windows/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/building-mapserver-mapscript-on-windows?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=building-mapserver-mapscript-on-windows</feedburner:origLink></item>
		<item>
		<title>OpenLayers and Versioning in Aptana Studio</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/49n2XjlT8PQ/openlayers-and-versioning-in-aptana-studio</link>
		<comments>http://geographika.co.uk/openlayers-and-versioning-in-aptana-studio#comments</comments>
		<pubDate>Thu, 30 Jun 2011 16:41:52 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[OpenLayers]]></category>
		<category><![CDATA[openlayers]]></category>
		<category><![CDATA[sourcecontrol]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=899</guid>
		<description><![CDATA[This post details how to add a Subversion (SVN) plugin to Aptana to allow you to compare OpenLayers code with previous versions. A straw poll was taken on the OpenLayers mailing list in April 2010, and OpenLayers v3 development is taking place in git, with the central repository stored on GitHub. This means working with <a href='http://geographika.co.uk/openlayers-and-versioning-in-aptana-studio'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2011/06/image1.png"><img style="margin: 0px 5px 0px 0px; display: inline; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/06/image_thumb.png" border="0" alt="image" width="244" height="90" align="left" /></a>This post details how to add a Subversion (SVN) plugin to Aptana to allow you to compare OpenLayers code with previous versions.</p>
<p style="text-align: justify;">A <a href="http://osgeo-org.1803224.n2.nabble.com/GitHub-straw-poll-td4915670.html">straw poll</a> was taken on the OpenLayers mailing list in April 2010, and OpenLayers v3 development is taking place in git, with the central repository stored on <a href="https://github.com/openlayers/openlayers">GitHub</a>. This means working with SVN and OpenLayers may become redundant. However as many OSGEO projects are stored in SVN with no current plans to move the same plugin and knowledge of working with SVN will still be useful.</p>
<p style="text-align: justify;">For further details on working with SVN there is a free e-book “Version Control with Subversion” available at <a title="http://svnbook.red-bean.com/" href="http://svnbook.red-bean.com/">http://svnbook.red-bean.com/</a></p>
<h2 style="text-align: justify;">Installing the Plugin</h2>
<p style="text-align: justify;">1. Open the Plugin Manager, by clicking on the green jigsaw piece in the toolbar below.</p>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2011/06/image2.png"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/06/image_thumb1.png" border="0" alt="image" width="126" height="48" /></a></p>
<p style="text-align: justify;"><span id="more-899"></span></p>
<p style="text-align: justify;">2. Right click and select Install in the plugin manager. A list of available plugins appears.</p>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2011/06/image3.png"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/06/image_thumb2.png" border="0" alt="image" width="479" height="123" /></a>3. As you can see there are a couple of SubVersion related plugins available.  Fortunately StackOverflow had a question titled <a href="http://stackoverflow.com/questions/61320/svn-plugins-for-eclipse-subclipse-vs-subversive">SVN plugins for Eclipse &#8211; Subclipse vs. Subversive</a>, which leant towards using Subclipse over Subversive. Life’s too short to dwell on possible advantages of using one over the other, so Subclipse it was.</p>
<p style="text-align: justify;">4. Next follow a number of screens related to security certificates, and additional components. Other than selecting a couple of “Recommended” options I left the defaults.</p>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2011/06/image4.png"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/06/image_thumb3.png" border="0" alt="image" width="244" height="79" /></a>5. Once the plugin was installed and Aptana restarted I now had a new project type = “Checkout Projects from SVN.”</p>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2011/06/image5.png"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/06/image_thumb4.png" border="0" alt="image" width="198" height="244" /></a> 6. The location of the OpenLayers trunk (the latest development version) can be found at <a href="http://svn.osgeo.org/openlayers/trunk/openlayers">http://svn.osgeo.org/openlayers/trunk/openlayers</a></p>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2011/06/image6.png"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/06/image_thumb5.png" border="0" alt="image" width="334" height="120" /></a>7. Selecting the root will check out OpenLayers, and all the associated tests, build tools, and documentation.</p>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2011/06/image7.png"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/06/image_thumb6.png" border="0" alt="image" width="244" height="122" /></a></p>
<p style="text-align: justify;">8. After this you can create a new project location, and the plugin fetches all the latest files directly from the OpenLayers SVN server.</p>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2011/06/image8.png"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/06/image_thumb7.png" border="0" alt="image" width="244" height="143" /></a></p>
<h2 style="text-align: justify;">Using the Plugin</h2>
<p style="text-align: justify;">Now this is set up the fun can start! The reason I wished to go into the changes made to OpenLayers was that one of my unit tests was throwing an error after I have updated my OpenLayers 2.10 to the latest development version in OpenLayers. The error was:</p>
<pre>exception: : object: wkt.replace is not a function</pre>
<pre>in ( [object Array]) at <a href="http://localhost/openlayers/lib/OpenLayers/Format/WKT.js">http://localhost/openlayers/lib/OpenLayers/Format/WKT.js</a> line 59
</pre>
<p>You can see when files were last modified, and by whom, in the File explorer tab. The most powerful feature though is being able to compare the current files with any past version of OpenLayers. This can be done by right-clicking on a file, and selecting the “Compare With” option.</p>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2011/06/image9.png"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/06/image_thumb8.png" border="0" alt="image" width="421" height="103" /></a></p>
<p style="text-align: justify;">Now to diagnose my error, I looked to see if any changes had been made from the 2.10 version of OpenLayers(which my unit test passed) , with the current development version. Selecting the “Branch/Tag” option allows you to select a version (based on its tag). Version 2.10 is listed after 2.1 due to sorting by characters rather than numbers.</p>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2011/06/image10.png"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/06/image_thumb9.png" border="0" alt="image" width="384" height="203" /></a> <a href="http://geographika.co.uk/wp-content/uploads/2011/06/image11.png"></a></p>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2011/06/image11.png"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/06/image_thumb10.png" border="0" alt="image" width="244" height="244" /></a></p>
<p style="text-align: justify;">A comparison showed that the file and line had indeed been changed. A replace function had been added to the code to remove whitespace from the WKT string.</p>
<p style="text-align: justify;">Upon further debugging it turned out the problem was my test had been passing an Array rather than a String, and as an Array object does not have a replace function is was correctly throwing an error. This served as a good reminder that unit tests can themselves have bugs..</p>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2011/06/image12.png"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/06/image_thumb11.png" border="0" alt="image" width="512" height="79" /></a></p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/49n2XjlT8PQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/openlayers-and-versioning-in-aptana-studio/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/openlayers-and-versioning-in-aptana-studio?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=openlayers-and-versioning-in-aptana-studio</feedburner:origLink></item>
		<item>
		<title>MapServer, OpenLayers and the WFS Maze</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/xCU14jc48TM/mapserver-openlayers-and-the-wfs-maze</link>
		<comments>http://geographika.co.uk/mapserver-openlayers-and-the-wfs-maze#comments</comments>
		<pubDate>Fri, 10 Jun 2011 16:07:56 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[mapserver]]></category>
		<category><![CDATA[OpenLayers]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[projections]]></category>
		<category><![CDATA[srs]]></category>
		<category><![CDATA[wfs]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=859</guid>
		<description><![CDATA[First a little background on what I was trying to achieve. I am developing a GIS that has both a web and desktop component. It&#8217;s built using SQL Server 2008, MapServer, OpenLayers, and using MapInfo and QGIS for desktop connections. On the web system I have an OpenLayers map, with an OpenStreetMap background layer. As <a href='http://geographika.co.uk/mapserver-openlayers-and-the-wfs-maze'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a title="Sundials by lcarmichael" href="http://www.flickr.com/photos/jlcarmichael/"><img style="margin: 0px 10px 0px 0px; display: inline; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/06/image.png" border="0" alt="image" width="252" height="244" align="left" /></a>First a little background on what I was trying to achieve. I am developing a GIS that has both a web and desktop component. It&#8217;s built using SQL Server 2008, MapServer, OpenLayers, and using MapInfo and QGIS for desktop connections.</p>
<p style="text-align: justify;">On the web system I have an OpenLayers map, with an OpenStreetMap background layer. As with nearly all the online tiling services, these are projected in EPSG:900913 (the Web Mercator / Google projection).</p>
<p style="text-align: justify;">I wanted to display a road network on top of these as a WFS (Web Feature Service). The source data is defined in the Irish National Grid projection (EPSG:29902).</p>
<p style="text-align: justify;">At the same time I also wanted people to be able to connect to the WFS via a desktop GIS client using the Irish National Grid projection. <span id="more-859"></span></p>
<h3>Multiple Spatial Reference Systems (SRSs)</h3>
<p style="text-align: justify;">The <a href="http://mapserver.org/ogc/wfs_server.html#configuring-your-mapfile-to-serve-wfs-layers">Rules for Handling SRS in MapServer WFS</a> are not the easiest to work with. The first paragraph of the rules imply that multiple projections are not available for a single WFS layer available through MapServer:</p>
<blockquote><p>Contrary to WMS, the OGC WFS specification doesn’t allow a layer (feature type) to be advertised in more than one SRS. Also, there is no default SRS that applies to all layers by default in the OGC WFS spec. However, it is possible to have every layer in a WFS server advertised in a different SRS.</p></blockquote>
<p style="text-align: justify;">However there is now support for multiple SRSs &#8211; added in version 6.0 of MapServer as outlined in <a href="http://trac.osgeo.org/mapserver/ticket/3227">this ticket</a>. You can check how a WFS layer is “advertised” to a client using a URL similar to the following:</p>
<p><a href="http://localhost/mapserver/mapserv.exe?map=C:/PathToMapFile/MyMap.map&amp;service=WFS&amp;request=GetCapabilities&amp;version=1.1.0">http://localhost/mapserver/mapserv.exe?map=C:/PathToMapFile/MyMap.map&amp;service=WFS&amp;request=GetCapabilities&amp;version=1.1.0</a></p>
<p style="text-align: justify;">Each of the layers should have some XML which lists the DefaultSRS, and if you have set it up one or more OtherSRS tags:</p>
<pre>&lt;FeatureType&gt;
    &lt;Name&gt;Test&lt;/Name&gt;
    &lt;Title&gt;Test&lt;/Title&gt;
    &lt;DefaultSRS&gt;urn:ogc:def:crs:EPSG::900913&lt;/DefaultSRS&gt;
    &lt;OtherSRS&gt;urn:ogc:def:crs:EPSG::29902&lt;/OtherSRS&gt;</pre>
<p>
To get to this point however is not the simplest of journeys..</p>
<h3>How to Set Up Multiple SRSs in MapServer</h3>
<p style="text-align: justify;">The <a href="http://mapserver.org/ogc/wfs_server.html#configuring-your-mapfile-to-serve-wfs-layers">SRS rules</a> explain how MapServer advertises the available projections for each of your WFS layers:</p>
<blockquote>
<ul>
<li>If a top-level map SRS is defined* then this SRS is used and applies to all layers (feature types) in this WFS. In this case the SRS of individual layers is simply ignored even if it’s set.</li>
<li>If there is no top-level map SRS defined* then each layer is advertised in its own SRS in the capabilities.</li>
<li>By “SRS is defined”, we mean either the presence of a PROJECTION object defined using an EPSG code, or of a “wfs_srs” metadata at this level.</li>
</ul>
</blockquote>
<p style="text-align: justify;">I recommend you read the further explanations in the official documentation, as there are a lot of other rules on how priorities and conflicts between different configuration settings work. From the documentation:</p>
<blockquote><p>Confusing? As a rule of thumb, simply set the wfs_srs at  the map level  (in web metadata) and never set the wfs_srs metadata at  the layer level  and things will work fine for most cases.</p></blockquote>
<p style="text-align: justify;">However this only applies if you don&#8217;t want to use multiple projections. This cut-down example of a map file may help to illustrate what these rules actually look like in code:  <script src="https://gist.github.com/1019212.js"> </script></p>
<p style="text-align: justify;">A few additional notes from spending a number of hours struggling with these:</p>
<ul>
<li style="text-align: justify;">The DefaultSRS is always the first item in the wfs_srs list. <strong>The order these are listed is therefore critical.<br />
</strong></li>
<li style="text-align: justify;">If no metadata is available then the SRS is taken from the Map Projection. In this case there are no OtherSRS values.</li>
<li style="text-align: justify;">I’d recommend <strong>not</strong> sharing the SRS definitions between  WFS and WMS (you can do this with the ows_srs metadata setting) as the order makes no real difference to a WMS service, but is  critical for a WFS service.</li>
<li style="text-align: justify;">You need to set the PROJECTION object for each WFS layer with multiple projections. <em>Even if the layer is in the same projection as the MAP projection. </em>This was probably the hardest issue to track down. If you don&#8217;t set it you end up with the nasty situation of the client BBOX in one projection searching for features in the other projection. It would be nice if MapServer just threw an error at this point. Instead you&#8217;ll likely get a message such as:</li>
</ul>
<pre>&lt;gml:boundedBy&gt;
&lt;gml:Null&gt;missing&lt;/gml:Null&gt;
&lt;/gml:boundedBy&gt;
</pre>
<p></p>
<h3>The WFS Client &#8211; OpenLayers</h3>
<p style="text-align: justify;">Once you&#8217;ve got you DefaultSRS and OtherSRSs set up correctly in MapServer and checked them with the GetCapabilities request, you can to try to connect to them with a real WFS client. The MapInfo desktop WFS involved entering the server name, and selecting layers from a list. The OpenLayers connection was more difficult.</p>
<pre><img class="size-medium wp-image-863 alignright" style="margin: 3px;" title="wfs" src="http://geographika.co.uk/wp-content/uploads/2011/06/wfs-300x180.png" alt="WFS Overlay" width="300" height="180" /></pre>
<p style="text-align: justify;">To add a WFS to OpenLayers, you create a vector layer with the WFS protocol. Make sure the WFS version is set to <strong>1.1.0</strong>. Why? If you use WFS 1.0.0 the srsName is not supported, so you can&#8217;t use OpenLayers to decide in which projection you want your features returned.</p>
<pre>protocol: new OpenLayers.Protocol.WFS({
              featureType: “Test”,
              featurePrefix: "ms",
              srsName: "EPSG:900913",
              version: "1.1.0",
              url: url
           })</pre>
<p style="text-align: justify;">If you set the srsName in the WFS protocol your WFS requests will include now include the srsName (it can also pick this up from the map, but I find it easier to be explicit about projections). If you check your requests in FireBug or Fiddler you can see the XML that is posted to MapServer when you switch on a vector layer:</p>
<pre>&lt;wfs:Query typeName="Test" srsName="EPSG:900913"&gt;</pre>
<p></p>
<p>A full OpenLayers request looks similar to this:</p>
<p><script src="https://gist.github.com/1019119.js"> </script></p>
<p style="text-align: justify;">However there is one more piece of the puzzle left &#8211; as adding the srsName value to the WFS protocol has very little effect! Features will be correctly selected, but they will be returned in the DefaultSRS, in this example EPSG:29902, so they will never appear in OpenLayers. Whether this is an issue with MapServer or the WFS specification I&#8217;m not sure.</p>
<p style="text-align: justify;">What you need to do is to pass the srsName to the URL of your WFS server. E.g.</p>
<p style="text-align: justify;"><a href="http://localhost/mapserver/?map=C:/PathToMapFile/mymap.map&amp;SERVICE=WFS&amp;VERSION=1.1.0&amp;srsName=EPSG:900913">http://localhost/mapserver/?map=C:/PathToMapFile/mymap.map&amp;SERVICE=WFS&amp;VERSION=1.1.0&amp;srsName=EPSG:900913</a></p>
<p style="text-align: justify;">The POST request remains the same, but setting the SRS in the URL forces MapServer to reproject the features. The WFS protocol should therefore look something like this:</p>
<pre>protocol: new OpenLayers.Protocol.WFS({
              featureType: “Test”,
              featurePrefix: "ms",
              srsName: "EPSG:900913",
              version: "1.1.0",
              url: url + "&amp;srsName=EPSG:900913",
           })</pre>
<p>If you enter a SRS which is not listed for your WFS layer you’ll get the following message:</p>
<pre>msWFSGetFeature(): WFS server error. Invalid GetFeature Request:Invalid SRS. 
Please check the capabilities and reformulate your request.</pre>
<p></p>
<p style="text-align: justify;">If all has gone well you&#8217;ll have a MAP file containing WFS layers that can be requested by clients in a variety of projections &#8211; very useful when some people are connecting through a web system based on Web Mercator, and others through a desktop using other datasets projected to national grids.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/xCU14jc48TM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/mapserver-openlayers-and-the-wfs-maze/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/mapserver-openlayers-and-the-wfs-maze?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=mapserver-openlayers-and-the-wfs-maze</feedburner:origLink></item>
		<item>
		<title>Using ArcObjects and .NET in Python</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/kBi3vit0v58/using-arcobjects-and-net-in-python</link>
		<comments>http://geographika.co.uk/using-arcobjects-and-net-in-python#comments</comments>
		<pubDate>Sun, 17 Apr 2011 11:59:41 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[arcobjects]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=853</guid>
		<description><![CDATA[This question was posed on the GIS Stack Exchange, and the replies include a number of interesting approaches. Below is another one. Why not just use .NET? I have several years worth of DLLs built using VB.NET and ArcObjects. Recently I’ve been using more and more open-source libraries, the majority of which can be manipulated <a href='http://geographika.co.uk/using-arcobjects-and-net-in-python'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2011/04/image.png"><img style="display: inline; margin-left: 0px; margin-right: 3px; border: 0pt none;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/04/image_thumb1.png" alt="image" width="229" height="260" align="left" border="0" /></a></p>
<p style="text-align: justify;">This question was posed on the <a href="http://gis.stackexchange.com/questions/80/how-do-i-access-arcobjects-from-python" target="_blank">GIS Stack Exchange</a>, and the replies include a number of interesting approaches. Below is another one.</p>
<h3 style="text-align: justify;">Why not just use .NET?</h3>
<p style="text-align: justify;">I have several years worth of DLLs built using VB.NET and ArcObjects. Recently I’ve been using more and more open-source libraries, the majority of which can be manipulated using Python.</p>
<p style="text-align: justify;">A major advantage of using a interpreted language (rather than one that needs to compile) like Python is that you can easily change paths and variables in a script.</p>
<p style="text-align: justify;">You can deliver a folder of .NET ArcObjects DLLs, a sample Python script and an end user can automate their workflow themselves. This negates the requirement to build a UI on top of your code as a (Python familiar) user can script it themselves.</p>
<p style="text-align: justify;">DLLs still have their place as ArcObjects includes many functions not available in the ESRI Python libraries. It is also easier to write and test ArcObjects code in Visual Studio with all the advantages of error checking and auto-completion.<span id="more-853"></span></p>
<h3 style="text-align: justify;">Options</h3>
<p style="text-align: justify;">Python is a programming language, but it can and has been implemented many times using different underlying technologies. The “default” version of Python is implemented in C (and therefore named <a href="http://en.wikipedia.org/wiki/CPython" target="_blank">CPython</a>). Jython is implemented in Java, and IronPython is implemented in C#.</p>
<p style="text-align: justify;">IronPython therefore seems perfect to use if the majority of your code <a href="http://geographika.co.uk/wp-content/uploads/2011/04/image1.png"><img style="display: inline; margin-left: 5px; margin-right: 0px; border: 0pt none;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/04/image_thumb2.png" alt="image" width="248" height="168" align="right" border="0" /></a>is based around the <a href="http://www.microsoft.com/net/" target="_blank">.NET framework</a>, however as it is separate from standard Python many third-party libraries are incompatible.</p>
<p style="text-align: justify;"><em>This may no longer be true thanks to the <a href="http://www.voidspace.org.uk/ironpython/cpython_extensions.shtml" target="_blank">CPython extensions</a> to IronPython, which embeds a CPython interpreter into IronPython – it sounds crazy but apparently works.</em></p>
<p style="text-align: justify;">Embedding CPython into IronPython relies upon a library called <a href="http://pythonnet.sourceforge.net/readme.html" target="_blank">Python for .NET</a>, which also allows .NET libraries to be used in standard CPython. The library can be used deparately from IronPython, so the solution I ended up using was CPython and the Python for .NET library.</p>
<h3 style="text-align: justify;">Installation</h3>
<ol style="text-align: justify;">
<li>
<div>Go the download page for the Python for .Net project at <a title="http://sourceforge.net/projects/pythonnet/files/" href="http://sourceforge.net/projects/pythonnet/files/">http://sourceforge.net/projects/pythonnet/files/</a>, and download the appropriate zip file for your existing Python installation (2.5, 2.6 or 2.7).</div>
</li>
<li>
<div>Unzip the file to a folder of your choice. Ideally this should be somewhere on the Python path, but in the sample code below you can add a reference to this folder by changing the path to the pythonnet-2.0-alpha2-clr2.0_131_py27_UCS2 folder.</div>
</li>
<li>
<div>That’s all you need to do!</div>
</li>
</ol>
<p style="text-align: justify;">The sample script below shows how to add references to your own DLLs and to the ESRI ArcObject DLLs, open ArcMap, and create classes.</p>
<p><script src="https://gist.github.com/923954.js"> </script></p>
<p style="text-align: justify;">As this approach is not ArcObjects specific you can use classes in any of your other .NET DLLs, and even classes in .NET .exes.</p>
<p style="text-align: justify;">I can now script all the classes in my .NET DLLs through Python – instantly removing the need for hastily put together user interfaces, and fully automating previously manual tasks. It also allows easy passing of data between the ESRI and open source stacks. I’ve only scripted a few processes so far, but I’ve had no issues yet, and at the moment it feels like one of the rare programming occasions where getting things to work together was actually easier than expected.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/kBi3vit0v58" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/using-arcobjects-and-net-in-python/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/using-arcobjects-and-net-in-python?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=using-arcobjects-and-net-in-python</feedburner:origLink></item>
		<item>
		<title>Accessing Cross Domain Data with YQL</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/S1J0gvFk6Fc/accessing-cross-domain-data-with-yql</link>
		<comments>http://geographika.co.uk/accessing-cross-domain-data-with-yql#comments</comments>
		<pubDate>Sun, 10 Apr 2011 12:14:56 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[OpenLayers]]></category>
		<category><![CDATA[geoext]]></category>
		<category><![CDATA[yahoo]]></category>
		<category><![CDATA[yql]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=842</guid>
		<description><![CDATA[The same origin policy prevents code from one domain accessing data from a different domain. For a mapping site requests for KML, GeoRSS, WFS services, and some WMS operations are all affected by this policy, and therefore require a range of workarounds, usually involving a proxy. One solution is the ExtJS ScriptTagProxy that can be <a href='http://geographika.co.uk/accessing-cross-domain-data-with-yql'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><img style="display: inline; margin-left: 0px; margin-right: 0px; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/04/image_thumb.png" border="0" alt="image" width="151" height="166" align="left" />The <a href="http://en.wikipedia.org/wiki/Same_origin_policy" target="_blank">same origin policy</a> prevents code from one domain accessing data from a different domain. For a mapping site requests for KML, GeoRSS, WFS services, and some WMS operations are all affected by this policy, and therefore require a range of workarounds, usually involving a <a href="http://trac.osgeo.org/openlayers/wiki/FrequentlyAskedQuestions#ProxyHost" target="_blank">proxy</a>.</p>
<p style="text-align: justify;">One solution is the ExtJS <a href="http://dev.sencha.com/deploy/dev/docs/?class=Ext.data.ScriptTagProxy" target="_blank">ScriptTagProxy</a> that can be used to retrieve data from an external domain. However for this to work the server must return executable JavaScript code. For example to access an external WMS capabilities file you’d need to set up a special handler on your server to wrap the data in JavaScript before being added to your web page. This pattern is referred to as <a href="http://en.wikipedia.org/wiki/JSONP" target="_blank">JSONP</a> (JSON with padding).</p>
<h3 style="text-align: justify;">YQL</h3>
<p style="text-align: justify;">Thanks to this <a href="http://jawtek.blogspot.com/2009/03/unwritten-guide-to-yahoo-query-langauge.html" target="_blank">Unwritten Guide to Yahoo Query Language</a> it became apparent you can get Yahoo to automatically do this wrapping for you. Whilst using YQL is still technically a proxy, it’s a proxy you don’t have to worry about maintaining.<span id="more-842"></span></p>
<p style="text-align: justify;">I’m not a huge fan of relying on commercial APIs and services, partly as if they are free then they can also change without warning or <a href="http://en.wikipedia.org/wiki/List_of_Yahoo!-owned_sites_and_services#Closed.2Fdefunct_services" target="_blank">disappear</a>, and partly as fully understanding the <a href="http://info.yahoo.com/legal/us/yahoo/yql/yql-4307.html" target="_blank">Terms of Service</a> requires both a law and computer science degree.</p>
<p style="text-align: justify;">However configuring your own proxy and wrapping is a large overhead if accessing data from another domain is the only reason you need server-side code.</p>
<p style="text-align: justify;">YQL looks a lot like standard SQL, but can be used to query data from a URL. Go to the <a href="http://developer.yahoo.com/yql/console/" target="_blank">YQL Console</a> and try out the following query:</p>
<pre style="text-align: justify;">select * from xml where url='http://api.geoext.org/1.0/examples/data/wmscap.xml'
</pre>
<p></p>
<h3 style="text-align: justify;">An External WMS Capabilities Store</h3>
<p style="text-align: justify;">This method can be used to easily access a WMS Capabilities file on an external server. I’ve put a small <a href="http://geographika.co.uk/samples/wms-capabilities/wms-capabilities.html" target="_blank">demo online</a> showing a working example. The source code can be found on <a href="https://bitbucket.org/geographika/wms-capabilities/src/tip" target="_blank">BitBucket</a>.</p>
<p style="text-align: justify;">The example is based on <a href="http://www.geoext.org" target="_blank">GeoExt’s</a> <a href="http://api.geoext.org/1.0/examples/wms-capabilities.html" target="_blank">original WMS Capabilities</a> demo. The code makes use of the ScriptTagProxy, and a slightly modified reader that takes the results part of the JSON (the XML) and passes it on to the standard WMSCapabilitiesReader:</p>
<pre style="text-align: justify;">GeoExt.data.YahooWMSCapabilitiesReader = Ext.extend(GeoExt.data.WMSCapabilitiesReader, {
    readRecords: function(data){
        data = data.results.toString();
        return GeoExt.data.YahooWMSCapabilitiesReader.superclass.readRecords.call(this, data);
    }
});
</pre>
<p></p>
<p style="text-align: justify;">Yahoo have many “clones” of services offered by the other web giants, which whilst well implemented don’t really interest me &#8211; when was the last time you looked at <a href="http://maps.yahoo.com/" target="_blank">Yahoo Maps</a>?.  However along with YQL, Yahoo have a few interesting and unique developer tools such as <a href="http://pipes.yahoo.com/pipes/" target="_blank">Yahoo Pipes</a> and <a href="http://developer.yahoo.com/yui/3/" target="_blank">YUI</a> (in fact ExtJS branched out of YUI), so its worth keeping an eye on the often forgotten man of the Internet.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/S1J0gvFk6Fc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/accessing-cross-domain-data-with-yql/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/accessing-cross-domain-data-with-yql?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=accessing-cross-domain-data-with-yql</feedburner:origLink></item>
		<item>
		<title>Will HTML5 Revolutionise Raster Web GIS?</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/Ldg84KPtysk/will-html5-revolutionise-raster-web-gis</link>
		<comments>http://geographika.co.uk/will-html5-revolutionise-raster-web-gis#comments</comments>
		<pubDate>Fri, 18 Feb 2011 12:09:32 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[OpenLayers]]></category>
		<category><![CDATA[opinion]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[raster]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=835</guid>
		<description><![CDATA[Or perhaps that should be rephrased start browser-based raster GIS? GIS data is split into two base types – vector data – geometric shapes, usually further split into points, lines, and polygons, and raster data – cell-based or “pixelated” data. Graphics on the web mirror this divide. On the vector side SVG – scalable vector <a href='http://geographika.co.uk/will-html5-revolutionise-raster-web-gis'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2011/02/image.png"><img style="display: inline; margin-left: 0px; margin-right: 0px; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/02/image_thumb.png" border="0" alt="image" width="248" height="155" align="left" /></a> Or perhaps that should be rephrased <em>start</em> browser-based raster GIS?</p>
<p style="text-align: justify;">GIS data is split into two base types – vector data – geometric shapes, usually further split into points, lines, and polygons, and raster data – cell-based or “pixelated” data.</p>
<p style="text-align: justify;">Graphics on the web mirror this divide. On the vector side <a href="http://www.w3.org/Graphics/SVG/" target="_blank">SVG</a> – scalable vector graphics, is used in many browsers to display geometric shapes. On the raster side “dumb” images come in many well known formats such as bitmaps, GIFs, PNGs, and JPEGs.</p>
<p style="text-align: justify;">Vector geometries are easily manipulated after drawing as they have an abstract model to work with (the SVG, or KML document), which the browser can then convert to the <a href="http://en.wikipedia.org/wiki/Document_Object_Model" target="_blank">DOM</a>. As an example OpenLayers includes two vector renderers – one for SVG (<a href="http://trac.osgeo.org/openlayers/browser/trunk/openlayers/lib/OpenLayers/Renderer/SVG.js" target="_blank">see source code</a>), one for <a href="http://trac.osgeo.org/openlayers/browser/trunk/openlayers/lib/OpenLayers/Renderer/VML.js" target="_blank">VML</a> (used by the ever-unique IE), and since the start of this year a <a href="http://trac.osgeo.org/openlayers/browser/trunk/openlayers/lib/OpenLayers/Renderer/Canvas.js" target="_blank">new canvas renderer</a>.</p>
<p style="text-align: justify;">The canvas renderer is used to draw features to the <a href="http://en.wikipedia.org/wiki/Canvas_element" target="_blank">new canvas element</a> which is part of the HTML5 specification. This allows access to images loaded into the canvas through new programming interfaces such as the <a href="http://dev.w3.org/html5/2dcontext/#canvasrenderingcontext2d" target="_blank">Canvas 2D Context API</a>.  It is this part of the HTML5 specification that could change the way we work with raster data on the web.</p>
<div style="text-align: justify;"><span id="more-835"></span></div>
<p style="text-align: justify;">The power for raster operations will be based on the <a href="https://developer.mozilla.org/en/Canvas_tutorial/Compositing" target="_blank"><strong>compositing functions</strong></a>. These correspond with various <a href="http://www.quantdec.com/SYSEN597/GTKAV/section9/map_algebra.htm" target="_blank">map algebra</a> functions that have been used by desktop GIS systems for years. To take a few examples the HTML5 <a href="https://developer.mozilla.org/en/Canvas_tutorial/Transformations#Transforms" target="_blank">transforms</a> include the following:</p>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2011/02/image1.png"><img style="display: inline; margin-left: 0px; margin-right: 0px; border-width: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/02/image_thumb1.png" border="0" alt="image" width="126" height="252" align="left" /></a></p>
<p style="text-align: justify;">
<blockquote style="text-align: justify;"><p>XOR &#8211; Shapes are made transparent where both overlap and drawn normal everywhere else.</p>
<p>LIGHTER &#8211; Where both shapes overlap the color is determined by adding color values.</p>
<p>The clip() function can be used to create masking areas, and to speed up the processing.</p></blockquote>
<p style="text-align: justify;">These three basic functions cover many of the key uses of raster GIS. By adding or subtracting the colour values in a raster cell, you are in effect changing the raster data itself.</p>
<p style="text-align: justify;">For example it would be possible for example to multiply a soil type raster dataset, with a rainfall raster dataset to produce a third raster dataset giving indications of crop suitability. Or as this is in the browser a user could choose their own weightings to instantly multiple different land use classes to producing a new map.</p>
<h3 style="text-align: justify;">It’s Already Here…</h3>
<p style="text-align: justify;">For excellent examples of these types of pixel manipulations go to <a href="http://beej.us/blog/2010/02/html5s-canvas-part-ii-pixel-manipulation/" target="_blank">Beej’s Bit Bucket</a> and check out his <a href="http://beej.us/blog/wp-content/uploads/2010/03/canvasbluegoat.html" target="_blank">blue goat</a>, <a href="http://beej.us/x/scratcher/" target="_blank">scratcher demo</a>, and his challenge to create <a href="http://en.wikipedia.org/wiki/Sobel_operator" target="_blank">Sobel edge detection</a> using canvas.</p>
<p style="text-align: justify;">Matthew Trost has created a brilliant <a href="http://www.matthewtrost.org/projects/astar/" target="_blank">path finding demo</a> using canvas and JavaScript. Whilst the target audience for is game developers, it inadvertently implements several of the <a href="http://www.esri.com/software/arcgis/extensions/networkanalyst/key-features.html" target="_blank">key functions</a> of raster-based GIS.</p>
<p style="text-align: justify;">It will be coming to OpenLayers soon – the evaluation of HTML5 and OpenLayers is presented <a href="http://trac.osgeo.org/openlayers/wiki/Future/OpenLayersAndHTML5" target="_blank">here</a>. There is a demo showing layers in a canvas element in <a href="http://dev.openlayers.org/sandbox/krisgeus/openlayers/examples/transitionWithCanvas.html" target="_blank">krisgeus’s sandbox</a>. And <a href="http://www.camptocamp.com/" target="_blank">CampToCamp</a> have an impressive demo to dynamically <a href="http://dev.openlayers.org/sandbox/camptocamp/canvas/openlayers/examples/elevationCanvas.html" target="_blank">display and graph elevation values</a>.</p>
<p style="text-align: justify;">
<h3 style="text-align: justify;">Challenges and Challengers<a href="http://geographika.co.uk/wp-content/uploads/2011/02/image2.png"><img style="display: inline; margin-left: 0px; margin-right: 0px; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/02/image_thumb2.png" border="0" alt="image" width="142" height="189" align="right" /></a></h3>
<p style="text-align: justify;">Currently it is easier to run raster processing on a server, and return the results to a user. With an increase in cloud-based processing responses times will get even shorter, so developers will have to decide which approach will be easier to maintain and implement, whilst meeting users’ expectations and requirements.</p>
<p style="text-align: justify;">In an ideal world, processing could be balanced between the client and server to bring about the fastest results possible, however coding for two different architectures likely rules this out for all but high traffic sites.</p>
<p style="text-align: justify;">As pointed out <a href="http://www.kontain.com/fi/entries/94636/" target="_blank">here</a> <em>“performance can be a challenge since bitmap operations are very processing expensive, especially at high resolutions.” </em>A major challenge of creating web sites is designing for the lowest common denominator – what happens if a user connects to a site using IE6 on a 15 year-old desktop?</p>
<p style="text-align: justify;">Whether or not it will be more practical to do raster analysis in the browser rather than on the server is up for debate. But home computers aren’t going to get slower, and as HTML5 becomes the norm rather than the exception raster GIS on the web becomes a very interesting terrain.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/Ldg84KPtysk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/will-html5-revolutionise-raster-web-gis/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/will-html5-revolutionise-raster-web-gis?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=will-html5-revolutionise-raster-web-gis</feedburner:origLink></item>
		<item>
		<title>Linear Referencing in SQL Server 2008</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/qhmZ4U29lhE/linear-referencing-in-sql-server-2008</link>
		<comments>http://geographika.co.uk/linear-referencing-in-sql-server-2008#comments</comments>
		<pubDate>Sat, 22 Jan 2011 22:17:00 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[geodatabases]]></category>
		<category><![CDATA[sql server 2008]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[linear referencing]]></category>
		<category><![CDATA[network]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=819</guid>
		<description><![CDATA[Linear referencing is used to define features in relation to existing line features. These new features can either be points or lines. For example a water monitoring station can be defined as 300m along a section of river, or a stretch of road can be defined as requiring repairs, from 220m along to 270m along. <a href='http://geographika.co.uk/linear-referencing-in-sql-server-2008'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://en.wikipedia.org/wiki/Linear_Reference_System" target="_blank"><img style="margin: 0px 5px; display: inline; border: 0pt none;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/01/image_thumb1.png" border="0" alt="image" width="303" height="241" align="left" />Linear referencing</a> is used to define features in relation to existing line features. These new features can either be points or lines. For example a water monitoring station can be defined as 300m along a section of river, or a stretch of road can be defined as requiring repairs, from 220m along to 270m along. Most GISs implement this functionality &#8211; for details look at the <a href="http://webhelp.esri.com/arcgisdesktop/9.2/index.cfm?TopicName=An_overview_of_linear_referencing" target="_blank">ESRI</a> and <a href="http://grass.osgeo.org/grass64/manuals/html64_user/lrs.html" target="_blank">GRASS</a> help pages.</p>
<p style="text-align: justify;">In terms of storing linear referenced point features, you only need three fields – an ID of the original line feature, an ID of the  feature to reference along the line, and a M value – the measurement along the original feature. Line features require two measurement fields, a starting distance, and an end distance.</p>
<p><span id="more-819"></span></p>
<h3 style="text-align: justify;">Dynamic Segmentation</h3>
<p style="text-align: justify;">Linear referenced features can be stored in a standard table structure. What is more complicated however is displaying these features again – a process (termed, at least by ESRI) as dynamic segmentation – the process of dynamically splitting, or segmenting, an existing feature. It’s a step up from a standard table join, but essentially has the same purpose of relating two records in a database.</p>
<p style="text-align: justify;"><a href="http://sqlspatialtools.codeplex.com/" target="_blank">SQL Spatial Tools</a> is an open source collection of functions to manipulate spatial data within SQL Server 2008. It contains a  LocateAlongGeom function that “<em>takes a geometry linestring and finds the point a given distance along it.” </em>So that takes care of displaying linear referenced points. What it lacks at the moment (and can be found in other spatial databases such as <a href="http://postgis.refractions.net/documentation/manual-svn/reference.html#Linear_Referencing" target="_blank">PostGIS</a> and <a href="http://www.oracle.com/technology/sample_code/products/spatial/htdocs/lrs_sample/lrs_example_readme.htm" target="_blank">Oracle</a>), is a way to dynamically create line features using a distance from and a distance to. Fortunately the SQL datatypes and existing spatial tool functions make this easy to add in.</p>
<h3 style="text-align: justify;">The Code</h3>
<p style="text-align: justify;">The CreateLinearReferenceFeature code can be seen in the <a href="https://bitbucket.org/geographika/sql-server-spatial-tools/src/tip/Functions.cs" target="_blank">Function.cs file</a>. The full project is available for download and modifications in BitBucket at <a title="http://bitbucket.org/geographika/sql-server-spatial-tools" href="https://bitbucket.org/geographika/sql-server-spatial-tools" target="_blank">https://bitbucket.org/geographika/sql-server-spatial-tools</a>. As I’m never sure if CodePlex accepts patches or not, I decided to create my own fork of the code. I have uploaded the <a href="http://sqlspatialtools.codeplex.com/SourceControl/list/patches" target="_blank">key files to CodePlex</a> where they will await evaluation. I’d imagine however that there will be a new release of the tools by Microsoft for the new <a href="http://www.microsoft.com/sqlserver/en/us/product-info/future-editions.aspx" target="_blank">Denali release</a> of SQL Server 2008, so this funciton may have to be merged into a new release in the future.</p>
<p style="text-align: justify;">The SQL Spatial Tools compile to a DLL, and the assembly needs to be registered with the database along with all the associated functions. I modified the <a href="http://sqlspatialtools.codeplex.com/SourceControl/changeset/view/61525#255008" target="_blank">original SQL script</a> to include the <a href="https://bitbucket.org/geographika/sql-server-spatial-tools/src/tip/SQL%20Scripts/Register.sql" target="_blank">new functions</a>.  There is also an  <a href="https://bitbucket.org/geographika/sql-server-spatial-tools/src/9fa85d45d386/SQL%20Scripts/Unregister.sql" target="_blank">unregister.sql</a> script to remove the assembly and functions. A few caveats on the linear refence function:</p>
<ul style="text-align: justify;">
<li>the code has not been tested on the new <a href="http://www.sqlskills.com/BLOGS/BOBB/post/New-curve-types-in-SQL-Server-Denali-are-now-in-OGC-spec.aspx" target="_blank">SQL Server 2008 curve type</a></li>
<li>the project is written in C# and compiled with Visual Studio 2010</li>
<li>if you give the function a MeasureTo value greater than the length of the feature you will receive the following System.ArgumentException: “<em>MeasureTo value must be less than the length of the feature. </em>”</li>
</ul>
<p style="text-align: justify;">To test out the functionality you can use the SQL script below. Feedback and comments appreciated!And no need to store hundreds of little line geometries in the same database as your nice clean line networks.</p>
<p style="text-align: justify;"><script src="https://gist.github.com/791340.js?file=LinearReferencingExample.sql"></script></p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/qhmZ4U29lhE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/linear-referencing-in-sql-server-2008/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/linear-referencing-in-sql-server-2008?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=linear-referencing-in-sql-server-2008</feedburner:origLink></item>
		<item>
		<title>Creating Previews of PDF Maps</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/B7kYa4uRZvk/creating-previews-of-pdf-maps</link>
		<comments>http://geographika.co.uk/creating-previews-of-pdf-maps#comments</comments>
		<pubDate>Tue, 18 Jan 2011 18:27:21 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[documentation]]></category>
		<category><![CDATA[general]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[maps]]></category>
		<category><![CDATA[pdfs]]></category>
		<category><![CDATA[previews]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=811</guid>
		<description><![CDATA[The MapFish print module used by both MapFish and GeoExt generates PDF maps that can be saved to clients machines. Over time you can acquire hundreds of different PDFs, but unfortunately Windows XP does not generate thumbnail previews to help find them again later. The script below solves this problem by generating a PNG image <a href='http://geographika.co.uk/creating-previews-of-pdf-maps'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2011/01/image.png"><img style="margin: 0px 5px 0px 0px; display: inline; border-width: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2011/01/image_thumb.png" border="0" alt="image" width="292" height="323" align="left" /></a>The <a href="http://geographika.co.uk/?p=727" target="_blank">MapFish print module</a> used by both MapFish and GeoExt generates PDF maps that can be saved to clients machines. Over time you can acquire hundreds of different PDFs, but unfortunately Windows XP does not generate thumbnail previews to help find them again later.</p>
<p style="text-align: justify;">The script below solves this problem by generating a PNG image of all the PDFs in a folder. The image to the left shows the results of the script when run on a series of <a href="http://www.un.org/Depts/Cartographic/english/htmain.htm" target="_blank">UN Mission Maps</a>.</p>
<p style="text-align: justify;">This relies on two programs to be installed. <a href="http://www.imagemagick.org/script/binary-releases.php#windows" target="_blank">ImageMagick</a> – a free image conversion software package, and <a href="http://sourceforge.net/projects/ghostscript/files/GPL Ghostscript/" target="_blank">GhostScript</a> another free program that can be used to access, read, and create PDF files. You may have to reboot your machine after installing these programs for the script to run successfully.</p>
<p style="text-align: justify;">The script uses a <a href="http://www.imagemagick.org/script/convert.php" target="_blank">convert</a> utility program which comes with ImageMagick. <span id="more-811"></span></p>
<p><script src="https://gist.github.com/784880.js"> </script></p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/B7kYa4uRZvk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/creating-previews-of-pdf-maps/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/creating-previews-of-pdf-maps?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=creating-previews-of-pdf-maps</feedburner:origLink></item>
		<item>
		<title>Assigning Points to Polygons in SQL Server</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/wxdJaNTo-14/assigning-points-to-polygons-in-sql-server</link>
		<comments>http://geographika.co.uk/assigning-points-to-polygons-in-sql-server#comments</comments>
		<pubDate>Thu, 23 Dec 2010 13:48:53 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[sql server 2008]]></category>
		<category><![CDATA[recipe]]></category>
		<category><![CDATA[spatial]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=800</guid>
		<description><![CDATA[A common requirement in GIS is to be able to find the number of points in a polygon to answer a question such as “how many towns are in this county.” With the spatial operations in SQL Server this can be calculated dynamically, however for large spatial datasets it can often take several minutes to <a href='http://geographika.co.uk/assigning-points-to-polygons-in-sql-server'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/12/image4.png"><img style="margin: 0px 5px 5px 0px; display: inline; border-width: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/12/image_thumb4.png" border="0" alt="image" width="244" height="171" align="left" /></a></p>
<p style="text-align: justify;">A common requirement in GIS is to be able to find the number of points in a polygon to answer a question such as “how many towns are in this county.”</p>
<p style="text-align: justify;">With the spatial operations in SQL Server this can be calculated dynamically, however for large spatial datasets it can often take several minutes to run the query. If a user is running the query through a web interface they will either give up, or the connection will time out.</p>
<p style="text-align: justify;">It can be useful to assign all features to a parent polygon in the database so these calculations are almost instant. To do this run the following SQL:</p>
<p style="text-align: justify;"><script src="https://gist.github.com/747294.js?file=assign_points_to_polygons.sql"></script> <span id="more-800"></span></p>
<p>It would be nicer to have this step automated at the database level, by having spatial query results available in a dynamic calculated column. However at present this is not possible. You will get an error such as “<em>Computed column &#8216;Centroid&#8217; in table &#8216;MyTable’ cannot be persisted because the column type, &#8216;geometry&#8217;, is a non-byte-ordered CLR type</em>.”  An alternative is to create an <a href="http://msdn.microsoft.com/en-us/library/dd171921.aspx" target="_blank">Indexed View</a>,  or to use a trigger to populate this field automatically.</p>
<p><strong>Update </strong>- storing geometry in persisted columns <a href="http://blogs.msdn.com/b/edkatibah/archive/2011/01/25/spatial-support-for-persisted-computed-columns-in-denali-ctp1.aspx" target="_blank">will be available in SQL Server 2008 Denali CTP1</a>.</p>
<h3 style="text-align: justify;">Displaying Points and Polygons</h3>
<p>The image of points and polygons for this post was generated with the following SQL. It takes advantage of the fact that any geometry type (points, lines, and polygons) can be stored in a single geometry field, and therefore be displayed at the same time.</p>
<p><script src="https://gist.github.com/747318.js?file=show_points_and_polys.sql"></script></p>
<p style="text-align: justify;">This post also allowed me to create my first <a href="https://gist.github.com/" target="_blank">Gist</a> in GitHub. SQL code was “<em>prettified</em>” using Simple-Talks online <a href="http://extras.sqlservercentral.com/prettifier/prettifier.aspx" target="_blank">SQL Prettifier</a>.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/wxdJaNTo-14" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/assigning-points-to-polygons-in-sql-server/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/assigning-points-to-polygons-in-sql-server?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=assigning-points-to-polygons-in-sql-server</feedburner:origLink></item>
		<item>
		<title>A Proxy for IIS and .NET</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/SFTT46MG5bQ/a-proxy-for-iis-and-net</link>
		<comments>http://geographika.co.uk/a-proxy-for-iis-and-net#comments</comments>
		<pubDate>Tue, 07 Dec 2010 10:17:12 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[OpenLayers]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[proxy]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=787</guid>
		<description><![CDATA[Due to the same origin policy any data from a remote server cannot be (easily) added to a web application on your own server. This issue also applies to WFS (Web Feature Services) and OpenLayers. There is a Python script that can be used to get round this issue, but I preferred to have a <a href='http://geographika.co.uk/a-proxy-for-iis-and-net'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><img class="alignleft" style="margin-left: 5px; margin-right: 5px;" title="Proxy Server" src="http://upload.wikimedia.org/wikipedia/commons/thumb/f/fb/Schematic_Proxy_Server.svg/350px-Schematic_Proxy_Server.svg.png" alt="Proxy Server" width="178" height="70" />Due to the <a href="http://en.wikipedia.org/wiki/Same_origin_policy">same origin policy</a> any data from a remote server cannot be (easily) added to a web application on your own server. This issue also applies to <a href="http://trac.osgeo.org/openlayers/wiki/FrequentlyAskedQuestions#ProxyHost">WFS (Web Feature Services) and OpenLayers</a>. There is a <a href="http://trac.osgeo.org/openlayers/browser/trunk/openlayers/examples/proxy.cgi">Python script</a> that can be used to get round this issue, but I preferred to have a native .NET equivalent.</p>
<p style="text-align: justify;">On the OpenLayers Mailing List <a href="http://osgeo-org.1803224.n2.nabble.com/ProxyHost-as-c-httphandler-td5593858.html#a5593858">Diego Guidi pointed to an opensource .NET proxy</a>. A proxy makes a request to a remote URL, reads the response, and then sends it to the client so it appears all data comes from the same server.</p>
<p style="text-align: justify;">The .NET proxy is written by <a href="http://pajhome.org.uk/">Paul Johnston</a>, and can be found at <a title="http://code.google.com/p/iisproxy/" href="http://code.google.com/p/iisproxy/">http://code.google.com/p/iisproxy/</a>. I made a few minor changes as follows:</p>
<ul style="text-align: justify;">
<li>
<div>increased the byte size for reading responses to <a href="http://code.google.com/p/iisproxy/issues/detail?id=7">resolve this issue</a></div>
</li>
<li>
<div>added support for PUT requests</div>
</li>
<li>
<div>temporarily removed GZIP compression due to invalid responses and a possible <a href="http://stackoverflow.com/questions/4255521/compression-header-bug-in-net-httpwebrequest">bug</a> in .NET</div>
</li>
</ul>
<p style="text-align: justify;">The proxy can be used for any requests and is not limited to just OpenLayers. My source files can be found at <a title="http://bitbucket.org/geographika/openlayers/src/bfeab6a9971a/iisproxy/" href="http://bitbucket.org/geographika/openlayers/src/bfeab6a9971a/iisproxy/">http://bitbucket.org/geographika/openlayers/src/bfeab6a9971a/iisproxy/</a></p>
<p style="text-align: justify;">I’d recommend reading the original project’s <a href="http://code.google.com/p/iisproxy/source/browse/trunk/README.txt">README</a> file which goes through compilation and installation, but I’ve added my own notes below. <span id="more-787"></span></p>
<h3 style="text-align: justify;">Compiling the Proxy</h3>
<p style="text-align: justify;">To compile the proxy download the <a href="http://bitbucket.org/geographika/openlayers/src/bfeab6a9971a/iisproxy/">source</a>, open the Windows command prompt and run the following commands:</p>
<ul style="text-align: justify;">
<li>
<div>cd C:\PathToIISProxyFolder</div>
</li>
<li>
<div>build.cmd</div>
</li>
</ul>
<p style="text-align: justify;">The build.cmd file is hardcoded to compile the code for .NET 2.0 (located at C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc), but you should be able to compile it for higher versions of .NET.</p>
<h3 style="text-align: justify;">Configuring the Proxy</h3>
<p style="text-align: justify;">The important thing to remember is that your folder structure on your local server <em>must match</em> the folder structure on your remote server. So if you wish to get requests back from <a href="http://mapserver.org/wfsservice/">http://mapserver.org/wfsservice/</a> you need to create a local application at <a href="http://localhost/wfsservice">http://localhost/wfsservice</a>.</p>
<h3 style="text-align: justify;">In XP / IIS 5.1</h3>
<p style="text-align: justify;">Windows XP Professional comes with IIS 5.1. This is not installed by default so you may need to go to Control Panel &gt;&gt; Add or Remove Programs &gt;&gt; Add / Remove Windows Components.</p>
<p style="text-align: justify;">Once installed you can create a new folder in C:\Inetpub\wwwroot and name it wfsservice. Copy the IISProxy \bin folder and web.config into this folder.</p>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/12/image.png"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/12/image_thumb.png" border="0" alt="image" width="138" height="47" /></a> Next open the IIS Manager (in Control Panel &gt;&gt; Administrative Tools), navigate to the wfsservice folder, right-click, and select properties. You need to click the Create button to turn this into a web application.</p>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/12/image1.png"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/12/image_thumb1.png" border="0" alt="image" width="324" height="109" /></a></p>
<p style="text-align: justify;">Once the application is created, click the Configuration button.  On the Mappings tab select Add. This step ensures all web requests to your application are sent to the proxy DLL. As the DLL is written for ASP.NET it needs to be run by the aspnet_isapi.dll. Different versions of this DLL may be installed on your machine.</p>
<p style="text-align: justify;">I compiled the proxy for .NET 2 and the DLL I selected is located at C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll.</p>
<p style="text-align: justify;">There is a slight bug in the form which means you may have to click in and out of the Executable box before the OK button becomes active. The extension of .* indicates that any web request (.html, .aspx, .json) should all be handled by the proxy DLL.</p>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/12/image2.png"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/12/image_thumb2.png" border="0" alt="image" width="327" height="189" /></a>I deselected the “Check that file exists” box as I want all requests to be handled remotely even if there is no remote file. I also want the proxy to handle all types of HTTP requests (GET, POST, PUT, DELETE) so selected the “All Verbs” option.</p>
<h3 style="text-align: justify;">In Windows 7 / IIS7</h3>
<p style="text-align: justify;">In Windows 7 the installation process should be simpler when configured using the Integrated Pipeline mode. This <a href="http://learn.iis.net/page.aspx/508/wildcard-script-mapping-and-iis-7-integrated-pipeline/">article details</a> how using IIS7 Integrated Pipeline mode is more efficient than the wildcard method used above.</p>
<p style="text-align: justify;">Create a folder to match the name of the remote folder, and in IIS Manager convert it to an application. Copy the web.config and \bin folder as before. However the web.config is slightly different and should be similar to below (remember only the root name of the remote server should be used with no backslashes).</p>
<pre style="text-align: justify;">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;configuration&gt;
    &lt;appSettings&gt;
        &lt;add key="proxyUrl" value="<a href="http://mapserver.org">http://mapserver.org"</a> /&gt;
    &lt;/appSettings&gt;
   &lt;system.webServer&gt;
        &lt;handlers&gt;
            &lt;add name="ReverseProxy" verb="*" path="*.*" type="ReverseProxy.ReverseProxy, ReverseProxy" /&gt;
        &lt;/handlers&gt;
    &lt;/system.webServer&gt;
&lt;/configuration&gt;</pre>
<p style="text-align: justify;">There has also been an issue in IIS7 of the proxy returning security errors such as &#8211; &#8220;Request for the permission of type &#8216;System.Web.AspNetHostingPermission, System..&#8221;</p>
<p style="text-align: justify;">The fix for this is to set LoadProfile to True for the application pool &#8211; <a href="http://dbvt.com/blog/post/AspNetHostingPermission-Security-Exception-Fix-with-Ajax-in-IIS7.aspx">via Dave Burke</a>.</p>
<h3 style="text-align: justify;">Debugging</h3>
<p style="text-align: justify;">If you have issues with timeouts and hanging responses you can debug the proxy code on your own machine by attaching to the ASP.NET process in Visual Studio – Debug &gt;&gt; Attach to Process. Set a breakpoint in the code and then trigger a request either in your browser or using <a href="http://www.fiddler2.com/fiddler2/">Fiddler</a>.</p>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/12/image3.png"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/12/image_thumb3.png" border="0" alt="image" width="435" height="151" /></a></p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/SFTT46MG5bQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/a-proxy-for-iis-and-net/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/a-proxy-for-iis-and-net?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=a-proxy-for-iis-and-net</feedburner:origLink></item>
		<item>
		<title>Creating a Geodesic Circle in OpenLayers</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/6qzTAq86j2Y/creating-a-geodesic-circle-in-openlayers</link>
		<comments>http://geographika.co.uk/creating-a-geodesic-circle-in-openlayers#comments</comments>
		<pubDate>Sat, 27 Nov 2010 16:49:50 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[OpenLayers]]></category>
		<category><![CDATA[buffer]]></category>
		<category><![CDATA[geodesic]]></category>
		<category><![CDATA[geometry]]></category>
		<category><![CDATA[polygon]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=765</guid>
		<description><![CDATA[I recently asked a question on GIS Stack Exchange on how to create a  buffer around a point that took into account the curvature of the earth. OpenLayers has support for geodesic measurements, but not creating geodesic polygons. Drawing a standard polygon on a Mercator projected map can produce features with very different measurements from <a href='http://geographika.co.uk/creating-a-geodesic-circle-in-openlayers'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">
<p style="text-align: justify;"><a href="http://www.flickr.com/photos/nicoyogui/3898776967/"><img style="display: inline; margin-left: 0px; margin-right: 5px; border: 0pt none;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/11/image5.png" border="0" alt="image" width="256" height="176" align="left" /></a></p>
<p style="text-align: justify;">I recently asked a question on <a href="http://gis.stackexchange.com/questions/3264/using-geodesic-measurements-for-cirle-radii" target="_blank">GIS Stack Exchange</a> on how to create a  buffer around a point that took into account the curvature of the earth. OpenLayers has support for <a href="http://en.wikipedia.org/wiki/Geodesic">geodesic measurements</a>, but not creating geodesic polygons. Drawing a standard polygon on a Mercator projected map can produce features with very different measurements from their intended &#8220;on the ground&#8221; equivalents. <em> </em></p>
<p style="text-align: justify;"><a href="http://www.cleverelephant.ca/">Paul Ramsey</a> pointed out that <em>“the scale errors for Mercator are very high indeed (infinite, in fact, at the poles) increasing as you head north/south from the true scale latitude.” </em>In fact drawing a circle (in Ireland &#8211; 53 degrees North) with a 10km geometric radius produced a circle with an on the ground radius of 6km.  A huge margin of error over a very short distance (see a <a href="http://geographika.co.uk/watch-out-for-openlayer-distances">previous post</a> on the same subject).</p>
<p style="text-align: justify;">After a useful answer from <a href="http://blog.shoutis.org/">Dan Shoutis</a>, it appeared most of the work to implement geodesic circles was already available in the OpenLayers API. The <a href="http://trac.osgeo.org/openlayers/browser/trunk/openlayers/lib/OpenLayers/Util.js">OpenLayers’ geodesic functions</a> are based on code adapted from Chris Veness work at <a href="http://www.movable-type.co.uk/scripts/latlong-vincenty-direct.html" target="_blank">http://www.movable-type.co.uk/scripts/latlong-vincenty-direct.html</a>.</p>
<p style="text-align: justify;">The code to create a regular (non-geodesic) polygon can be seen in the OpenLayers source <a href="http://trac.osgeo.org/openlayers/browser/trunk/openlayers/lib/OpenLayers/Geometry/Polygon.js">here</a>. There is a function added after the class OpenLayers.Geometry.Polygon.createRegularPolygon that can be used to <em>“create a regular polygon around a radius. Useful for creating circles and the like.” </em></p>
<p style="text-align: justify;">This function only required a couple of changes &#8211; notably using Longitude and Latitude and rather than X and Ys, to produce geodesic polygons. If you are using the Mercator projection then transformations requires <a href="http://proj4js.org/" target="_blank">proj4js</a> support.<span id="more-765"></span></p>
<h2 style="text-align: justify;">Code</h2>
<p style="text-align: justify;">An online demo of the function is available at <a title="http://geographika.co.uk/samples/geodesic/" href="http://geographika.co.uk/samples/geodesic/">http://geographika.co.uk/samples/geodesic/</a>. The adapted function can be seen at <a title="http://geographika.co.uk/samples/geodesic/GeodesicPolygon.js" href="http://geographika.co.uk/samples/geodesic/GeodesicPolygon.js">http://geographika.co.uk/samples/geodesic/GeodesicPolygon.js</a>.</p>
<p style="text-align: justify;">I have uploaded the full source code for the demo to <a title="http://bitbucket.org/geographika/openlayers/src" href="http://bitbucket.org/geographika/openlayers/src">http://bitbucket.org/geographika/openlayers/src</a>.</p>
<p style="text-align: center;"><a href="http://geographika.co.uk/samples/geodesic/" target="_blank"><img class="aligncenter" style="display: inline; border: 0pt none;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/11/image_thumb5.png" border="0" alt="image" width="297" height="206" align="center" /></a></p>
<p style="text-align: left;">Just don’t try drawing circles around the map edges..</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/6qzTAq86j2Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/creating-a-geodesic-circle-in-openlayers/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/creating-a-geodesic-circle-in-openlayers?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=creating-a-geodesic-circle-in-openlayers</feedburner:origLink></item>
		<item>
		<title>MapFish Print Module for IIS</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/fxB8O8Dwppc/mapfish-print-module-for-iis</link>
		<comments>http://geographika.co.uk/mapfish-print-module-for-iis#comments</comments>
		<pubDate>Wed, 10 Nov 2010 15:42:48 +0000</pubDate>
		<dc:creator>amercader</dc:creator>
				<category><![CDATA[mapfish]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[printing java pylons github amercader]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/mapfish-print-module-for-iis</guid>
		<description><![CDATA[This is a guest post by Adrià Mercader. Even in the current digital era, being able to print maps from geospatial applications is still a very commonly requested feature. Traditionally, there have been two main approaches to the map printing on browser applications: handling it either on the client or on the server. In the <a href='http://geographika.co.uk/mapfish-print-module-for-iis'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/11/image2.png"><img style="display: inline; margin-left: 0px; margin-right: 0px; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/11/image_thumb2.png" border="0" alt="image" width="184" height="100" align="left" /></a> <em>This is a guest post by </em><strong><a href="http://amercader.net/" target="_blank">Adrià Mercader</a></strong>.</p>
<p style="text-align: justify;">Even in the current digital era, being able to print maps from geospatial applications is still a very commonly requested feature. Traditionally, there have been two main approaches to the map printing on browser applications: handling it either on the client or on the server. In the first case, a new page is opened with the suitable size for a common paper format (e.g. A4 portrait) and is printed with the browser&#8217;s print function. This is probably the easiest way to go if you have a very basic map and you don&#8217;t need a complex layout, and big guys like Google Maps do it this way. The second option is based on sending all necessary information to a remote printing service, which will produce an output file (generally a PDF) ready to be printed. This allows for more complex layouts, different page sizes, etc. but with the drawback of being more difficult to build and maintain.</p>
<p style="text-align: justify;">Fortunately though, the <a href="http://mapfish.org">MapFish</a> mapping framework includes a powerful <a href="http://mapfish.org/doc/print/">printing module</a> that allows you to define complex layouts and provides a protocol that can be integrated seamlessly with <a href="http://www.geoext.org/">GeoExt</a> based applications. The layouts can include legends, attribute tables, external images and custom variables sent from the client, and are configured via files with the YAML format. The MapFish site has a <a href="http://mapfish.org/doc/print/configuration.html">complete reference</a> of the configuration file syntax.</p>
<p style="text-align: justify;"><span id="more-727"></span></p>
<p style="text-align: justify;">If you want to use the MapFish printing service out of the box, you need to install it in a Java servlet container like Tomcat or use it as part of the complete MapFish Python framework (See the <a href="http://mapfish.org/doc/print/installation.html">Installation page</a> for full details). But if you have an existing infrastructure, these two options can seem like overkill. In our particular case, the printing service was needed for an existing application served under IIS with <a href="http://sourceforge.net/apps/trac/pyisapie">PyISAPIe</a>, so we had a look on how to isolate the printing functionality from the rest of the framework.</p>
<p style="text-align: justify;">It turned out to be relatively easy: the actual work of generating the PDF file with the provided spec is done by a <a href="http://en.wikipedia.org/wiki/JAR_%28file_format%29">JAR file</a> (a standalone Java application packaged into a single zip-like file). Besides, there is a controller which handles the requests, calls the JAR with the appropriate parameters and returns the response. This <a href="http://trac.mapfish.org/trac/mapfish/browser/framework/server/trunk/mapfish/controllers/printer.py">controller file</a> is the key, and our work basically consisted of adapting the Paster and Pylons specific code to PyISAPIe code. The same philosophy can be adapted to any language or server: you will need a controller that gets the requests, speaks with the JAR file and returns the output.</p>
<p style="text-align: justify;">The code is Open Source and you can have a look at it on the GitHub repository:</p>
<p style="text-align: justify;"><a href="https://github.com/amercader/MapFish-Print-IIS">https://github.com/amercader/MapFish-Print-IIS</a></p>
<p style="text-align: justify;">The following are the steps you have to follow to get it up and running. There aren&#8217;t any particularly complicated steps, but you have to be sure to not miss anything.</p>
<h3 style="text-align: justify;">Requirements</h3>
<ul style="text-align: justify;">
<li>
<div>Python 2.5+</div>
</li>
<li>
<div>IIS 7.0 (Not tested under IIS 6.0)</div>
</li>
<li>
<div>PyISAPIe 1.1.0+</div>
</li>
<li>
<div>Java Runtime Environment 1.5+</div>
</li>
<li>
<div>MapFish print module JAR file</div>
</li>
</ul>
<h3 style="text-align: justify;">Installation</h3>
<ol style="text-align: justify;">
<li>Your server will need the <a href="http://www.java.com/en/download/index.jsp">Java Runtime Environment</a> (which can be a Windows x64 version). You may need to restart the machine to update the environment variables (JAVA_HOME). If you plan to compile the MapFish print module yourself, you will also need JDK 1.5+.</li>
<li>You will obviously need the MapFish print module JAR file. Compile it following these instructions:<a href="http://mapfish.org/doc/print/installation.html#compilation">http://mapfish.org/doc/print/installation.html#compilation</a>If you don&#8217;t want or can&#8217;t compile it, you can use a pre-compiled one, <a href="https://github.com/downloads/amercader/MapFish-Print-IIS/print-standalone-1.2.jar">available here</a>, but note that this may not be the most recent version of the print module. Copy the JAR file in the directory of your choice.</li>
<li>Copy a YAML configuration file for the print service in the directory of your choice and edit it as needed. You can find samples in the &#8216;samples&#8217; directory of the MapFish print module source downloaded in the previous point.</li>
<li>Install and configure PyISAPIe. You can follow the instructions described on <a href="http://geographika.co.uk/setting-up-python-on-iis7">this post</a> or in the README file included with PyISAPIe . If you want to run a 64 bit version, have a look at <a href="http://geographika.co.uk/compiling-a-64-bit-version-of-pyisapie">this post</a>.</li>
<li>Download the <a href="https://github.com/amercader/MapFish-Print-IIS/zipball/master">latest version</a> of the package. Copy the files contained (Http and WWW modules and the printer.ini file) where the PyISAPIe DLL can find them. The easier choice is in the same folder as the DLL. You may want to move Http and WWW, e.g to site-packages, but the printer.ini file must be located in the DLL directory.</li>
<li>Edit printer.ini to define the configuration options:
<ul>
<li>
<div>Path to the MapFish print module JAR file, compiled in the first point.</div>
</li>
<li>
<div>Path to the YAML configuration file for the print service.</div>
</li>
<li>
<div>The temporary directory that will use the service to store the generated files. Please note that the user running the application on IIS must have full access to this directory (i.e. write and delete files). If commented out in the printer.ini file, the application will try to use the default OS temporary directory (the one returned by <code>gettempdir()</code>)</div>
</li>
</ul>
</li>
<li>Create a virtual directory in IIS, and add the PyISAPIe DLL as a <em>Wildcard Script Map</em>.<a href="http://geographika.co.uk/wp-content/uploads/2010/11/image.png"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/11/image_thumb.png" border="0" alt="image" width="242" height="122" /></a></li>
<li>Restart ISS and visit the following URL:http://<em>your_server</em>/<em>virtual_dir</em>/info.jsonYou should receive a JSON response with the capabilities of the printing service.</li>
</ol>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/11/image3.png"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/11/image_thumb3.png" border="0" alt="image" width="136" height="246" /></a></p>
<h3 style="text-align: justify;">Troubleshooting</h3>
<ul style="text-align: justify;">
<li><strong>JAR file testing</strong><br />
To test if that the JAR file works correctly, you can execute the following command from the command line (replace the paths with your own). You can find config.yaml and spec.json in the &#8216;samples&#8217; folder of the MapFish print module source:</p>
<p style="text-align: left;"><code>java -jar C:/Python26/MapFish/print-standalone-1.2-SNAPSHOT.jar org.mapfish.print.ShellMapPrinter --config="C:/Python26/MapFish/config.yaml" --spec="C:/Python26/MapFish/spec.json" --output="C:/Python26/MapFish/tmp/test.pdf"</code></p>
</li>
<li><strong>The service returns corrupted PDF files when printing the OpenStreetMap layer</strong><br />
This is caused by a <a href="http://trac.mapfish.org/trac/mapfish/ticket/605">bug</a> in the MapFish source code. The availabe <a href="https://github.com/downloads/amercader/MapFish-Print-IIS/print-standalone-1.2.jar">pre-compiled JAR file</a> fixes this problem (Again, note that this may not be the most recent version).</li>
<li><strong>IIS returns a 404 error when sending a print request</strong><br />
If you are using the GET method to request the PDF file (i.e. using the print.pdf end point), you may find that the server returns a 404 error if the query string is too long. That means that the query string (the parameters sent after the service URL) is longer than the IIS security limit. You could try to <a href="http://www.iis.net/ConfigReference/system.webServer/security/requestFiltering/requestLimits">adjust this limit</a>, but better yet, you can simply use POST requests from your client application, which is the recommended setting. This way you won&#8217;t have any problems regarding the length of the parameters sent.</li>
<li><strong>The application returns an exception when including a local image</strong><br />
If you try to include a local image in your YAML configuration file, (e.g. <code>url: 'file://${configDir}/north.png'</code> or <code>url: '${configDir}/north.png'</code>), the service will return an exception. This is caused by a <a href="http://trac.mapfish.org/trac/mapfish/ticket/606">bug</a>, and until it&#8217;s fixed, a workaround is to use a file accessible via Http (<code>url: 'http://.../north.png'</code>).</li>
</ul>
<h3 style="text-align: justify;">Feedback</h3>
<p style="text-align: justify;">I would love to hear about your experience using it, and if you think of an enhancement or find a bug do not hesitate to contact me (<em>amercadero at gmail.com</em> &#8211; <a href="http://amercader.net">http://amercader.net</a>) or even better, fork the code on GitHub and contribute your changes.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/fxB8O8Dwppc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/mapfish-print-module-for-iis/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/mapfish-print-module-for-iis?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=mapfish-print-module-for-iis</feedburner:origLink></item>
		<item>
		<title>Guests Welcome!</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/SG4_JY5OMik/guests-welcome</link>
		<comments>http://geographika.co.uk/guests-welcome#comments</comments>
		<pubDate>Wed, 10 Nov 2010 14:05:16 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[wms]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=745</guid>
		<description><![CDATA[The next post will be written by Adrià Mercader who has been working on configuring the MapFish print server to be used on IIS. This fits in perfectly with the recent Window / open source hybrid web-mapping solutions I have been working on. Adrià is also the author of the WMS Inspector a FireFox plug-in <a href='http://geographika.co.uk/guests-welcome'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/11/image4.png"><img style="display: inline; margin-left: 0px; margin-right: 0px; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/11/image_thumb4.png" border="0" alt="image" width="248" height="178" align="left" /></a></p>
<p style="text-align: justify;">
<p style="text-align: justify;">The next post will be written by <a href="http://amercader.net/" target="_blank">Adrià Mercader</a> who has been working on configuring the MapFish print server to be used on IIS. This fits in perfectly with the recent Window / open source hybrid web-mapping solutions I have been working on.</p>
<p style="text-align: justify;">Adrià is also the author of the <a href="https://github.com/amercader/WMS-Inspector/wiki/" target="_blank">WMS Inspector</a> a FireFox plug-in that allows you to view and analyse WMS requests for a web-page. This was recently presented at <a href="http://2010.foss4g.org/presentations_show.php?id=2999" target="_blank">FOSS4G in Barcelona</a>, near Adrià’s hometown. He has recently moved to Newcastle in the UK, clearly for both better weather and football.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/SG4_JY5OMik" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/guests-welcome/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/guests-welcome?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=guests-welcome</feedburner:origLink></item>
		<item>
		<title>Installing Python Modules on Windows</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/iL6s7Pw3j7A/installing-python-modules-on-windows</link>
		<comments>http://geographika.co.uk/installing-python-modules-on-windows#comments</comments>
		<pubDate>Wed, 20 Oct 2010 15:49:13 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[64bit]]></category>
		<category><![CDATA[geojson]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=719</guid>
		<description><![CDATA[Installing Python modules on 32 bit Windows is a fairly simple process once you get to know the vocabulary of packages (Python scripts and libraries), eggs (similar to a bundled zip file), and the Cheeseshop (the Python “app store” equivalent – now renamed the Python Package Index or PyPi). Many popular packages in PyPi have <a href='http://geographika.co.uk/installing-python-modules-on-windows'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/10/image.png"><img style="margin: 0px 10px 0px 0px; display: inline; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/10/image_thumb.png" border="0" alt="image" width="244" height="222" align="left" /></a> Installing Python modules on 32 bit Windows is a fairly simple process once you get to know the vocabulary of packages (Python scripts and libraries), eggs (similar to a bundled zip file), and the Cheeseshop (the Python “app store” equivalent – now renamed the Python Package Index or <a href="http://pypi.python.org/pypi" target="_blank">PyPi</a>).</p>
<p style="text-align: justify;">Many popular packages in PyPi have custom Windows installers that take care of both Python files and any associated DLLs. For example <a href="http://pypi.python.org/pypi/Shapely/" target="_blank">Shapely</a> and <a href="http://pypi.python.org/pypi/numpy/1.5.0" target="_blank">NumPy</a>.</p>
<p style="text-align: justify;">For other packages the easiest way to add them to your Python installation is to use <a href="http://pypi.python.org/pypi/setuptools" target="_blank">Setup Tools</a>. Download the Windows setup package corresponding to your version of Python from <a href="http://pypi.python.org/pypi/setuptools">http://pypi.python.org/pypi/setuptools</a> and double click to install.</p>
<p style="text-align: justify;">This adds an easy_install.exe to your C:\Python\Scripts folder that can be used to quickly add packages.  You run easy_install from the Windows command line followed by the name of the package. It searches the online PyPi for the best match for your Python version, and then downloads and installs it.</p>
<p style="text-align: justify;"><span id="more-719"></span></p>
<p style="text-align: justify;">For example to install <a href="http://mapfish.org/" target="_blank">MapFish</a> open a command window and run:</p>
<p style="text-align: justify;">C:\Python27\Scripts\easy_install mapfish</p>
<p style="text-align: justify;">Or for GeoJSON:</p>
<p style="text-align: justify;">C:\Python27\Scripts\easy_install geojson</p>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/10/image1.png"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/10/image_thumb1.png" border="0" alt="image" width="392" height="96" /></a></p>
<h3 style="text-align: justify;">64-Bit Windows</h3>
<p style="text-align: justify;">If you install the 32-bit version of Python on Windows 64 bit then you can continue to install the standard 32-bit packages as above. However if you want to take advantage of a 64-bit version of Python then things get trickier.</p>
<p style="text-align: justify;">If you are lucky an official 64-bit Windows installer is already available for download e.g. <a href="http://pypi.python.org/pypi/Shapely/" target="_blank">Shapely</a>, unfortunately this is the exception rather than the rule. There are however often “unofficial” installers available on the web.</p>
<p style="text-align: justify;">If you try to run a 32-bit installer then it will often say it cannot find your Python installation. This is because the 64-bit and 32-bit Python installations write to <a href="http://stackoverflow.com/questions/3652625/installing-setuptools-on-64-bit-windows" target="_blank">different parts of the Windows registry</a>. You can try and fool the set up package into installing using the method outlined <a href="http://selfsolved.com/problems/setuptools-06c11-fails-to-instal" target="_blank">here</a>, however if the package relies on DLLs then you could end up with problems. If the package is pure Python (no associated DLLs) then I don’t think this should be an issue.</p>
<p style="text-align: justify;">If you receive a <em>“This application has failed to start because MSVCR71.dll was not found” </em>error then the Python package relies on DLLs written in C++. To use these packages you need to install the Microsoft Visual C++ Redistributable Package. This can be downloaded from <a href="http://www.microsoft.com/downloads/en/details.aspx?familyid=BA9257CA-337F-4B40-8C14-157CFDFFEE4E&amp;displaylang=en" target="_blank">here</a>. It contains “<em>runtime components of Visual C++ Libraries required to run 64-bit applications developed with Visual C++ SP1 on a computer that does not have Visual C++ 2008 SP1 installed.</em>”</p>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/10/image2.png"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/10/image_thumb2.png" border="0" alt="image" width="396" height="147" /></a></p>
<p style="text-align: justify;">I recently came across a treasure trove for 64-bit Windows and Python maintained by <a href="http://www.lfd.uci.edu/~gohlke/" target="_blank">Christoph Gohlke</a> at <a title="http://www.lfd.uci.edu/~gohlke/pythonlibs/" href="http://www.lfd.uci.edu/~gohlke/pythonlibs/">http://www.lfd.uci.edu/~gohlke/pythonlibs/</a>. This page contains 64-bit Windows installers for many packages including <a href="http://www.gdal.org/" target="_blank">GDAL</a> (there are further details on using 64 bit GDAL and MapScript <a href="http://geographika.co.uk/64-bit-mapscript-for-python-on-windows" target="_blank">here</a>), and a compilation of many packages including geopy, simplejson, sphinx, pytools and many others.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/iL6s7Pw3j7A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/installing-python-modules-on-windows/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/installing-python-modules-on-windows?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=installing-python-modules-on-windows</feedburner:origLink></item>
		<item>
		<title>OGR Comes to SQL Server 2008 Spatial</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/GOkJT2Gayi0/ogr-comes-to-sql-server-2008-spatial</link>
		<comments>http://geographika.co.uk/ogr-comes-to-sql-server-2008-spatial#comments</comments>
		<pubDate>Sat, 25 Sep 2010 12:36:42 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[geodatabases]]></category>
		<category><![CDATA[sql server 2008]]></category>
		<category><![CDATA[gdal]]></category>
		<category><![CDATA[sqlserver]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=699</guid>
		<description><![CDATA[OGR, created by Frank Warmerdam, is an open source library and set of command line utilities for reading and writing geospatial vector data using many different formats . It is the vector equivalent of GDAL which has similar functionality for rasters. The name of the library is a vestige from when OGR used to stand for <a href='http://geographika.co.uk/ogr-comes-to-sql-server-2008-spatial'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/09/image.png"><img style="display: inline; margin-left: 0px; margin-right: 0px; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/09/image_thumb.png" border="0" alt="image" width="240" height="203" align="left" /></a> OGR, created by <a href="http://home.gdal.org/warmerda/" target="_blank">Frank Warmerdam</a>, is an open source library and set of command line utilities for reading and writing geospatial vector data using many different formats <a href="http://home.gdal.org/warmerda/" target="_blank"></a>. It is the vector equivalent of <a href="http://www.gdal.org" target="_blank">GDAL</a> which has similar functionality for rasters.</p>
<p style="text-align: justify;">The name of the library is a vestige from when OGR used to stand for OpenGIS Simple Features Reference Implementation. However as OGR is not fully compliant with the <a href="http://www.opengeospatial.org/standards/sfa" target="_blank">OpenGIS Simple Feature specification</a> the name was changed to OGR Simple Features Library (from the <a href="http://trac.osgeo.org/gdal/wiki/FAQGeneral" target="_blank">GDAL FAQ</a>).</p>
<p style="text-align: justify;">The latest additions to the OGR formats are the SQL Server 2008 <a href="http://www.microsoft.com/sqlserver/2008/en/us/spatial-data.aspx" target="_blank">geometry and geography</a>. This enables spatial data in SQL Server 2008 to be reprojected, and converted to other formats (shapefiles, MapInfo, KML, GML, GeoJSON and any of the <a href="http://www.gdal.org/ogr/ogr_formats.html" target="_blank">many other formats already supported by OGR</a>) using freely available open source tools. Details on the associated OGR tools can be seen <a href="http://www.gdal.org/ogr_utilities.html" target="_blank">here</a>.</p>
<p style="text-align: justify;"><strong>The full MSSQLSpatial OGR driver notes and details are </strong><a href="http://www.gdal.org/ogr/drv_mssqlspatial.html" target="_blank"><strong>available online</strong></a><strong>. </strong></p>
<h3 style="text-align: justify;"><span id="more-699"></span>Where can I get the Driver?</h3>
<p style="text-align: justify;">The source code for the new MSSQLSpatial driver can be seen here in the online GDAL subversion <a href="http://trac.osgeo.org/gdal/browser/trunk/gdal/ogr/ogrsf_frmts/mssqlspatial" target="_blank">code repository</a>. As can be seen by the check-in dates much of the work has been completed in the last two weeks.</p>
<p style="text-align: justify;">The two developers who deserve the credit are Tamas Szekeres and Even Rouault, both members of the GDAL Project Management Committee.  Tamas has blogged about the new OGR driver <a href="http://szekerest.blogspot.com/2010/09/ogr-ms-sql-2008-spatial-driver.html" target="_blank">here</a>. Tamas’s work is becoming invaluable to many of my projects – and he was also responsible for the <a href="http://mapserver.org/development/rfc/ms-rfc-38.html" target="_blank">MapServer SQL Server 2008 driver</a>.</p>
<p style="text-align: justify;">The MSSQLSpatial driver is not currently available  in the latest version of FWTools (2.4.7 at the time of writing). FWTools (Frank Warmerdam tools) is an easy to install package containing both GDAL and OGR, but keep an eye on the <a href="http://fwtools.maptools.org/">http://fwtools.maptools.org/</a> site for new releases.</p>
<p style="text-align: justify;">The driver was not a part of the GDAL 1.7 release, so if you can’t wait until the next binary (precompiled) <a href="http://trac.osgeo.org/gdal/wiki/DownloadingGdalBinaries" target="_blank">release</a>, you have to compile it yourself. However Tamas maintains a page which automatically compiles the latest MapServer source code into binaries at <a href="http://vbkto.dyndns.org/sdk/">http://vbkto.dyndns.org/sdk/</a>. MapServer includes the latest development GDAL and OGR binaries (gdal18dev.dll) which in turn include the new <a href="http://vbkto.dyndns.org/sdk/PackageInfo.aspx?file=release-1310-gdal-mapserver.zip" target="_blank">MSSQLSpatial driver</a>. So this is currently the easiest place to get a compiled version for testing with SQL Server.</p>
<h3 style="text-align: justify;">Quick Set Up of OGR &amp; MSSQLSpatial (on Windows)</h3>
<p style="text-align: justify;">Even though at the time of writing the latest development builds for MapServer failed the GDAL/OGR DLLs and .exes seem fine and can be found in the bin/gdal subfolder of the MapServer packages. To quickly get up and running with OGR you can follow these steps:</p>
<p style="text-align: justify;">1. Download a suitable package from <a href="http://vbkto.dyndns.org/sdk/">http://vbkto.dyndns.org/sdk/</a>. You will need a development release, or a release with GDAL 1.8 or higher. Click on the information links to see which OGR types are supported in a package.</p>
<p style="text-align: justify;">2. Unzip the package to your machine. It is best to put the package in a folder which does not contain spaces.</p>
<p style="text-align: justify;">3. Run the following commands in a Windows Command Line window. I left the package in my D:\My Documents\Downloads\ folder in this example.</p>
<pre style="text-align: justify;">D:
cd "D:\My Documents\Downloads\release-1500-gdal-mapserver\"
SDKShell.bat setenv hideoci</pre>
<p style="text-align: justify;">
<p style="text-align: justify;">The SDKShell.bat file sets all the GDAL environment variables for your command window session. The hideoci parameter is used to move the Oracle driver plugin out of GDAL – otherwise if you try and run commands you get the following error (unless the Oracle client is installed on your machine):</p>
<blockquote style="text-align: justify;"><p><em>This application has Failed to start because OCI.dll was not Found. Re-installing the application may fix this problem</em></p></blockquote>
<p style="text-align: justify;">The hideoci parameter did not work for me due to the spaces in my folder path, so I manually did what the .bat file was meant to do – move the ogr_OCI.dll, and gdal_GEOR.dll files out of bin\gdal\plugins\ and into a new bin\gdal\plugins-optional folder.</p>
<p style="text-align: justify;">Once this was done I was able to run the following command to check the OGR formats:</p>
<pre style="text-align: justify;"> ogrinfo.exe –-formats

<a href="http://geographika.co.uk/wp-content/uploads/2010/09/image1.png"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/09/image_thumb1.png" border="0" alt="image" width="244" height="78" /></a></pre>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/GOkJT2Gayi0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/ogr-comes-to-sql-server-2008-spatial/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/ogr-comes-to-sql-server-2008-spatial?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=ogr-comes-to-sql-server-2008-spatial</feedburner:origLink></item>
		<item>
		<title>64-bit Mapscript for Python on Windows</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/bl3kwH5o5Gs/64-bit-mapscript-for-python-on-windows</link>
		<comments>http://geographika.co.uk/64-bit-mapscript-for-python-on-windows#comments</comments>
		<pubDate>Tue, 03 Aug 2010 08:17:21 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[mapserver]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[64bit]]></category>
		<category><![CDATA[gdal]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=630</guid>
		<description><![CDATA[Tamas Szekeres maintains a site with many different compiled versions of MapServer at http://vbkto.dyndns.org/sdk/ (the site can occasionally be overloaded or down). These are compiled daily direct from the source. It is a veritable Aladdin&#8217;s cave of treasures – especially if you are installing on a Windows Server, and even more so if you are <a href='http://geographika.co.uk/64-bit-mapscript-for-python-on-windows'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://szekerest.blogspot.com/">Tamas Szekeres</a> maintains a site with many different compiled versions of <a href="http://mapserver.org/" target="_blank">MapServer</a> at <a title="http://vbkto.dyndns.org/sdk/" href="http://vbkto.dyndns.org/sdk/">http://vbkto.dyndns.org/sdk/</a> (the site can occasionally be overloaded or down). These are compiled daily direct from the source. It is a veritable Aladdin&#8217;s cave of treasures – especially if you are installing on a Windows Server, and even more so if you are installing for 64bit.</p>
<p style="text-align: justify;">It gets even better though! Included in the installation are the latest SQL Server 2008 driver, 64 bit <a href="http://www.gdal.org/" target="_blank">GDAL</a>, and <a href="http://mapserver.org/mapscript/index.html" target="_blank">MapScript</a> Python bindings. MapScript allows MapServer functions and classes to be scripted in a variety of languages.</p>
<p style="text-align: justify;">As Python is becoming ubiquitous in the GIS world (opensource and proprietary), if you aren’t familiar with PHP then You can download the zip file and extract to a folder on your machine, in the example below I used C:\ms4w64 (old habits die hard!).</p>
<p style="text-align: justify;"><span id="more-630"></span></p>
<h4 style="text-align: justify;">Install Steps</h4>
<p style="text-align: justify;">1. Add C:\ms4w64\bin to your system PATH environment variable (right-click on My Computer, select Properties, Advanced, Environment Variables, then in System Variables select PATH and edit. Remember to put a semi-colon ; between folders in the path.</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border-width: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/07/image1.png" border="0" alt="image" width="226" height="92" /></p>
<p style="text-align: justify;">Adding this folder to your PATH will allow Windows to find the MapServer and GDAL DLLs used by Mapscript.</p>
<p style="text-align: justify;">2. Now we want to make the Mapscript Python module available in Python. There are a couple of options here. I took the files from <strong>C:\ms4w64\bin\ms\python </strong>and copied them into <strong>C:\Python26\Lib\site-packages – </strong>the default search location for third party Python modules. The files to copy across are:</p>
<ul style="text-align: justify;">
<li>_mapscript.pyd</li>
<li>mapscript.py</li>
<li>A mapscript.pyc (compiled Python) file will be generated on first use</li>
</ul>
<p style="text-align: justify;">Alternatively you can add the <strong>C:\ms4w64\bin\ms\python </strong>folder to the PYTHONPATH Window’s environment variable as in step 1.</p>
<p style="text-align: justify;"><strong>Important! </strong>You will need to log off, or restart your PC in order for the environment variables to be “refreshed” by the operating system.</p>
<p style="text-align: justify;">Either way you should now be able to type “import mapscript” in IDLE without receiving errors.</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border-width: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/07/image2.png" border="0" alt="image" width="437" height="191" /></p>
<h4 style="text-align: justify;">Errors?</h4>
<p style="text-align: justify;">
<pre class="brush: python; title: ; notranslate">Traceback (most recent call last):
File &quot;&lt;pyshell#0&gt;&quot;, line 1, in &lt;module&gt;
import mapscript
ImportError: No module named mapscript</pre>
<p style="text-align: justify;">Python can’t find the Mapscript module. Try typing the following commands into Idle to see the folders that Python checks looking for modules:</p>
<p style="text-align: justify;">
<pre class="brush: python; title: ; notranslate">import sys
print sys.path</pre>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border-width: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/07/image3.png" border="0" alt="image" width="473" height="105" /></p>
<p style="text-align: justify;">
<pre class="brush: python; title: ; notranslate">Traceback (most recent call last):
File &quot;&lt;pyshell#13&gt;&quot;, line 1, in &lt;module&gt;
import mapscript
File &quot;C:\Python25\lib\site-packages\mapscript.py&quot;, line 28, in &lt;module&gt;
import _mapscript
ImportError: DLL load failed with error code 193</pre>
<p style="text-align: justify;">It is likely you are using a 32 bit version of Python with 64 bit versions of the MapServer DLLs. You may have reinstalled and reconfigured Python so many times that you have actually forgotten what you installed. A useful program in this case can be downloaded from <a href="http://www.mitec.cz/exe.html">http://www.mitec.cz/exe.html</a></p>
<p style="text-align: justify;">This tells you the processor type for a .exe file such as python.exe. Check that it is a 64-bit version as shown below.</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border-width: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/07/image4.png" border="0" alt="image" width="393" height="139" /></p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/bl3kwH5o5Gs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/64-bit-mapscript-for-python-on-windows/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/64-bit-mapscript-for-python-on-windows?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=64-bit-mapscript-for-python-on-windows</feedburner:origLink></item>
		<item>
		<title>Setting up a Secure Cascading WMS on MapServer</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/xNHBMqIVNPM/setting-up-a-secure-cascading-wms-on-mapserver</link>
		<comments>http://geographika.co.uk/setting-up-a-secure-cascading-wms-on-mapserver#comments</comments>
		<pubDate>Tue, 20 Jul 2010 13:46:36 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[mapserver]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[wms]]></category>
		<category><![CDATA[64bit]]></category>
		<category><![CDATA[cURL]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=668</guid>
		<description><![CDATA[There a number of benefits to using a cascading WMS service – a WMS service that is read and then forwarded on through an intermediary WMS server: you can cache the service (for example with TileCache) to greatly improve performance your application need only worry about a single point of connection, using WMS layers aggregated <a href='http://geographika.co.uk/setting-up-a-secure-cascading-wms-on-mapserver'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><img style="margin: 0px 20px 0px 0px; display: inline; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/07/image16.png" border="0" alt="image" width="340" height="460" align="left" /> There a number of benefits to using a cascading <a href="http://en.wikipedia.org/wiki/Web_Map_Service" target="_blank">WMS</a> service – a WMS service that is read and then forwarded on through an intermediary WMS server:</p>
<ul style="text-align: justify;">
<li>
<div>you can cache the service (for example with <a href="http://tilecache.org/" target="_blank">TileCache</a>) to greatly improve performance</div>
</li>
<li>
<div>your application need only worry about a single point of connection, using WMS layers aggregated from many different sources</div>
</li>
<li>
<div>you can add additional metadata missing from the source</div>
</li>
<li>
<div>services can be reprojected (using <a href="http://www.gdal.org/" target="_blank">GDAL</a>)</div>
</li>
<li>
<div>you can merge WMS layers together and server them out as a new map layer</div>
</li>
</ul>
<p style="text-align: justify;">There are also some negatives:</p>
<ul style="text-align: justify;">
<li>
<div>you have additional server configuration to set up and maintain</div>
</li>
<li>
<div>if you are not adding or changing the WMS service you should probably connect to the WMS service directly in the client applications, otherwise there will be a performance hit</div>
</li>
<li>
<div>caching may contravene the licensing agreement of the original WMS source</div>
</li>
</ul>
<p style="text-align: justify;">The rest of this post details the steps in setting up a cascading WMS using <a href="http://mapserver.org/" target="_blank">MapServer</a>. You need MapServer 5.4.1 or higher to implement a secure cascaded WMS service. This example uses a 64-bit version of MapServer 5.6 taken from <a href="http://szekerest.blogspot.com/" target="_blank">Tamas Szekeres</a>’s <a href="http://vbkto.dyndns.org/sdk/" target="_blank">autobuilds site</a> installed in a C:\ms4w64 folder. It also assumes MapServer has been configured with SSL <a href="http://geographika.co.uk/64-bit-curl-with-openssl-on-windows" target="_blank">as detailed in another post</a>. In this example I use IIS and Windows Server 2003.</p>
<div style="text-align: justify;"><span id="more-668"></span></div>
<h4 style="text-align: justify;">MapFile Configuration</h4>
<p style="text-align: justify;">Configuring a MapFile for a cascading WMS service is well-documented on the <a href="http://mapserver.org/ogc/wms_client.htm" target="_blank">MapServer WMS Client page</a>. An example is shown below. Note that this service is not reprojected, and the username and password can be passed through the metadata parameters.</p>
<pre style="text-align: justify;">LAYER
  NAME "MyLayer"
  TYPE RASTER
  STATUS OFF
  CONNECTION “https://webservices…”
  CONNECTIONTYPE WMS
  #DEBUG 5 #to debug the original layer
  METADATA
    "wms_srs"             "EPSG:2157"
    "wms_name"            "0"
    "wms_server_version"  "1.1.1"
    "wms_format"          "image/png"
    "wms_auth_username" "username"
    "wms_auth_password" "password"
    "wms_bgcolor" "0xFFFFFF"
  END
END</pre>
<p style="text-align: justify;">
<p style="text-align: justify;">It is vital you set up debugging for the MapFile to see why a connection may be failing. You can set this by adding the following lines to the MapFile:</p>
<pre style="text-align: justify;">DEBUG 5 #debugging level between 1 and 5, 5 is the most detailed
CONFIG "MS_ERRORFILE" "C:/ms4w64/tmp/ms.log"
#path to log file - ensure IIS can write to this file
</pre>
<p>This can be removed once everything is working correctly.</p>
<h4 style="text-align: justify;">Configuring SSL and MapServer (Part 1)</h4>
<p style="text-align: justify;">A secure WMS service is one that uses an <strong>https</strong>:// address, and may require a username and password. Setting up MapServer to connect using SSL is by far the trickiest part of the configuration. First of all I had to <a href="http://geographika.co.uk/64-bit-curl-with-openssl-on-windows" target="_blank">compile my own libcurl.dll</a> to include <a href="http://www.openssl.org/" target="_blank">OpenSSL</a>. Otherwise I got the following error in the log file:</p>
<p style="text-align: justify;"><em>msHTTPExecuteRequests(): HTTP request error. HTTP: request failed with curl error code 1 (Protocol https not supported or disabled in libcurl)</em></p>
<p style="text-align: justify;">Once I had the new libcurl.dll I replaced the existing file in the C:\ms4w64\bin folder (always make a back-up of the original files first!) with my freshly compiled version. I used <a href="http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx" target="_blank">Process Monitor</a> to  see if I was missing any other DLLs – I was. The libcurl.dll required some additional OpenSSL DLLs to connect to https addresses. These DLLs were:</p>
<ul style="text-align: justify;">
<li>
<div>libeay32.dll</div>
</li>
<li>
<div>ssleay32.dll</div>
</li>
</ul>
<p style="text-align: justify;">These too I copied into my C:\mapserver\bin folder from the openssl-1.0.0a\out32dll folder created <a href="http://geographika.co.uk/64-bit-curl-with-openssl-on-windows" target="_blank">when compiling libcurl.dll</a>. Next I got the following error:</p>
<p style="text-align: justify;"><em>HTTP: request failed with curl error code 60 (SSL certificate problem, verify that the CA cert is OK. Details:<br />
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed) for https://…</em></p>
<p style="text-align: justify;">These errors relate to <a href="http://osgeo-org.1803224.n2.nabble.com/WMS-Layer-with-secure-http-url-td2807534.html#a2814037" target="_blank">missing certificates</a>. For more details on security certificates <a href="http://curl.haxx.se/docs/sslcerts.html" target="_blank">see this page</a>.</p>
<h4 style="text-align: justify;">Getting a Security Certificate</h4>
<p style="text-align: justify;">I needed to get a valid certificate from the web service and point MapServer to this file. I was able to get a certificate by typing in the service;s https:// url in FireFox, and then selecting Tools &gt; Page Info &gt; Security &gt; View Certificate &gt; Details &gt; Export. You can also right-click on the padlock icon at the bottom of the page to access the same option.</p>
<p style="text-align: justify;">When exporting I selected the “X 509 Certificate with chain (PEM)” option. I tried an export without the “chain” but this didn’t allow me to connect.</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/07/image17.png" border="0" alt="image" width="258" height="56" /></p>
<p style="text-align: justify;">I’d recommend trying to connect to the site independently of MapServer, so any issues can be narrowed to certificate problems rather than the MapServer configuration. I ran these tests on my development machine – a 32bit Windows XP laptop, following these steps:</p>
<p style="text-align: justify;">1. Install a standalone version of cURL from the <a href="http://curl.haxx.se/download.html" target="_blank">cURL download page</a> (I used libcurl-7.19.3-win32-ssl-msvc.zip).</p>
<p style="text-align: justify;">2. Save your security certificate with the filename <strong>curl-ca-bundle.crt </strong>in the same folder as you unzipped the curl.exe file. Placing it in the same folder, with this name, will mean the certificate can be read by cURL. <img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/07/image18.png" border="0" alt="image" width="98" height="119" /></p>
<p style="text-align: justify;">In a DOS window navigate to the folder with the curl.exe file and run the following command to see if the certificate works with the site. Add in some valid WMS parameters.</p>
<pre style="text-align: justify;">curl https://webserveraddress.com/wms?VERSION=1.1.1&amp;REQUEST=...</pre>
<p style="text-align: justify;">If you need to pass in a username and password to the service use:</p>
<pre style="text-align: justify;">curl https://username:password@webserveraddress.com/wms?VERSION=1.1.1&amp;REQUEST=...</pre>
<p style="text-align: justify;">If you get the following error:</p>
<p style="text-align: justify;"><em>(60) SSL certificate problem, verify that the CA cert is OK. Details:error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed</em></p>
<p style="text-align: justify;">It means your certificate is invalid. You can try the command with a <strong>/k</strong> switch to ignore the security and check that there isn’t a connection problem rather than a security problem:</p>
<pre style="text-align: justify;">curl https://username:password@webserveraddress.com/wms?VERSION=1.1.1&amp;REQUEST=... /k</pre>
<p style="text-align: justify;">If all went well with the certificate you should get a DOS window filled with random characters:</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/07/image19.png" border="0" alt="image" width="420" height="106" /></p>
<p style="text-align: justify;">This is good! It is an image file viewed as text and means you have successfully returned an image from the secure WMS server.</p>
<h4 style="text-align: justify;">Configuring SSL and MapServer (Part 2)</h4>
<p style="text-align: justify;">Now all that remains is to set up the certificate on the MapServer. There are some <a href="http://213.207.42.55/README_INSTALL.html#g-certificates-for-https-with-wms-wfs-servers" target="_blank">instructions here</a> and <a href="http://trac.osgeo.org/mapserver/ticket/3070" target="_blank">more here.</a> I got a little confused thinking I could point to the certificate file using a CONFIG command in the MapFile to set the environment variable. This is not the case.</p>
<p style="text-align: justify;">It must be set  using a Windows environment variable (although you can set it in Apache if you’re not using IIS). It took a while for me to figure this out, but due to the beauty of OpenSource if you get too stuck you can search the sourcecode itself to see how parameters are used. The <a href="http://trac.osgeo.org/mapserver/browser/branches/branch-5-6/mapserver/maphttp.c" target="_blank">relevant sourcecode can be found here</a>.</p>
<p style="text-align: justify;">I created a new Windows environment variable CURL_CA_BUNDLE to point to the .crt file as shown below:</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/07/image20.png" border="0" alt="image" width="344" height="148" /></p>
<p style="text-align: justify;">And this time in the log – success!</p>
<p style="text-align: justify;">[Wed Jul 07 16:04:55 2010].384000 msDrawMap(): kicking into non-square pixel preserving mode.<br />
[Wed Jul 07 16:04:55 2010].838000 HTTP: Starting to prepare HTTP requests.<br />
[Wed Jul 07 16:04:55 2010].838000 Using CURL_CA_BUNDLE=C:\ms4w64\bin\curl-ca-bundle.crt</p>
<p style="text-align: justify;">
<h4 style="text-align: justify;">Poor Image Quality?</h4>
<p style="text-align: justify;">Sometimes the WMS images lack the quality of the originals when run through a cascaded service. <a href="http://comments.gmane.org/gmane.comp.gis.mapserver.user/41900" target="_blank">This post</a> attributes it to either reprojection or incompatible output formats. In my case it was the latter. As the forum post writer says – if you aren’t reprojecting or adding information then using a proxy rather than a cascading WMS would be far more efficient.</p>
<div style="text-align: justify;">
<table style="border: thin;" cellspacing="8" cellpadding="8" width="100%">
<tbody>
<tr>
<td width="333" valign="top"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/07/image21.png" border="0" alt="image" width="172" height="149" /></td>
<td width="347" valign="top"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/07/image22.png" border="0" alt="image" width="174" height="149" /></td>
</tr>
<tr>
<td width="333" valign="top">
<p style="text-align: left;">My original MapFile <a href="http://mapserver.org/mapfile/outputformat.html#outputformat" target="_blank">OUTPUTFORMAT</a> had worked perfectly for all my local WMS services, but with the cascaded service the aerial photography was blotchy.</p>
<p>OUTPUTFORMAT<br />
NAME &#8216;AGGA&#8217;<br />
DRIVER AGG/PNG<br />
IMAGEMODE RGBA<br />
END</td>
<td width="349" valign="top">
<p style="text-align: left;">I changed the OUTPUTFORMAT to the following settings and the images were back to good resolution.</p>
<p>OUTPUTFORMAT<br />
NAME &#8220;png&#8221;<br />
DRIVER &#8220;GDAL/PNG&#8221;<br />
MIMETYPE &#8220;image/png&#8221;<br />
EXTENSION &#8220;png&#8221;<br />
END</td>
</tr>
</tbody>
</table>
</div>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/xNHBMqIVNPM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/setting-up-a-secure-cascading-wms-on-mapserver/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/setting-up-a-secure-cascading-wms-on-mapserver?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=setting-up-a-secure-cascading-wms-on-mapserver</feedburner:origLink></item>
		<item>
		<title>64 bit cURL with OpenSSL on Windows</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/kfnYCVsU0ls/64-bit-curl-with-openssl-on-windows</link>
		<comments>http://geographika.co.uk/64-bit-curl-with-openssl-on-windows#comments</comments>
		<pubDate>Fri, 09 Jul 2010 10:26:23 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[mapserver]]></category>
		<category><![CDATA[64bit]]></category>
		<category><![CDATA[cURL]]></category>
		<category><![CDATA[libcurl]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=653</guid>
		<description><![CDATA[MapServer makes use of libcurl.dll to connect to web resources. The reason I’ve had to learn this is because libcurl.dll is vital when using MapServer as a WMS client, or “a cascading WMS server” – using MapServer to connect to another WMS server and then “forward” them as if they were any other map layer. <a href='http://geographika.co.uk/64-bit-curl-with-openssl-on-windows'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://mapserver.org/" target="_blank"><img style="margin: 0px; display: inline; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/07/image6.png" alt="image" width="46" height="46" align="left" border="0" />MapServer</a> makes use of libcurl.dll to connect to web resources. The reason I’ve had to learn this is because libcurl.dll is vital when using MapServer as a WMS client, or “a cascading WMS server” – using MapServer to connect to another WMS server and then “forward” them as if they were any other map layer.</p>
<p style="text-align: justify;">libcurl.dll is the library version of the command line tool cURL – a tool written in C (hence the name) that:</p>
<div style="text-align: justify;">
<blockquote><p>is a command line tool for transferring data with URL syntax, supporting FTP, FTPS, HTTP, HTTPS…curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading…</p>
<p>..libcurl is most probably the most portable, most powerful and most often used C-based multi-platform file transfer library on this planet &#8211; be it open source or commercial. &#8211; <a title="http://curl.haxx.se/" href="http://curl.haxx.se/">http://curl.haxx.se/</a></p></blockquote>
</div>
<div style="text-align: justify;"><span id="more-653"></span></div>
<p style="text-align: justify;"><a href="http://szekerest.blogspot.com" target="_blank">Tamas Szekeres</a> maintains <a href="http://vbkto.dyndns.org/sdk/" target="_blank">a site that dynamically builds Mapserver</a> from source on a nightly basis using different versions of MapServer, and <a href="http://www.gdal.org/" target="_blank">GDAL</a>, for both 32 and 64 bit Windows. Unfortunately for me I wanted to connect to a WMS using MapServer that used the HTTPS (Hypertext Transfer Protocol Secure) protocol. When I tried connecting to the WMS service with MapServer the log file reported the following error:</p>
<p style="text-align: justify;">msHTTPExecuteRequests(): HTTP request error. HTTP: request failed with curl error code 1 (Protocol https not supported or disabled in libcurl) for <a href="https://webservices">https://webservices</a>…</p>
<p style="text-align: justify;">The libcurl.dll included in the MapServer build <a href="http://curl.haxx.se/docs/faq.html#curl_1_SSL_is_disabled_https" target="_blank">doesn’t support SSL</a> (Secure Sockets Layer). That sinking feeling of knowing I was going to have to get my hands dirty and start messing about compiling things I didn’t understand was soon upon me..</p>
<p style="text-align: justify;">There are many different compiled versions of cURL and libcURL you can download from the <a href="http://curl.haxx.se/download.html" target="_blank">download page</a> but unfortunately at the time of writing there were no Windows 64bit versions &#8211; however it is worth double-checking this. It is also a good idea to check that the MapServer builds haven&#8217;t been updated to include SSL before going through the lengthy steps below. There are <a href="http://www.gknw.net/mirror/curl/win64/autobuilds/" target="_blank">precompiled versions of the cURL.exe tool</a> out there in the Internet for 64 bit Windows, but MapServer requires the DLL library as shown below:<img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/07/image7.png" alt="image" width="302" height="211" border="0" /></p>
<p style="text-align: justify;">So currently if you require 64 bit <em>and </em>SSL it looks like you have to compile your own version, hence the following steps.</p>
<h4 style="text-align: justify;">cURL Compilation Steps – Part One</h4>
<p style="text-align: justify;">These steps are based on information gleaned from this <a href="http://curl.haxx.se/mail/lib-2009-01/0209.html#replies" target="_blank">cURL mailing list post</a> and this <a href="http://stackoverflow.com/questions/197444/building-libcurl-with-ssl-support-on-windows" target="_blank">StackOverflow question</a> and answer. The second link is particularly good, but a few extra details can save many hours of time. If you are familiar with compiling C libraries then its probably best to skip to to StackOverflow now. If, like me, you’re not too sharp on C then follow the steps below. There is also the<a href="http://curl.haxx.se/docs/install.html" target="_blank"> official compilation steps guide</a> which provides more detail.</p>
<p style="text-align: justify;"><strong>1.</strong> Download the latest source archives from the <a href="http://curl.haxx.se/download.html" target="_blank">cURL download page</a>. At the time of writing links to these were at the top of the page, and in this example the file was named <a href="http://curl.haxx.se/download/curl-7.21.0.zip">curl-7.21.0.zip</a>. Fortunately it seems that the libcurl.dll version number does not need to match the version installed with the MapServer build.</p>
<p style="text-align: justify;"><strong>2.</strong> Unzip this file somewhere on your machine. Avoid spaces to avoid future problems. In this example I unzipped the files to <strong>D:\Projects\cURL\curl-7.21.0</strong></p>
<p style="text-align: justify;"><strong>3.</strong> In the root of the folder you unzipped should be a <strong>vc6curl.dsw </strong>file (a Visual C++ workspace file). I’m assuming you have Visual Studio installed – I’m using VS2008. If you double click this file it should open with Visual Studio – allow it to convert to the new project format.</p>
<p style="text-align: justify;"><strong>4.</strong> Once the project opens go to <strong>Build &gt;&gt; Configuration Manager</strong>. Set the parameters to DLL Release, x64.</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/07/image8.png" alt="image" width="550" height="91" border="0" /></p>
<p style="text-align: justify;">If x64 is not present in the drop-down list you may have to create a new “Solution Platform”, and copy the settings from the Win32 configuration:<img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/07/image9.png" alt="image" width="263" height="177" border="0" /></p>
<p style="text-align: justify;"><strong> 5.</strong> Now we have to make sure that the DLL is built with SSL support. To do this we add a couple of “<em>Preprocessor</em>” parameters. To do this right-click on the libcurl project in the Solution Explorer window:</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/07/image10.png" alt="image" width="142" height="123" border="0" /></p>
<p style="text-align: justify;">Then in <strong>Configuration Properties &gt;&gt; C/C++ &gt;&gt; Preprocessor </strong>add USE_SSLEAY and USE_OPENSSL as shown below. The NDEBUG parameter indicates &#8220;No Debugging.&#8221; Note there is also a WIN32 option &#8211; I compiled a x64 DLL successfully using both WIN32 and WIN64. I had a brief look at the source, but it is probably best to set to WIN64.</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/07/image11.png" alt="image" width="324" height="284" border="0" /></p>
<h4 style="text-align: justify;">OpenSSL Compilation Steps</h4>
<p style="text-align: justify;"><strong>6.</strong> Now you’re probably thinking that you can now compile. If you are optimistic then you probably will. But unless I’ve completely misunderstood how all this ties together, you are still many steps away from getting that libcurl.dll file..</p>
<p style="text-align: justify;">If you require SSL, you also need to compile the OpenSSL library. This compilation can all be done from the Windows command line. The source code can be <a href="http://www.openssl.org/source/" target="_blank">downloaded from this link</a>. I used the latest version available &#8211; <a href="http://www.openssl.org/source/openssl-1.0.0a.tar.gz">openssl-1.0.0a.tar.gz</a>. Download this and unzip (use <a href="http://www.7-zip.org/" target="_blank">7-Zip</a> to handle those pesky tar-balls), again unzip to a folder without spaces in the path to be on the safe side.</p>
<p style="text-align: justify;"><strong>7.</strong> Once unzipped there is a INSTALL.W64 file in the root which provides details on compiling OpenSSL for Windows x64. These steps are fairly well-detailed, but a few screenshots don’t hurt. There are a few warnings in this file not to try and download 4GB files, but as it says it is very unlikely these issues would occur in the real world.</p>
<p style="text-align: justify;">The first step to compilation is to install Perl – a language I’ve never used, but it seems the OpenSSL compilation steps have been automated with Perl scripts. The document recommends using <a href="http://www.activestate.com/activeperl/downloads" target="_blank">ActiveState Perl</a>, but I read that using <a href="http://strawberryperl.com/" target="_blank">Strawberry Perl</a> on Windows <a href="http://stackoverflow.com/questions/71513/which-version-of-perl-should-i-use-on-windows" target="_blank">would be a better choice</a>. After downloading and installing Strawberry Perl, I logged off and on again to make sure the Windows environment variable were updated and continued the compilation.</p>
<p style="text-align: justify;"><strong>8.</strong> I opened a Windows command window and made the OpenSSL folder the active directory:</p>
<pre style="text-align: justify;">cd D:\Projects\cURL\openssl-1.0.0a</pre>
<p style="text-align: justify;"><strong>9.</strong> Next I set up the Windows Visual Studio environment by running the following command. This batch file assumes that you are developing on a 32 bit machine to deploy on a 64 bit machine. There are a number of <a href="http://msdn.microsoft.com/en-us/library/x4d2c09s%28VS.80%29.aspx" target="_blank">similar batch files</a> in the parent folder if your set up is different.</p>
<pre style="text-align: justify;">"C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\x86_amd64\vcvarsx86_amd64.bat"</pre>
<p style="text-align: justify;"><strong>10.</strong> Next I ran the Perl script from the Windows command prompt using:</p>
<pre style="text-align: justify;">perl Configure VC-WIN64A</pre>
<p style="text-align: justify;"><strong>11.</strong> Then a couple more commands:</p>
<pre style="text-align: justify;">ms\do_win64a
nmake -f ms\ntdll.mak</pre>
<p style="text-align: justify;"><strong>12.</strong> In the INSTALL.W64 there are final two steps to check everything was built correctly. As I compiled a x64 DLL on a x32 machine I couldn’t run these, but the lack of show-stopping errors filled me with hope..so back to the libcURL compilation..</p>
<h4 style="text-align: justify;">cURL Compilation Steps – Part Two</h4>
<p style="text-align: justify;"><strong>13.</strong> A rebuild of libcurl.dll at this stage will lead to <em>“fatal error C1083: Cannot open include file: &#8216;openssl/rsa.h&#8217;: No such file or directory”. </em>The Visual Studio project needs to reference the OpenSSL files we just built. First of all add an “Include Directory” to the libcurl project pointing to the openssl\inc32\ folder as shown below. This is where all the .h header files are kept.</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/07/image12.png" alt="image" width="506" height="207" border="0" /></p>
<p style="text-align: justify;"><strong>14.</strong> Trying to recompile now (I’m an eternal optimist) leads to <em>“error LNK2019: unresolved external symbol DES_set_key referenced in function setup_des_key”</em> errors. The project now can’t find symbols stored in the OpenSSL .lib files. I ran a Windows search on the OpenSSL folder to find these .lib files:</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/07/image13.png" alt="image" width="507" height="233" border="0" /></p>
<p style="text-align: justify;">Next I <a href="http://www.nirsoft.net/utils/sysexp.html" target="_blank">found a handy tool</a> that could export this search list to text, so I could copy and paste references. The list of .lib files is below. I added these to the “<em>Additional Dependencies</em>” list in the project’s <em>“Configuration Properties &gt;&gt; Linker &gt;&gt; Input”</em> option.</p>
<p style="text-align: justify;">4758cca.lib <img style="margin: 0px; display: inline; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/07/image14.png" alt="image" width="357" height="242" align="right" border="0" /><br />
aep.lib<br />
atalla.lib<br />
capi.lib<br />
chil.lib<br />
cswift.lib<br />
gmp.lib<br />
libeay32.lib<br />
nuron.lib<br />
padlock.lib<br />
ssleay32.lib<br />
sureware.lib<br />
ubsec.lib</p>
<p style="text-align: justify;">I also needed to make Visual Studio aware of the location of these files by going to Tools &gt;&gt; Options &gt;&gt; Projects and Solutions &gt;&gt; VC++ Directories, and pointing to openssl-1.0.0a\out32dll, making sure &#8220;x64&#8243; and &#8220;Library Files&#8221; were selected in the drop-down lists as shown below:</p>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/07/Image3.png"><img class="aligncenter size-full wp-image-659" title="Image3" src="http://geographika.co.uk/wp-content/uploads/2010/07/Image3.png" alt="" width="644" height="161" /></a></p>
<p style="text-align: justify;"><strong>15.</strong> Finally I could run <strong>Build &gt;&gt; Build libcurl</strong> from Visual Studio. A brand new libcurl.dll file appeared in the \lib\DLL-Release folder. Done – for now. There are a number of other steps and DLLs to include to get MapServer working, but that is for another post.</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/07/image15.png" alt="image" width="509" height="178" border="0" /></p>
<h4 style="text-align: justify;">Errors?</h4>
<p style="text-align: justify;">There are a number of errors I encountered during these steps that may lead you to this page:</p>
<ul style="text-align: justify;">
<li><em>&#8216;cl&#8217; is not recognized as an internal or external command, operable program or batch file.</em></li>
</ul>
<p style="text-align: justify;">Make sure the Visual Studio environment has been set up correctly using <em>“C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\x86_amd64\vcvarsx86_amd64.bat&#8221; </em>or similar.</p>
<ul style="text-align: justify;">
<li><em>error A2088:END directive required at end of file NMAKE : fatal error U1077:</em></li>
</ul>
<p style="text-align: justify;">I got this error when compiling OpenSSL (when running ml64.exe), as previous failed compilation attempts had left files in the “openssl-1.0.0a\tmp32dll” folder. Deleting the contents of this folder got rid of this error.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/kfnYCVsU0ls" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/64-bit-curl-with-openssl-on-windows/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/64-bit-curl-with-openssl-on-windows?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=64-bit-curl-with-openssl-on-windows</feedburner:origLink></item>
		<item>
		<title>GIS Servers and the 64-bit Question</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/mO3RSBiYS6c/gis-servers-and-the-64-bit-question</link>
		<comments>http://geographika.co.uk/gis-servers-and-the-64-bit-question#comments</comments>
		<pubDate>Tue, 06 Jul 2010 16:55:47 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[mapserver]]></category>
		<category><![CDATA[opinion]]></category>
		<category><![CDATA[64bit]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=635</guid>
		<description><![CDATA[The following is the first in a series of posts related to configuring a 64-bit Windows server as a GIS server  using MapServer and Python. Why move to 64-bit? If a server’s operating system and hardware are 64-bit it seems a waste not to take advantage of them. It may be better to look at <a href='http://geographika.co.uk/gis-servers-and-the-64-bit-question'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><img style="margin: 0px 10px 0px 0px; display: inline; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/07/image5.png" border="0" alt="image" width="265" height="165" align="left" />The following is the first in a series of posts related to configuring a 64-bit Windows server as a GIS server  using <a href="http://mapserver.org/" target="_blank">MapServer</a> and Python.</p>
<p style="text-align: justify;"><em>Why move to 64-bit?</em></p>
<p style="text-align: justify;">If a server’s operating system and hardware are 64-bit it seems a waste not to take advantage of them. It may be better to look at the question why move to 64-bit software, as <em>why wouldn’t you</em> <em>move to 64-bit software?</em></p>
<p style="text-align: justify;">Its nice to be able to claim one-upmanship over <a href="http://resources.arcgis.com/content/kbase?fa=articleShow&amp;d=29391" target="_blank">commercial GIS products</a> who are only now bringing out 64 bit versions. However having gone through the pain of setting up Open Source GIS applications on Windows I’m not surprised companies took the time to simplify the process (and wait for Microsoft to do some of the legwork) rather than dealing with all the 32/64 bit support issues too early.</p>
<div style="text-align: justify;"><span id="more-635"></span></div>
<h4 style="text-align: justify;">Memory &amp; Performance</h4>
<div style="text-align: justify;">
<blockquote><p>Intel x86/32-bit architecture limits virtual memory space to 3 GB, not 4 GB, due to much of the 3–4 GB region being reserved for hardware addressing &#8211; <a href="http://en.wikipedia.org/wiki/64-bit#Pros_and_cons" target="_blank">Wikipedia</a></p></blockquote>
</div>
<p style="text-align: justify;">Performance-wise one of the main benefits of 64-bit hardware is the extra memory you can add to a server. 64 bit Windows 7 can support up to <a href="http://msdn.microsoft.com/en-us/library/aa366778%28VS.85%29.aspx" target="_blank">128 GB of RAM</a>. GIS applications are used to dealing with large spatial datasets – both raster and vector, and will therefore be able to make full use of additional memory. This is not the case for all programs for example <a href="http://blogs.msdn.com/b/ricom/archive/2009/06/10/visual-studio-why-is-there-no-64-bit-version.aspx" target="_blank">Visual Studio</a> which is unlikely to be multiuser or used to handle large datasets.</p>
<p style="text-align: justify;">A 64-bit server allows files larger than 4GB to be loaded directly into memory. This is very advantageous to video editing, bit also to GISs that use aerial imagery which can be served more quickly if loaded into memory rather than loading in sections.</p>
<p style="text-align: justify;">Databases make use of additional memory to cache data for faster responses to user requests, and to handle more concurrent connections – there is a nice summary post on the <a href="http://blogs.msdn.com/b/sqlprogrammability/archive/2007/04/30/will-64-bit-increase-the-performance-of-my-sql-server-application.aspx" target="_blank">benefits of 64-bit for SQL Server here</a>. Spatial databases, with their additional larger and complex data structures, are even better placed to take advantage of 64-bit computing.</p>
<h4 style="text-align: justify;">Future Proofing</h4>
<p style="text-align: justify;">Even though it is not the easiest thing to configure a GIS server, nearly all future software will have a 64 bit release, and in a few years 32 bit versions may start to be phased out. Future-proofing a system currently in development may help your GIS to last a few more years in a production environment.</p>
<p style="text-align: justify;">Another benefit is that you can start designing your infrastructure to scale – all on the same physical machine. You can create a virtual web server, a virtual database server, and a virtual map server and divide up large amounts of memory, facilitated by a 64-bit architecture, between them. If the site needs to allow for more users, you can simply take the virtual server and move it to another physical machine – and (in theory) there is very little to configure once the virtual machine has been moved.</p>
<h4 style="text-align: justify;">Cost</h4>
<p style="text-align: justify;">As noted above the reduced number of physical machines should mean lower maintenance costs. In addition if you can get more throughput from your database then this may require fewer licences (such as for SQL Server 2008 which often comes with a per-processor licence). Of course with a 64-bit server you could have up to 64 processors, although this could well melt the server’s case..</p>
<p style="text-align: justify;">
<p style="text-align: justify;">
<p style="text-align: justify;">
<h4 style="text-align: justify;">What to Update?</h4>
<p style="text-align: justify;">I’m currently involved in a couple of projects, one using Windows Server 2008 and another Windows Server 2003. Both are 64-bit operating systems on 64-bit hardware. As 32-bit and 64-bit applications don’t play very well together it seems it will be an “all or nothing” migration, involving the following components:</p>
<ul style="text-align: justify;">
<li>
<div>MapServer</div>
</li>
<li>
<div><a href="http://www.gdal.org/" target="_blank">GDAL</a></div>
</li>
<li>
<div>Python (for TileCache and Mapscript)</div>
</li>
<li>
<div>Shapely</div>
</li>
</ul>
<p style="text-align: justify;">I’ll try and put steps together for each of these for my future sanity, and also in the help that there will be a few more developers straddling the Open Source and Windows divide. It would be nice at the end to post some benchmarks, but running both set ups on the same server could prove <span style="text-decoration: line-through;">problematic </span>traumatic. If anyone has noticed performance increases when using 64-bit GIS applications please leave comments!</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/mO3RSBiYS6c" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/gis-servers-and-the-64-bit-question/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/gis-servers-and-the-64-bit-question?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=gis-servers-and-the-64-bit-question</feedburner:origLink></item>
		<item>
		<title>Using TileCache on IIS</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/MTd1o6cI8WA/using-tilecache-on-iis</link>
		<comments>http://geographika.co.uk/using-tilecache-on-iis#comments</comments>
		<pubDate>Sun, 04 Jul 2010 12:43:50 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[mapserver]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[wms]]></category>
		<category><![CDATA[iis]]></category>
		<category><![CDATA[PyISAPIe]]></category>
		<category><![CDATA[tilecache]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=612</guid>
		<description><![CDATA[I’ve previously written about using PyISAPie to run Python under IIS – this allows Python scripts to run faster than using CGI. Rather than starting up the Python interpreter each time a request is made to the web server, PyISAPIe starts the interpreter once and only needs to run the script at each request. TileCache <a href='http://geographika.co.uk/using-tilecache-on-iis'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><img class="aligncenter" style="margin: 0px; display: inline; border-width: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/07/image.png" border="0" alt="image" width="135" height="147" align="left" />I’ve previously written about using <a href="http://geographika.co.uk/setting-up-python-on-iis7" target="_blank">PyISAPie to run Python under IIS</a> – this allows Python scripts to run faster than using CGI. Rather than starting up the Python interpreter each time a request is made to the web server, PyISAPIe starts the interpreter once and only needs to run the script at each request.</p>
<p style="text-align: justify;"><a href="http://tilecache.org" target="_blank">TileCache</a> provides a Python-based WMS-C/TMS server &#8211; this is allows you create a local disk-based cache of any WMS server (in my case MapServer), and then connect to it through a WMS-C client such as OpenLayers. Using a cache means that rather than have MapServer create an image for every single request for a tile, the first time a tile is requested the image is saved in a folder on the server. On all subsequent requests for the same data TileCache can retrieve this file without needing MapServer. Performance increase is incredible &#8211; however watch out for filling up disk space, and remember to empty the cache if you change symbology or update your data.</p>
<p style="text-align: justify;">As mod_python is <a href="http://blog.dscpl.com.au/2010/06/modpython-project-is-now-officially.html" target="_blank">now officially dead</a> (and has been moved in Apache’s attic), it is yet another reason if you are using Windows servers to run everything through IIS rather than the rather clumsy Apache on Windows. Why pay for Windows, and then install a web server port, thereby losing all the tools, security, and utilities within Windows to manage and administer the web server?</p>
<p style="text-align: justify;">The aim of this post is to describe the set up of TileCache, running through IIS.<span id="more-612"></span></p>
<p style="text-align: justify;"><strong>Step 1</strong></p>
<p style="text-align: justify;">Install and configure <a href="http://geographika.co.uk/setting-up-python-on-iis7" target="_blank">PyISAPIe</a></p>
<p style="text-align: justify;"><strong>Step 2</strong></p>
<p style="text-align: justify;">Place the following script in an application on IIS &#8211; <a title="http://bitbucket.org/geographika/mapserver-scripts/src/tip/tilecache/tilecache.py" href="http://bitbucket.org/geographika/mapserver-scripts/src/tip/tilecache/tilecache.py">http://bitbucket.org/geographika/mapserver-scripts/src/tip/tilecache/tilecache.py</a>. Set this script to be handled by PyISAPIe as described in the link in Step 1.</p>
<p style="text-align: justify;">In the script update the following line to point to your root MapServer WMS URL. MapServer itself can also run well under IIS.</p>
<pre class="brush: python; title: ; notranslate">wms_url = 'http://localhost/mapserver/mapserv.exe?'</pre>
<p style="text-align: justify;">A few caveats related to this script:</p>
<ul style="text-align: justify;">
<li>the resolutions are hard-coded to the Mercator resolutions used by Google Maps, Bing Maps, OpenStreetMap etc.</li>
<li>the SRS is coded to EPSG:3785 which is the equivalent of EPSG:900913 – the “Google” Mercator projection. I believe the code has changed again, but in any case it can be set by changing the script</li>
<li>parsing of the query string sent to the server is done using the Python CGI module. There are newer modules to handle query strings, but these may not be compatible with TileCache which is works with Python 2.5  and 2.6 (I&#8217;ve not tried with newer versions)</li>
</ul>
<p style="text-align: justify;"><strong>Step 3</strong></p>
<p style="text-align: justify;">Some minor alterations need to be made to the TileCache scripts themselves, otherwise the following errors will occur:</p>
<pre class="brush: python; title: ; notranslate">

Traceback (most recent call last):
 File &quot;C:\Python25\PyISAPIe\Http\Isapi.py&quot;, line 49, in Request
 raise ImportError, &quot;[Loading '%s'] %s&quot; % (Env.SCRIPT_TRANSLATED, str(Val))
ImportError: [Loading '\\?\c:\inetpub\wwwroot\tilecache\tilecache.py'] 'module' object has no attribute 'argv'
</pre>
<p style="text-align: justify;">This is due to the following lines in the service.py file:</p>
<pre class="brush: python; title: ; notranslate">
# Windows doesn't always do the 'working directory' check correctly.
if sys.platform == 'win32':
 workingdir = os.path.abspath(os.path.join(os.getcwd(), os.path.dirname(sys.argv[0])))
 cfgfiles = (os.path.join(workingdir, &quot;tilecache.cfg&quot;), os.path.join(workingdir,&quot;..&quot;,&quot;tilecache.cfg&quot;))
else:
 cfgfiles = (&quot;/etc/tilecache.cfg&quot;, os.path.join(&quot;..&quot;, &quot;tilecache.cfg&quot;), &quot;tilecache.cfg&quot;)
</pre>
<p style="text-align: justify;">It should be commented out, leaving only the last line as follows:</p>
<pre class="brush: python; title: ; notranslate">
# Windows doesn't always do the 'working directory' check correctly.
#if sys.platform == 'win32':
#    workingdir = os.path.abspath(os.path.join(os.getcwd(), os.path.dirname(sys.argv[0])))
#    cfgfiles = (os.path.join(workingdir, &quot;tilecache.cfg&quot;), os.path.join(workingdir,&quot;..&quot;,&quot;tilecache.cfg&quot;))
#else:
cfgfiles = (&quot;/etc/tilecache.cfg&quot;, os.path.join(&quot;..&quot;, &quot;tilecache.cfg&quot;), &quot;tilecache.cfg&quot;)
</pre>
<p style="text-align: justify;">The TileCache set up should now be complete. You can point your OpenLayers WMS tiles to the TileCache URL, and parameters will be passed onto TileCache, which in turn will check its cache and return an image, or call MapServer to request that a new image is generated.</p>
<p style="text-align: justify;">Please let me know of any steps missed or errors encountered and I can update the post and script accordingly.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/MTd1o6cI8WA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/using-tilecache-on-iis/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/using-tilecache-on-iis?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=using-tilecache-on-iis</feedburner:origLink></item>
		<item>
		<title>OpenSource Upgrades</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/ff3uwimfXlM/opensource-upgrades</link>
		<comments>http://geographika.co.uk/opensource-upgrades#comments</comments>
		<pubDate>Thu, 24 Jun 2010 21:35:42 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[mapserver]]></category>
		<category><![CDATA[opinion]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[openlayers]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[upgrades]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=608</guid>
		<description><![CDATA[Moving to new versions in OpenSource has in the past been like playing Russian roulette. Just now clicking on &#8220;Upgrade to WordPress 3.0&#8243; I thought would lead to a greater understanding of the database schema, template inconsistencies, and plug-in idiosynchrocies of WordPress as I met an inevitable &#8220;Upgrade Failed. Please see log for details&#8221; message. <a href='http://geographika.co.uk/opensource-upgrades'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><img style="margin: 5px 5px 5px 0px; display: inline; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/06/image9.png" border="0" alt="image" width="207" height="215" align="left" /> Moving to new versions in OpenSource has in the past been like playing Russian roulette. Just now clicking on &#8220;Upgrade to WordPress 3.0&#8243; I thought would lead to a greater understanding of the database schema, template inconsistencies, and plug-in idiosynchrocies of WordPress as I met an inevitable &#8220;Upgrade Failed. Please see log for details&#8221; message.</p>
<p style="text-align: justify;">But no! <strong>Five seconds</strong> later, all was successful, and everything looked as before. There have been numerous <a href="http://codex.wordpress.org/Version_3.0" target="_blank">bug fixes and improvements</a>, but after a brief look through the list I didn’t see any “killer” new features.</p>
<p style="text-align: justify;">In the world of GIS however there are a number of important new versions coming up this summer.</p>
<h3 style="text-align: justify;"><a href="http://openlayers.org/" target="_blank"><span id="more-608"></span>OpenLayers</a></h3>
<p style="text-align: justify;">OpenLayers 3.0 development has started. Key features and ideology are <a href="http://openlayers.org/pipermail/dev/2010-June/006189.html" target="_blank">listed here</a>. There is also a <a href="http://trac.openlayers.org/wiki/three" target="_blank">wiki page</a>. There is a move towards separating the core functions from the UI. I get the feeling OpenLayers could be moving from a homage to the Google Maps API , into a full JavaScript / browser geospatial framework.</p>
<blockquote style="text-align: justify;"><p>The core should focus on the following:</p>
<ul>
<li>layer management &#8211; tile handling &amp; vector rendering</li>
<li>map &amp; layer related event handling</li>
<li>server/client communication &#8211; generating requests and parsing responses</li>
<li>geometry digitization &amp; editing</li>
</ul>
<p>A separate OpenLayers UI lib should focus on the following:</p>
<ul>
<li>rendering of buttons and other widgets</li>
<li>presenting map information that is not rendered as features (layer properties, feature attributes)</li>
<li>gathering user input for map configuration, queries, etc.</li>
</ul>
</blockquote>
<h3 style="text-align: justify;"><a href="http://mapserver.org/" target="_blank">MapServer</a></h3>
<p style="text-align: justify;">On the server side of things, it seems <a href="http://geoserver.org/display/GEOS/Welcome" target="_blank">GeoServer</a> has recently had more traction than the older MapServer. However there will soon be (sometime in July if I understand correctly) a <a href="http://trac.osgeo.org/mapserver/wiki/60ReleasePlan" target="_blank">version 6</a>.  This has a number of new items I’ve recently required for a new project, and they are now tantalisingly within reach. These include:</p>
<ul style="text-align: justify;">
<li>XML mapfile consumption: run-time compilation (XML/XSLT =&gt; .map) or embedded XML parser <em>- it will then be possible to easily generate and manipulate MapFiles from a database, or script (I’m sure these already exist, but moving to XML will mean all sorts of powerful libraries in any language can be used to do this)</em></li>
<li>Output formats: KML and GeoJSON – <em>excellent news! I’ve tried WFS, and I don’t like it. Its nowhere near as ubiquitous as KML (a now open standard) , or as easy to manipulate as JSON. </em></li>
<li>Tile caching support<em> – whilst it is slightly annoying that having got to grips with </em><a href="http://tilecache.org/" target="_blank"><em>TileCache</em></a><em> and Windows it looks like it will be integrated into MapServer, one less system component to deal with is always a good thing. </em></li>
</ul>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/ff3uwimfXlM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/opensource-upgrades/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/opensource-upgrades?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=opensource-upgrades</feedburner:origLink></item>
		<item>
		<title>A 10 Minute Intro on using BitBucket with Windows</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/3NvREOpaNN4/a-10-minute-intro-on-using-bitbucket-with-windows</link>
		<comments>http://geographika.co.uk/a-10-minute-intro-on-using-bitbucket-with-windows#comments</comments>
		<pubDate>Wed, 09 Jun 2010 11:38:07 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[bitbucket]]></category>
		<category><![CDATA[sourcecontrol]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=593</guid>
		<description><![CDATA[There are already a couple of official quick start guides to using Mercurial’s Window’s client program TortoiseHG, but below are the bare details of how to use it with a new account on the BitBucket service. 1. Create a new account on http://bitbucket.org/. Then create a new repository for your code. 2. Download the TortoiseHG <a href='http://geographika.co.uk/a-10-minute-intro-on-using-bitbucket-with-windows'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">There are already a couple of <a href="http://tortoisehg.bitbucket.org/manual/1.0/quick.html" target="_blank">official quick start guides</a> to using Mercurial’s Window’s client program <a href="http://tortoisehg.bitbucket.org/" target="_blank">TortoiseHG</a>, but below are the bare details of how to use it with a new account on the <a href="http://geographika.co.uk/?p=584" target="_blank">BitBucket service</a>.</p>
<p style="text-align: justify;"><span id="more-593"></span></p>
<p style="text-align: justify;">1. Create a new account on <a href="http://bitbucket.org/">http://bitbucket.org/</a>. Then create a new repository for your code.</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/06/image2.png" border="0" alt="image" width="253" height="124" /></p>
<p style="text-align: justify;">2. Download the TortoiseHG program for Windows from <a href="http://tortoisehg.bitbucket.org/">http://tortoisehg.bitbucket.org/</a>. Install and reboot. This will add context commands to Windows Explorer.</p>
<p style="text-align: justify;">3. Right-click on a folder in Windows Explorer that contains the code files or scripts you want to add to your BitBucket account, and select “Create Repository Here” from the context menu.</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/06/image3.png" border="0" alt="image" width="374" height="138" /></p>
<p style="text-align: justify;">4. Next right-click in the folder and select “Add Files.” You can now check which files in the folder you wish to add to BitBucket, and click the “Add” button.</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/06/image4.png" border="0" alt="image" width="411" height="296" /></p>
<p style="text-align: justify;">5. Right-click again in the folder and select “Hg Commit.” The screen below should appear. You can enter a text description for the update (“add tilecache script” in the image below). Once you’ve done this click the “Commit” button in the toolbar.</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/06/image5.png" border="0" alt="image" width="514" height="338" /></p>
<p style="text-align: justify;">6. Right-click again in the folder and select “Hg Repository Explorer.” Add the name of your BitBucket repository to the address bar as shown below. In this case my repository is <a href="http://bitbucket.org/geographika/mapserver-scripts">http://bitbucket.org/geographika/mapserver-scripts</a> – yours should be in a similar format.</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/06/image6.png" border="0" alt="image" width="412" height="79" /></p>
<p style="text-align: justify;">7. In the menu select “Synchronize” and then “Push”</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/06/image7.png" border="0" alt="image" width="331" height="231" /></p>
<p style="text-align: justify;">8. You should be presented with a confirmation dialog as below. You will be asked for your username and password for BitBucket (step 1). That’s it! You can then check your code online, and learn the rest at your own pace! Let me know if you’ve posted anything good in the comments below!</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/06/image8.png" border="0" alt="image" width="283" height="123" /></p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/3NvREOpaNN4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/a-10-minute-intro-on-using-bitbucket-with-windows/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/a-10-minute-intro-on-using-bitbucket-with-windows?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=a-10-minute-intro-on-using-bitbucket-with-windows</feedburner:origLink></item>
		<item>
		<title>Source Control using BitBucket</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/HmruBHQjFIk/source-control-using-bitbucket</link>
		<comments>http://geographika.co.uk/source-control-using-bitbucket#comments</comments>
		<pubDate>Wed, 09 Jun 2010 11:15:45 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[opinion]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[bitbucket]]></category>
		<category><![CDATA[mercurial]]></category>
		<category><![CDATA[sourcecontrol]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=584</guid>
		<description><![CDATA[Putting code under source control is on most checklists for modern software development. Even small side projects, scripts, and code snippets can benefit from being under source control. For example: When you improve the code others can see the changes and get the benefits If someone else improves the code those improvements can be passed <a href='http://geographika.co.uk/source-control-using-bitbucket'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Putting code under source control is on most <a href="http://www.codinghorror.com/blog/2006/07/what-is-modern-software-development.html" target="_blank">checklists for modern software development</a>. Even small side projects, scripts, and code snippets can benefit from being under source control. For example:</p>
<ul style="text-align: justify;">
<li><img style="margin-right: 5px; margin-left: 15px; display: inline;" src="http://bitbucket-assets.s3.amazonaws.com/img/logo_myriad.png" alt="" width="169" height="44" align="right" />When you improve the code others can see the changes and get the benefits</li>
<li>If someone else improves the code those improvements can be passed back to you via an automated process</li>
</ul>
<p style="text-align: justify;"><a href="http://bitbucket.org/" target="_blank">BitBucket</a> is a hosting service for the code-source control system <a href="http://en.wikipedia.org/wiki/Mercurial" target="_blank">Mercurial</a>. Mecurial is part of a new-wave of <a href="http://betterexplained.com/articles/intro-to-distributed-version-control-illustrated/" target="_blank">distributed source control systems</a> that have the following advantages and disadvantages over regular non-distributed source control:</p>
<p style="text-align: justify;"><span id="more-584"></span></p>
<table style="text-align: justify; height: 112px;" border="0" cellspacing="2" cellpadding="8" width="517">
<tbody>
<tr style="padding-left: 60px;">
<td width="240" valign="top"><strong>Advantages</strong></td>
<td width="275" valign="top"><strong>Disadvantages</strong></td>
</tr>
<tr>
<td width="240" valign="top">
<li>Everyone has a local sandbox</li>
<li>It works offline</li>
<li>It’s fast</li>
<li>It handles changes well</li>
<li>Branching and merging is easy</li>
<li>Less management</li>
</td>
<td width="275" valign="top">
<li>You still need a backup.</li>
<li>There’s not really a “latest version”</li>
<li>There aren’t really revision numbers.</li>
</td>
</tr>
</tbody>
</table>
<p style="text-align: justify;"><a href="http://github.com/" target="_blank">GitHub</a> a similar service but based on the distributed source control system <a href="http://en.wikipedia.org/wiki/Git_%28software%29" target="_blank">Git</a> developed by Linus Torvald the creator or Linux. Whilst the debate rages on which of <a href="http://stackoverflow.com/questions/1598759/git-and-mercurial-compare-and-contrast" target="_blank">Mecurial and Git</a> is better, I chose Mercurial because <a href="http://importantshock.wordpress.com/2008/08/07/git-vs-mercurial/" target="_blank">Git is MacGyver and Mercurial is James Bond</a>. Also Git isn’t the nicest word in <a href="http://en.wikipedia.org/wiki/Git_%28British_slang%29" target="_blank">this part of the world</a>.</p>
<p style="text-align: justify;">There are already some GIS related projects in BitBucket such as <a href="http://bitbucket.org/sgillies/descartes/overview" target="_blank">Descartes</a>, some <a href="http://bitbucket.org/tibor_arpas/tcpatches/overview" target="_blank">TileCache Patches</a>, and some <a href="http://bitbucket.org/tsauerwein/openlayers-html5-code/overview" target="_blank">OpenLayers HTML 5 code</a> that may be of interest. It&#8217;s <a href="http://bitbucket.org/plans" target="_blank">also free</a> if you use public code repositories (you can have 1 private one) and use less than 1GB of space – which is <em>a lot</em> of source code.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/HmruBHQjFIk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/source-control-using-bitbucket/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/source-control-using-bitbucket?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=source-control-using-bitbucket</feedburner:origLink></item>
		<item>
		<title>OpenAerialMap</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/9Cyj-t6yqw8/openaerialmap</link>
		<comments>http://geographika.co.uk/openaerialmap#comments</comments>
		<pubDate>Sun, 06 Jun 2010 16:57:03 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[opinion]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[openaerialmap]]></category>
		<category><![CDATA[osm]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=535</guid>
		<description><![CDATA[Everyone loves aerial photography. Some of its early pioneers were the James Bonds of their era. Twenty years ago people could go round neighbourhoods in England and sell people frames photographs of their houses from the air. Today people spend hours looking at the aerial photography layer on Google Maps wondering why so many people <a href='http://geographika.co.uk/openaerialmap'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><img style="margin: 0px 5px 0px 0px; display: inline; border-width: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/05/image6.png" border="0" alt="image" width="224" height="197" align="left" /> Everyone loves aerial photography. Some of its <a href="http://en.wikipedia.org/wiki/Sidney_Cotton#Spy_missions" target="_blank">early pioneers</a> were the James Bonds of their era. Twenty years ago people could go round neighbourhoods in England and sell people frames photographs of their houses from the air.</p>
<p style="text-align: justify;">Today people spend hours looking at the aerial photography layer on Google Maps wondering why so many people have outdoor swimming pools in the UK..</p>
<p style="text-align: justify;">People also like <a href="http://www.freeourdata.org.uk/index.php" target="_blank">free data</a>. And companies like <a href="http://wiki.openstreetmap.org/wiki/Faq#Why_don.27t_you_just_use_Google_Maps.2Fwhoever_for_your_data.3F" target="_blank">data free from the Google Terms of Service</a> even more. The successful <a href="http://wiki.openstreetmap.org/wiki/OpenAerialMap" target="_blank">OpenStreetMap wiki</a> refers to what seems to be the perfect datasource &#8211; the <a href="http://openaerialmap.org/" target="_blank">OpenAerialMap</a> (OAM) project, however it starts with the rather ominous opening statement:</p>
<p style="text-align: justify;"><em>It was available at </em><a href="http://openaerialmap.org/"><em>http://openaerialmap.org/</em></a><em> but&#8230;</em></p>
<div style="text-align: justify;"><span id="more-535"></span></div>
<p style="text-align: justify;">The reasons for its demise are documented by <a href="http://crschmidt.net/" target="_blank">Christopher Schmidt</a> (a major force in the development of OpenLayers and TileCache) in <a href="http://openaerialmap.org/pipermail/talk_openaerialmap.org/2008-December/000055.html" target="_blank">this post to the mailing list</a>. In summary the main reasons for failure were technical &#8211; dealing with the huge amounts of raster data and getting disk space.</p>
<p style="text-align: justify;"><a href="http://mapfishblog.blogspot.com/" target="_blank">Cedric Mouillet</a> asked on <a href="http://openaerialmap.org/pipermail/talk_openaerialmap.org/2010-April/000361.html" target="_blank">the mailing list</a> what was the state of the project, to see if it could be used as reference mapping for the <a href="www.openaddresses.org" target="_blank">OpenAddresses</a> project. No answers were posted.</p>
<p style="text-align: justify;">There is still however life in the movement. A conference call was made at the start of May 2010 to discuss the <a href="http://openaerialmap.org/OAM_Hardware_Conference_Call" target="_blank">hardware set-up of the project</a>. Included in the attendees list for the call and on the <a href="http://www.openaerialmap.org/OAM_Steering_Committee" target="_blank">OAM Steering Committee</a> are members of OSGeo which may prove critical to the future of the project.</p>
<p style="text-align: justify;">Anyway here’s hoping to a successful second version of OAM. In the meantime Google’s aerial photography service (followed by Bing and Yahoo) will remain way out in front terms of <a href="http://www.terrametrics.com/support/faqs_content.htm" target="_blank">data quality, quantity</a>, and ease of access. Just remember it is only “free” in one sense.</p>
<p style="text-align: justify;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="580" height="360" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/FOR0fPTx-os&amp;hl=en_US&amp;fs=1&amp;rel=0&amp;border=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="580" height="360" src="http://www.youtube.com/v/FOR0fPTx-os&amp;hl=en_US&amp;fs=1&amp;rel=0&amp;border=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/9Cyj-t6yqw8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/openaerialmap/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/openaerialmap?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=openaerialmap</feedburner:origLink></item>
		<item>
		<title>Summary of Hours by Month (for every day)</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/QOQgRJiLnLA/summary-of-hours-by-month-for-every-day</link>
		<comments>http://geographika.co.uk/summary-of-hours-by-month-for-every-day#comments</comments>
		<pubDate>Wed, 02 Jun 2010 09:01:46 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[dates]]></category>
		<category><![CDATA[invoice]]></category>
		<category><![CDATA[month]]></category>
		<category><![CDATA[recursion]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=562</guid>
		<description><![CDATA[I recently read Mark Forster’s time management book Do It Tomorrow. In summary it suggests creating a task list on a daily basis, and not doing anything other than from items in that list. Only real emergencies should be dealt with. If emails arrive that have to be dealt with then add them to tomorrow’s <a href='http://geographika.co.uk/summary-of-hours-by-month-for-every-day'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">I recently read Mark Forster’s time management book <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&amp;location=https%3A%2F%2Fwww.amazon.com%2Fgp%2Fyourstore%3Fie%3DUTF8%26ref_%3Dpd%5Firl%5Fgw%26signIn%3D1&amp;tag=geographika-20&amp;linkCode=ur2&amp;camp=1789&amp;creative=390957">Do It Tomorrow</a>. In summary it suggests creating a task list on a daily basis, and not doing anything other than from items in that list. Only <em>real</em> emergencies should be dealt with.</p>
<p style="text-align: justify;">If emails arrive that have to be dealt with then add them to tomorrow’s list – that way you have a chance of completing your tasks for a day, and can switch off the computer feeling that you’re finished for the day.</p>
<p style="text-align: justify;">There is also a chapter at the end of the book that says anytime invested in improving systems and processes is time gained. This fits in with the ethos of many programming books – to automate things as much as possible.</p>
<p style="text-align: justify;">As I work on a number of different client projects I use a time tracking database to enter hours worked on a daily basis. It is fairly trivial to get a summary of hours for a month, but what I needed to provide (for invoicing) was a full list of days in a month and hours worked – whether there were values or not.</p>
<h3 style="text-align: justify;"><span id="more-562"></span>Solution</h3>
<p style="text-align: justify;">To test the solution you can create a temporary table to mock the hours worked for a project. Running the following SQL should produce a table similar to below:</p>
<pre class="brush: sql; title: ; notranslate">CREATE TABLE #WorkingHours (
[Date] datetime,
[Duration] decimal(18,2),
[ProjectId] int)
GO

INSERT INTO #WorkingHours ([Date],[Duration],[ProjectId])
VALUES(CONVERT(datetime, '20100503'),8.5,18)
GO
INSERT INTO #WorkingHours ([Date],[Duration],[ProjectId])
VALUES(CONVERT(datetime, '20100504'),8,18)
GO
INSERT INTO #WorkingHours ([Date],[Duration],[ProjectId])
VALUES(CONVERT(datetime, '20100507'),7.5,18)
GO
INSERT INTO #WorkingHours ([Date],[Duration],[ProjectId])
VALUES(CONVERT(datetime, '20100508'),7,18)
GO
INSERT INTO #WorkingHours ([Date],[Duration],[ProjectId])
VALUES(CONVERT(datetime, '20100511'),8.5,18)
GO

SELECT * FROM #WorkingHours
GO</pre>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border-width: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/06/image.png" border="0" alt="image" width="241" height="98" /></p>
<p style="text-align: justify;">Now to create a list of dates for the previous month use the following SQL:</p>
<pre class="brush: sql; title: ; notranslate">WITH LastMonthsDates
AS
(
  --first day of last month
  SELECT DATEADD(m,-1,DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()))
  AS [calendardate]
  UNION ALL
  SELECT DATEADD(dd, 1, [calendardate])
  FROM LastMonthsDates
  --less than or equal to last day of month
  WHERE DATEADD(dd, 1, [calendardate]) &lt;=
  DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0))
)

SELECT CONVERT(VARCHAR(10), [calendardate], 103) AS [Day]
,CASE WHEN SUM(WH.Duration) IS NULL THEN 0 ELSE SUM(WH.Duration) END AS Hours
FROM LastMonthsDates
LEFT OUTER JOIN #WorkingHours WH ON
DATEDIFF(d, [calendardate], [Date]) = 0 AND WH.ProjectId = 18
GROUP BY [calendardate]
ORDER BY [calendardate] ASC</pre>
<p style="text-align: justify;">This should produce a record for each day similar to the output below (using the UK date format):</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/06/image1.png" border="0" alt="image" width="143" height="165" /></p>
<p style="text-align: justify;">This SQL was built up from a variety of source. To get the last day of the previous month I used the code from <a href="http://blog.sqlauthority.com/2007/05/13/sql-server-query-to-find-first-and-last-day-of-current-month/" target="_blank">here</a>. The code for creating a range of dates is based on the ideas <a href="http://www.kodyaz.com/articles/sql-server-dates-table-using-tsql-cte-calendar-table.aspx" target="_blank">in this blog post</a>.</p>
<p style="text-align: justify;">However the use of recursion to create the calendar table is not recommended for large date ranges due the performance issues <a href="http://ask.sqlservercentral.com/questions/4099/what-are-the-pros-and-cons-of-using-a-temporary-dates-table-instead-of-a-permanen" target="_blank">discussed here</a>. In cases where yearly reports need to be generated it is suggested creating a full table of dates in your database and joining to this rather than creating it dynamically.</p>
<p style="text-align: justify;">Finally it took me a while to realise that to limit records in the WorkingHours table (for example by ProjectId, or a UserId) the WHERE clause should be added to part of the join, otherwise records are excluded. So rather than:</p>
<pre class="brush: sql; title: ; notranslate">SELECT * FROM LastMonthsDates
LEFT OUTER JOIN #WorkingHours WH ON
DATEDIFF(d, [calendardate], [Date]) = 0
WHERE WH.ProjectId = 18
</pre>
<p style="text-align: justify;">I needed to use:</p>
<pre class="brush: sql; title: ; notranslate">SELECT * FROM LastMonthsDates
LEFT OUTER JOIN #WorkingHours WH ON
DATEDIFF(d, [calendardate], [Date]) = 0
AND WH.ProjectId = 18
</pre>
</pre>
<p>Thanks to this <a href="http://forums.devshed.com/oracle-development-96/combination-of-left-outer-join-and-where-clause-383248.html">forum post</a> for pointing out that the WHERE conditions should be moved to the ON clause.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/QOQgRJiLnLA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/summary-of-hours-by-month-for-every-day/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/summary-of-hours-by-month-for-every-day?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=summary-of-hours-by-month-for-every-day</feedburner:origLink></item>
		<item>
		<title>We Know Where Your Browser Lives</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/WyIslbTuTSg/we-know-where-your-browser-lives</link>
		<comments>http://geographika.co.uk/we-know-where-your-browser-lives#comments</comments>
		<pubDate>Fri, 28 May 2010 12:03:00 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[opinion]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[geolocation]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=543</guid>
		<description><![CDATA[Maybe I’m a little late in finding this, but if you have FireFox 3.5 or higher try clicking this link (you will have to agree to let your browser divulge your location to open the link). The JavaScript code run when clicking the link is as follows, and can also be pasted directly into your <a href='http://geographika.co.uk/we-know-where-your-browser-lives'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><img style="margin: 0px 5px 0px 0px; display: inline; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/05/image7.png" border="0" alt="image" width="109" height="180" align="left" /> Maybe I’m a <a href="http://www.theregister.co.uk/2009/06/30/firefox_3point5_review/" target="_blank">little late</a> in finding this, but if you have FireFox 3.5 or higher try clicking <a onclick="javascript:navigator.geolocation.getCurrentPosition(function(position){window.open(&quot;http://maps.google.com/?ll=&quot;+position.coords.latitude+&quot;,&quot;+position.coords.longitude,'_blank');});return false;" href="#">this link</a> (you will have to agree to let your browser divulge your location to open the link). The JavaScript code run when clicking the link is as follows, and can also be pasted directly into your address bar:</p>
<pre style="text-align: justify;">javascript:navigator.geolocation.getCurrentPosition(
function(position){
window.location.href="http://maps.google.com/?ll="+position.coords.latitude+",
"+position.coords.longitude;});</pre>
<p style="text-align: justify;">I believe the navigator.geolocation object is also available in Safari, iPhone, and Chrome. The <a href="http://www.mozilla.com/en-US/firefox/geolocation/" target="_blank">Mozilla documentation</a> provides more details on its use. This <a href="http://stackoverflow.com/questions/1349064/which-devices-support-javascript-geolocation-via-navigator-geolocation" target="_blank">StackOverflow question</a> asks which browsers and devices it applies to, and this is set to grow if it becomes part of the browser standards &#8211; the W3C has an online draft <a href="http://dev.w3.org/geo/api/spec-source.html" target="_blank">Geolocation API Specification</a>. They list the following <a href="http://dev.w3.org/geo/api/spec-source.html#usecases" target="_blank">use cases</a>:<span id="more-543"></span></p>
<ul style="text-align: justify;">
<li>Find points of interest in the user&#8217;s area</li>
<li>Annotating content with location information</li>
<li>Show the user&#8217;s position on a map</li>
<li>Turn-by-turn route navigation</li>
<li>Alerts when points of interest are in the user&#8217;s vicinity</li>
<li>Up-to-date local information</li>
<li>Location-tagged status updates in social networking applications</li>
</ul>
<p style="text-align: justify;">There is also a framework API <em>aligned</em> to the W3C specification at <a href="http://code.google.com/p/geo-location-javascript/" target="_blank">http://code.google.com/p/geo-location-javascript/</a></p>
<p style="text-align: justify;">In the week that ArcGIS is released as a <a href="http://www.spatiallyadjusted.com/2010/05/24/arcgis-com-beta-goes-live/" target="_blank">“cloud service”</a>, I believe the real power of the Internet will come more from manipulating and <a href="http://geographika.co.uk/?p=517" target="_blank">combining data services</a> than putting desktop applications in a browser. Especially if these applications can’t easily integrate open web services. When the full range of ArcGIS geoprocessing tools can be fed streams of GeoJSON, combined with user location, then the geocloud will have truely arrived.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/WyIslbTuTSg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/we-know-where-your-browser-lives/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/we-know-where-your-browser-lives?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=we-know-where-your-browser-lives</feedburner:origLink></item>
		<item>
		<title>Visualising GeoJSON in 15 Minutes</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/f_8-dL9TUY8/visualising-geojson-in-15-minutes</link>
		<comments>http://geographika.co.uk/visualising-geojson-in-15-minutes#comments</comments>
		<pubDate>Mon, 24 May 2010 15:10:43 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[cloudmade]]></category>
		<category><![CDATA[descartes]]></category>
		<category><![CDATA[geojson]]></category>
		<category><![CDATA[mapplotlib]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=526</guid>
		<description><![CDATA[The objective of this post is to save a GeoJSON feature collected from the web to an image file, and was inspired by the Shapely manual. This will be done using Windows, Python 2.5 (although 2.6 should be almost exactly the same steps), and some additional Python packages. This example uses GeoJSON data from a <a href='http://geographika.co.uk/visualising-geojson-in-15-minutes'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">The objective of this post is to save a GeoJSON feature collected from the web to an image file, and was inspired by the <a href="http://gispython.org/shapely/docs/1.2/manual.html" target="_blank">Shapely manual</a>. This will be done using Windows, Python 2.5 (although 2.6 should be almost exactly the same steps), and some additional Python packages. This example uses GeoJSON data from a <a href="http://geographika.co.uk/?p=517" target="_blank">CloudMade geocoding service</a>.</p>
<p style="text-align: center;"><img class="aligncenter" style="margin-top: 0px; margin-bottom: 0px; display: block; border: 0pt none;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/05/image3.png" border="0" alt="image" width="246" height="218" /></p>
<p style="text-align: justify;">The greatest difficulty when trying to do things in Python is getting the right packages to match your Python version, and making sure all the package dependencies are in place.</p>
<h3 style="text-align: justify;"><span id="more-526"></span>Set Up Steps</h3>
<p style="text-align: justify;"><strong>1. Download Numpy</strong> from <a title="http://sourceforge.net/projects/numpy/files/NumPy/" href="http://sourceforge.net/projects/numpy/files/NumPy/">http://sourceforge.net/projects/numpy/files/NumPy/</a>. Numpy is <em>“a package that defines a multi-dimensional array object and associated fast math functions that operate on it.”</em></p>
<p style="text-align: justify;">Check that you download the version that matches your Python installation.  In my case I needed numpy-1.4.1-win32-superpack-python2.5.exe.</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border-width: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/05/image4.png" border="0" alt="image" width="218" height="165" /></p>
<p style="text-align: justify;"><strong>2. Download MatPlotLib</strong> from <a title="http://sourceforge.net/projects/matplotlib/files/" href="http://sourceforge.net/projects/matplotlib/files/">http://sourceforge.net/projects/matplotlib/files/</a>. I downloaded <a href="http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-0.99.1/matplotlib-0.99.1.win32-py2.5.exe/download">matplotlib-0.99.1.win32-py2.5.exe</a>. Again there are many different versions that can be downloaded – expand the arrows to see the options.</p>
<p style="text-align: justify;">There’s even a 64-bit version for Windows. However there doesn’t appear to be a 64 bit version of Numpy for Windows, and as Numpy is required by MapPlotLib to run I’m not sure how it could ever be of use. This is where the whole Python packages and 3rd party libraries gets exceedingly confusing..</p>
<p style="text-align: justify;"><strong>3. Install the Python setuptools </strong>from <a title="http://pypi.python.org/pypi/setuptools" href="http://pypi.python.org/pypi/setuptools">http://pypi.python.org/pypi/setuptools</a>. These tools include easy_install which “<em>lets you automatically download, build, install, and manage Python packages.</em>” Again get the relevant Python package in my case <a href="http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c11.win32-py2.5.exe#md5=cb0cd7b844bed5106aeb0d4583848b1f">setuptools-0.6c11.win32-py2.5.exe</a>.</p>
<p style="text-align: justify;">If you have only installed Python during your log in session then <a href="http://geographika.co.uk/reboot-to-refresh-environment-variables" target="_blank">reboot to refresh your environment variables.</a> This should allow you to use the easy_install program directly from the Windows Command Prompt (by typing easy_install rather than the full path).</p>
<p style="text-align: justify;"><strong>4. We can now install <a href="http://pypi.python.org/pypi/descartes/1.0" target="_blank">descartes</a> </strong>using the easy_install program. Descartes is uses <em>&#8220;geometric objects as matplotlib paths and patches.&#8221;</em> Type the command below (the full path may not be required) into a Windows Command Prompt:</p>
<pre style="text-align: justify;">C:\Python25\Scripts\easy_install.exe descartes</pre>
<p style="text-align: justify;">This command should return output similar to below:</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border-width: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/05/image5.png" border="0" alt="image" width="399" height="55" /></p>
<p style="text-align: justify;">If you already have IDLE (the Python editor open) then quit it and restart. If not you are likely to get “ImportError: No module named X” errors, even though the modules have been installed.</p>
<p style="text-align: justify;"><strong>5. You should now be able to run the Python script</strong> below to generate a PNG image file of England.</p>
<pre class="brush: python; title: ; notranslate">
from matplotlib import pyplot
from descartes import PolygonPatch
import math
import urllib2
import simplejson

def getData():
    #create the cloudmade query url
    root = 'http://geocoding.cloudmade.com'
    apikey = '85453debd0fc4ad18c5855c3d8eef780'
    query = 'england'
    url = '%s/%s/geocoding/v2/find.geojs?query=%s&amp;amp;return_geometry=true' \
          % (root,apikey,query)

    #open the url to get the geojson
    return urllib2.urlopen(url).read()

def configurePlot():
    #set up the mapplotlib
    fig = pyplot.figure(1, figsize=(10, 4), dpi=180)
    ax = fig.add_subplot(121)
    return ax

def setPlotExtent(ax,data):
    #get feature extents (a property of the cloudmade geojson)
    #note this was previously bbox
    minx = data['bounds'][0][0]
    maxx = data['bounds'][1][0]
    miny = data['bounds'][0][1]
    maxy = data['bounds'][1][1]

    #set the graph axes to the feature extents
    ax.set_xlim(minx,maxx)
    ax.set_ylim(miny,maxy)

def plotFeature(coordlist, myplot):
    #create a polygon geojson-like feature
    poly = {&quot;type&quot;: &quot;Polygon&quot;, &quot;coordinates&quot;: coordlist}
    patch = PolygonPatch(poly, fc='#6699cc', ec='#6699cc', alpha=0.5, zorder=2)
    #plot it on the graph
    myplot.add_patch(patch)

#turn the geojson into a python object
pydata = simplejson.loads(getData())
print pydata

myplot = configurePlot()
setPlotExtent(myplot,pydata)

#loop through each polygon in the MULTIPOLYGON collection
for coordlist in pydata['features'][0]['geometry']['coordinates']:
    plotFeature(coordlist, myplot)

#save the plot as an image
pyplot.savefig('myplot.png')
</pre>
<p>I now have a way of easily visualising GeoJSON I have a way of checking spatial operations on spatial data manipulated directly from the cloud. More to follow.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/f_8-dL9TUY8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/visualising-geojson-in-15-minutes/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/visualising-geojson-in-15-minutes?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=visualising-geojson-in-15-minutes</feedburner:origLink></item>
		<item>
		<title>GeoJSON Where are You?</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/61hDawdguyI/geojson-where-are-you</link>
		<comments>http://geographika.co.uk/geojson-where-are-you#comments</comments>
		<pubDate>Fri, 21 May 2010 13:02:56 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[cloudmade]]></category>
		<category><![CDATA[geojson]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=517</guid>
		<description><![CDATA[I was looking around the web to try and find some services that returned GeoJSON to try out Shapely. It was surprisingly hard to find servers or web services given the amount of tools that have already been built to use GeoJSON. Eventually I found the CloudMade’s geocoding developer samples. CloudMade is a company that <a href='http://geographika.co.uk/geojson-where-are-you'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">I was looking around the web to try and find some services that returned <a href="http://geojson.org/" target="_blank">GeoJSON</a> to try out <a href="http://trac.gispython.org/lab/wiki/Shapely" target="_blank">Shapely</a>. It was surprisingly hard to find servers or web services given the <a href="http://wiki.geojson.org/Users" target="_blank">amount of tools</a> that have already been built to use GeoJSON.</p>
<p style="text-align: justify;">Eventually I found the CloudMade’s <a href="http://developers.cloudmade.com/wiki/geocoding-http-api/Examples" target="_blank">geocoding developer samples</a>. <a href="http://cloudmade.com/" target="_blank">CloudMade</a> is a company that builds tools and services on top of <a href="http://www.openstreetmap.org/" target="_blank">OpenStreetMap</a>. Even though many of the people involved in both CloudMade and OSM are the same, using the two brands interchangeably has not been without <a href="http://www.spatiallyadjusted.com/2010/04/17/cloudmades-openstreetmap-project-is-successful/" target="_blank">controversy</a>.</p>
<p style="text-align: justify;"><a href="http://geocoding.cloudmade.com/BC9A493B41014CAABB98F0471D759707/geocoding/v2/find.html?query=england&amp;return_geometry=true" target="_blank"><img style="margin: 0px 5px 0px 0px; display: inline; border-width: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/05/image2.png" border="0" alt="image" width="158" height="177" align="left" /></a>Once you’ve signed up for a <a href="http://www.cloudmade.com/signup" target="_blank">free account</a>, you can then register for an API key that allows you to call their web services. <a href="http://cloudmade.com/select/web" target="_blank">See here</a> for differences between free and paid accounts. The service I was interested in testing was the geocoding service that returns GeoJSON.</p>
<p style="text-align: justify;">Depending on the type of feature you are looking for you can get different geometry types – the standard point, lines, and polygons, all as GeoJSON objects.</p>
<p style="text-align: justify;">The API uses URLs and GET requests to return data. Calls can be made to either a find.html page which returns the GeoJSON object displayed on a map, as shown in the query for “england” on the left. Alternatively the query can be made to find.geojs to return just the GeoJSON itself. There is also a find.js which can be used to return geometry as JSON, although this seems a little confusing &#8211; even more so as the coordinate order is reversed from the standard GeoJSON [lon,lat].</p>
<p style="text-align: justify;"><span id="more-517"></span>The API can be used in several languages (Ruby, Perl, PHP etc.), my current choice is Python, and the CloudMade Python API documentation is <a href="http://developers.cloudmade.com/documentation/python-lib/index.html" target="_blank">available online here</a>. Retreiving GeoJSON however is easy enough even without this API. For example in Python use:</p>
<pre class="brush: python; title: ; notranslate">import urllib2

root = 'http://geocoding.cloudmade.com'
apikey = '85453debd0fc4ad18c5855c3d8eef780'
query = 'england'
url = '%s/%s/geocoding/v2/find.geojs?query=%s&amp;amp;return_geometry=true' \
      % (root,apikey,query)

json = urllib2.urlopen(url).read()

print json</pre>
<p style="text-align: justify;">Now that I have a source GeoJSON I can start to use some of the more interesting tools to analyse and manipulate these features.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/61hDawdguyI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/geojson-where-are-you/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/geojson-where-are-you?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=geojson-where-are-you</feedburner:origLink></item>
		<item>
		<title>Stack Overflow &amp; OSGeo</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/13kzkM_L22w/stack-overflow-osgeo</link>
		<comments>http://geographika.co.uk/stack-overflow-osgeo#comments</comments>
		<pubDate>Wed, 19 May 2010 19:46:28 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[osgeo]]></category>
		<category><![CDATA[stackoverflow]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=511</guid>
		<description><![CDATA[Stack Overflow, as most developers will already know, is a question and answer site for programmers. It’s perfect for mainstream development questions in any programming language, and has also become the support site of choice for some newer programming communities such as Android developers. It can also be used as a barometer to see which <a href='http://geographika.co.uk/stack-overflow-osgeo'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://stackoverflow.com/" target="_blank">Stack Overflow</a>, as most developers will already know, is a question and answer site for programmers. It’s perfect for mainstream development questions in any programming language, and has also become the support site of choice for some newer programming communities such as <a href="http://stackoverflow.com/questions/tagged/android" target="_blank">Android developers</a>. <a href="http://stackoverflow.com/" target="_blank"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/05/image1.png" border="0" alt="image" width="164" height="46" /></a></p>
<p style="text-align: justify;">It can also be used as a barometer to see which current open source GIS projects have gained traction in the mainstream programming world. I took the full list of OSGeo projects from <a title="http://www.osgeo.org/" href="http://www.osgeo.org/">http://www.osgeo.org/</a> and ran queries on the site to see how many questions there were for each project. The results are as follows (as of May 2010):</p>
<p style="text-align: justify;"><span id="more-511"></span></p>
<table style="text-align: justify;" border="1" cellspacing="0" cellpadding="2" width="561">
<tbody>
<tr>
<td width="145" valign="top"><strong>Project</strong></td>
<td width="121" valign="top"><strong>Type</strong></td>
<td width="94" valign="top"><strong>No. of Questions</strong></td>
<td width="199" valign="top"><strong>Link to Questions</strong></td>
</tr>
<tr>
<td width="145" valign="top"><a href="http://www.osgeo.org/deegree">deegree</a></td>
<td width="121" valign="top">web mapping</td>
<td width="94" valign="top">0 results</td>
<td width="199" valign="top"></td>
</tr>
<tr>
<td width="145" valign="top"><a href="http://geomajas.org/">geomajas</a></td>
<td width="121" valign="top">web mapping</td>
<td width="94" valign="top">1 result</td>
<td width="199" valign="top"><a href="http://stackoverflow.com/questions/tagged/geomajas" target="_blank">geomajas</a></td>
</tr>
<tr>
<td width="145" valign="top"><a href="http://geoserver.org/">GeoServer</a></td>
<td width="121" valign="top">web mapping</td>
<td width="94" valign="top"><strong>13 results</strong></td>
<td width="199" valign="top"><a href="http://stackoverflow.com/questions/tagged/geoserver">geoserver</a></td>
</tr>
<tr>
<td width="145" valign="top"><a href="http://www.osgeo.org/mapbender">Mapbender</a></td>
<td width="121" valign="top">web mapping</td>
<td width="94" valign="top">0 results</td>
<td width="199" valign="top"></td>
</tr>
<tr>
<td width="145" valign="top"><a href="http://www.osgeo.org/mapbuilder">MapBuilder</a></td>
<td width="121" valign="top">web mapping</td>
<td width="94" valign="top">0 results</td>
<td width="199" valign="top"></td>
</tr>
<tr>
<td width="145" valign="top"><a href="http://mapfish.org/">MapFish</a></td>
<td width="121" valign="top">web mapping</td>
<td width="94" valign="top">1 result</td>
<td width="199" valign="top"><a href="http://stackoverflow.com/questions/tagged/mapfish">mapfish</a></td>
</tr>
<tr>
<td width="145" valign="top"><a href="http://www.osgeo.org/mapguide">MapGuide</a></td>
<td width="121" valign="top">web mapping</td>
<td width="94" valign="top">1 result</td>
<td width="199" valign="top"><a title="http://stackoverflow.com/questions/tagged/mapguide" href="http://stackoverflow.com/questions/tagged/mapguide">mapguide</a></td>
</tr>
<tr>
<td width="145" valign="top"><a href="http://www.osgeo.org/mapserver">MapServer</a></td>
<td width="121" valign="top">web mapping</td>
<td width="94" valign="top">17 results</td>
<td width="199" valign="top"><a href="http://stackoverflow.com/questions/tagged/mapserver">mapserver</a> &amp; <a href="http://stackoverflow.com/questions/tagged/umn-mapserver">umn-mapserver</a></td>
</tr>
<tr>
<td width="145" valign="top"><a href="http://www.osgeo.org/openlayers">OpenLayers</a></td>
<td width="121" valign="top">web mapping</td>
<td width="94" valign="top"><strong>56 results</strong></td>
<td width="199" valign="top"><a href="http://stackoverflow.com/questions/tagged/openlayers">openlayers</a></td>
</tr>
<tr>
<td width="145" valign="top"><a href="http://www.osgeo.org/grass">GRASS GIS</a></td>
<td width="121" valign="top">desktop</td>
<td width="94" valign="top">0 results</td>
<td width="199" valign="top"></td>
</tr>
<tr>
<td width="145" valign="top"><a href="http://www.osgeo.org/ossim">OSSIM</a></td>
<td width="121" valign="top">desktop</td>
<td width="94" valign="top">0 results</td>
<td width="199" valign="top"></td>
</tr>
<tr>
<td width="145" valign="top"><a href="http://www.osgeo.org/qgis">Quantum GIS</a></td>
<td width="121" valign="top">desktop</td>
<td width="94" valign="top">0 results</td>
<td width="199" valign="top"></td>
</tr>
<tr>
<td width="145" valign="top"><a href="http://www.osgeo.org/gvsig">gvSIG</a></td>
<td width="121" valign="top">desktop</td>
<td width="94" valign="top">0 results</td>
<td width="199" valign="top"></td>
</tr>
<tr>
<td width="145" valign="top"><a href="http://fdo.osgeo.org">FDO</a></td>
<td width="121" valign="top">library</td>
<td width="94" valign="top">0 results</td>
<td width="199" valign="top"></td>
</tr>
<tr>
<td width="145" valign="top"><a href="http://www.osgeo.org/gdal_ogr">GDAL/OGR</a></td>
<td width="121" valign="top">library</td>
<td width="94" valign="top"><strong>14 results</strong></td>
<td width="199" valign="top"><a href="http://stackoverflow.com/questions/tagged/gdal">gdal</a></td>
</tr>
<tr>
<td width="145" valign="top"><a href="http://geos.osgeo.org">GEOS</a></td>
<td width="121" valign="top">library</td>
<td width="94" valign="top">2 results</td>
<td width="199" valign="top"><a href="http://stackoverflow.com/questions/tagged/geos">geos</a></td>
</tr>
<tr>
<td width="145" valign="top"><a href="http://www.osgeo.org/geotools">GeoTools</a></td>
<td width="121" valign="top">library</td>
<td width="94" valign="top">7 results</td>
<td width="199" valign="top"><a href="http://stackoverflow.com/questions/tagged/geotools">geotools</a></td>
</tr>
<tr>
<td width="145" valign="top"><a href="http://metacrs.osgeo.org/">MetaCRS</a></td>
<td width="121" valign="top">library</td>
<td width="94" valign="top">0 results</td>
<td width="199" valign="top"></td>
</tr>
<tr>
<td width="145" valign="top"><a href="http://www.postgis.org/">PostGIS</a></td>
<td width="121" valign="top">library</td>
<td width="94" valign="top"><strong>54 results</strong></td>
<td width="199" valign="top"><a href="http://stackoverflow.com/questions/tagged/postgis">postgis</a></td>
</tr>
<tr>
<td width="145" valign="top"><a href="http://www.osgeo.org/geonetwork">GeoNetwork</a></td>
<td width="121" valign="top">metadata catalog</td>
<td width="94" valign="top">0 results</td>
<td width="199" valign="top"></td>
</tr>
</tbody>
</table>
<p style="text-align: justify;">A couple of disclaimers – I added the MapFish tag, and tagged a few of the GeoTools questions myself.</p>
<p style="text-align: justify;">Its clear that OpenLayers and PostGIS are way out in front in terms of questions asked, and it may not be too much of a leap to suggest these projects are the most widely used GIS projects outside of the GIS world.</p>
<div class="mceTemp mceIEcenter" style="text-align: justify;">
<dl class="wp-caption  aligncenter" style="width: 184px;">
<dt class="wp-caption-dt"><img style="margin: 0px auto; display: block; border: 0pt none;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/05/image.png" border="0" alt="image" width="174" height="99" /></dt>
<dd class="wp-caption-dd">A JavaScript error ironically thrown by OpenLayers</dd>
</dl>
</div>
<p style="text-align: justify;">Neither of these projects however match the huge numbers of questions about <a href="http://www.slideshare.net/ajturner/how-neogeography-killed-gis?src=embed" target="_blank">neogeographer’s</a> tools of choice – <a href="http://stackoverflow.com/questions/tagged/google-maps" target="_blank">Google Maps</a> at <strong>1,369</strong> questions. Poor old Bing Maps (perhaps partly due to being renamed from Live Maps) only gets 71 questions.</p>
<p style="text-align: justify;">Stack Overflow makes use of tags and a REST API so <strong>the full collection of questions related to OSGeo projects can be seen using the <a href="http://stackoverflow.com/questions/tagged/geomajas%20or%20geoserver%20or%20mapfish%20or%20mapguide%20or%20mapserver%20or%20openlayers%20or%20gdal%20or%20geos%20or%20geotools%20or%20postgis%20or%20osgeo" target="_blank">following URL</a>.</strong></p>
<p style="text-align: justify;">While it looks very unlikely that Stack Overflow will ever replace the <a href="http://lists.osgeo.org/mailman/listinfo" target="_blank">OSGeo mailing lists</a> as the first choice for debate and support, it would be good if a few of the FAQ got asked on Stack Overflow to help new users of these projects who aren’t aware of the mailing lists, or the <a href="http://osgeo-org.1803224.n2.nabble.com/" target="_blank">Nabble interface</a> to search them. It would also spread knowledge that these projects exist to mainstream developers and could help some projects gain traction.</p>
<p style="text-align: justify;">You can also upvote (or downvote) my answers too, as there are so few GIS developers using the site that no one can assess the whether my answers are valid or nonsense..</p>
<p style="text-align: justify;"><script src="http://stackoverflow.com/users/flair/179520.js?theme=clean" type="text/javascript"></script></p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/13kzkM_L22w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/stack-overflow-osgeo/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/stack-overflow-osgeo?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=stack-overflow-osgeo</feedburner:origLink></item>
		<item>
		<title>Map Pins…</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/vXhmpaZClXI/map-pin</link>
		<comments>http://geographika.co.uk/map-pin#comments</comments>
		<pubDate>Sun, 16 May 2010 20:18:52 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[quote]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=505</guid>
		<description><![CDATA[I wanna hang a map of the world in my house. Then I&#8217;m gonna put pins into all the locations that I&#8217;ve traveled to. But first, I&#8217;m gonna have to travel to the top two corners of the map so it won&#8217;t fall down. http://en.wikipedia.org/wiki/Mitch_Hedberg]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/05/pin.jpg"><img class="alignleft size-full wp-image-506" style="margin-left: 2px; margin-right: 7px;" title="pin" src="http://geographika.co.uk/wp-content/uploads/2010/05/pin.jpg" alt="" width="118" height="157" /></a>I wanna hang a map of the world in my house. Then I&#8217;m gonna put pins  into all the locations that I&#8217;ve traveled to. But first, I&#8217;m gonna have  to travel to the top two corners of the map so it won&#8217;t fall down.</p>
<p style="text-align: justify;">
<p style="text-align: justify;"><a href="http://en.wikipedia.org/wiki/Mitch_Hedberg">http://en.wikipedia.org/wiki/Mitch_Hedberg</a></p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/vXhmpaZClXI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/map-pin/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/map-pin?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=map-pin</feedburner:origLink></item>
		<item>
		<title>Watch out for OpenLayer Distances</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/WMWnXgkl0eQ/watch-out-for-openlayer-distances</link>
		<comments>http://geographika.co.uk/watch-out-for-openlayer-distances#comments</comments>
		<pubDate>Thu, 29 Apr 2010 20:54:46 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[bing]]></category>
		<category><![CDATA[errors]]></category>
		<category><![CDATA[geodesic]]></category>
		<category><![CDATA[measurements]]></category>
		<category><![CDATA[openlayers]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=494</guid>
		<description><![CDATA[I had the fortune on my most recent project, a MapFish mapping system, of having someone else do some thorough testing. One thing that had escaped me, was both the measure tool and area tool were returning incorrect results. The distance as-the-crow flies between Dublin and Cork is 219 kilometres (136.08 miles in old money) <a href='http://geographika.co.uk/watch-out-for-openlayer-distances'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/04/image25.png"><img style="margin: 5px 5px 5px 0px; display: inline; border-width: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/04/image_thumb.png" border="0" alt="image" width="204" height="222" align="left" /></a>I had the fortune on my most recent project, a <a href="http://mapfish.org/" target="_blank">MapFish</a> mapping system, of having someone else do some thorough testing. One thing that had escaped me, was both the measure tool and area tool were returning incorrect results.</p>
<p style="text-align: justify;">The distance as-the-crow flies between Dublin and Cork is 219 kilometres (136.08 miles in old money) wheras my tool was returning 357km. Having never driven this route it didn’t set off any alarm bells. Its also not the sort of function I’d unit test, &#8211; one as its in JavaScript, and two as the sample code seemed to work “out-of the box.”</p>
<p style="text-align: justify;">It turns out measurements are planar by default, as briefly referred to in the <a href="http://dev.openlayers.org/apidocs/files/OpenLayers/Control/ScaleLine-js.html#OpenLayers.Control.ScaleLine.geodesic" target="_blank">OpenLayers API docs</a> (although not on the actual measure tools pages..), and there is a <span style="text-decoration: underline;">geodesic</span> parameter. By default this is set to false, so in a Mercator projected map (so anything using Google, Bing, or <a href="http://www.openstreetmap.org/" target="_blank">OpenStreetMap</a> background mapping) measurement tools will be wrong. Maybe something to check if you’ve created a system &#8211; I’ve been 6 months working with OpenLayers and somehow managed to miss this one. <span id="more-494"></span><a href="mailto:Isaac@MSDN" target="_blank">Isaac@MSDN</a> describes Geodesic as follows:<a href="http://geographika.co.uk/wp-content/uploads/2010/04/image26.png"><img style="margin: 5px 0px 5px 5px; display: inline; border-width: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/04/image_thumb1.png" border="0" alt="image" width="105" height="105" align="right" /></a></p>
<p style="text-align: justify;"><em>“Geodesic is a fancy (and concise) way of saying a locally path-minimizing curve.  This, in turn, is just a fancy (and mathematical) way of saying that a taught string on a surface between two points will fall into such a path.”</em></p>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/04/image27.png"><img style="margin: 5px 5px 5px 0px; display: inline; border-width: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/04/image_thumb2.png" border="0" alt="image" width="204" height="222" align="left" /></a> In fairness the <a href="http://openlayers.org/dev/examples/measure.html" target="_blank">OpenLayers Measurement demo</a> makes this clear:</p>
<p style="text-align: justify;"><em>Note that the geometries drawn are planar geometries and the metrics returned by the measure control are planar measures by default. </em></p>
<p style="text-align: justify;"><em>If your map is in a geographic projection or you have the appropriate projection definitions to transform your geometries into geographic coordinates, you can set the &#8220;geodesic&#8221; property of the control to true to calculate geodesic measures instead of planar measures.</em></p>
<p style="text-align: justify;">To set the geodesic option use code similar to the example and pass in the geodesic parameter:</p>
<pre style="text-align: justify;">measureControls = {line: new OpenLayers.Control.Measure(OpenLayers.Handler.Path,
{persist: true, geodesic: true})</pre>
<p style="text-align: justify;">OpenLayers is not alone in this. From the <a href="http://code.google.com/apis/maps/documentation/overlays.html#Great_Circles" target="_blank">Google Maps API docs</a>:</p>
<p style="text-align: justify;"><em>Polylines represented on the map are straight lines conforming to the current projection. That is, they appear straight on the map, but may in fact not properly account for the curvature of the earth. </em></p>
<p style="text-align: justify;"><em>If you instead wish to draw a geodesic (a segment of a &#8220;great circle&#8221; representing the shortest distance between two points on the surface of the earth), you will need to pass <code>geodesic:true</code> in the <code>GPolylineOptions</code> argument of the <code>GPolyline</code>. </em></p>
<p style="text-align: justify;"><em> </em></p>
<p style="text-align: justify;">Again code can be found in the docs, and a geodesic parameter must be set to true:</p>
<pre style="text-align: justify;">var polyOptions = {geodesic:true};
var polyline = new GPolyline([
  new GLatLng(40.65642, -73.7883),
  new GLatLng(61.1699849, -149.944496)
  ], "#ff0000", 10, 1, polyOptions);
  map.addOverlay(polyline);
</pre>
<p style="text-align: justify;">I&#8217;m not sure if Bing Maps has geodesic properties. <a href="http://www.beginningspatial.com/plotting_geography_linestrings_google_maps_and_virtual_earth" target="_blank">This post</a> from Beginning Spatial has a solution for drawing geodesic lines in Bing&#8217;s forerunner Virtual Earth. There are also discussions on geodesic measurements on <a href="http://social.msdn.microsoft.com/Forums/en-US/vemapcontroldev/thread/e275f3ee-f83e-4b92-980a-6d18b20acb9a">this MSDN messageboard</a>.</p>
<p style="text-align: justify;">Finally in OpenLayers, if you are using the <a href="http://trac.openlayers.org/wiki/Addins/ScaleBar" target="_blank">ScaleBar</a> and Spherical Mercator maps then check these recent changes from <a href="http://trac.openlayers.org/changeset/10110" target="_blank">March 2010</a>.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/WMWnXgkl0eQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/watch-out-for-openlayer-distances/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/watch-out-for-openlayer-distances?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=watch-out-for-openlayer-distances</feedburner:origLink></item>
		<item>
		<title>Compiling a 64 bit Version of PyISAPIe</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/L3HusQw79Ko/compiling-a-64-bit-version-of-pyisapie</link>
		<comments>http://geographika.co.uk/compiling-a-64-bit-version-of-pyisapie#comments</comments>
		<pubDate>Fri, 16 Apr 2010 09:55:47 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[64bit]]></category>
		<category><![CDATA[iis]]></category>
		<category><![CDATA[IIS7]]></category>
		<category><![CDATA[msi]]></category>
		<category><![CDATA[PyISAPIe]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=473</guid>
		<description><![CDATA[Welcome to a veritable novella. I’ll jump straight to the end – there is no happy outcome, as yet, to this post there is a happy outcome! I have compiled a 64 bit PyISAPIe DLL (a program that runs Python at high speed under IIS), and it is up and running on Windows Server 2008 <a href='http://geographika.co.uk/compiling-a-64-bit-version-of-pyisapie'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><img style="margin: 0px; display: inline; border-width: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/04/image7.png" border="0" alt="image" width="166" height="156" align="left" /> Welcome to a veritable novella. I’ll jump straight to the end – <span style="text-decoration: line-through;">there is no happy outcome, as yet, to this post</span> there is a happy outcome! I have compiled a 64 bit <a href="http://sourceforge.net/apps/trac/pyisapie" target="_blank">PyISAPIe</a> DLL (a program that runs Python at high speed under IIS), and it is up and running on Windows Server 2008 and IIS7. Many thanks to Phillip Stabon, the creator of PyISAPIe, for additional help, and for the latest version of PyISAPIe which makes compilation for different set ups much easier.</p>
<p style="text-align: justify;">Some background information &#8211; I’ve not done any C++ for 10 years (and even then my most advanced program was to finish off a code sample on a hotel register for pirates – of the traditional kind). Also I’ve never used Subversion. Hence there are lots of pictures, and every step is detailed. If there&#8217;s anything missing let me know.</p>
<p style="text-align: justify;">I’m not sure why I started doing this – the performance of Python using 32-bit version is fine, and since I started working on this Phillip Stabon, has mentioned <a href="http://sourceforge.net/apps/trac/pyisapie" target="_blank">he will be making a 64 bit DLL himself</a>. However as there are many different versions of Python around, and different GIS tools rely on different versions it seemed a good idea to document how to do this from scratch.</p>
<p style="text-align: justify;">In this example I’m using Visual Studio 2008, and a number of other tools that are detailed as I go along. I’ve also got the <a href="http://geographika.co.uk/?p=457" target="_blank">64 bit compilation tools installed</a>. There are a few notes from Phillip on compiling it for Windows 64-bit in the <a href="http://groups.google.com/group/pyisapie/browse_thread/thread/b541331333bcfef8/54e82b58562b7268?hl=en&amp;lnk=gst&amp;q=64+bit#54e82b58562b7268">discussion lists</a> (see quoted text underneath the post). Since this post was first published there is a <a href="http://groups.google.com/group/pyisapie/browse_thread/thread/ca3dfbf8f1d5e349?hl=en" target="_blank">newer discussion in the forums</a>.</p>
<p style="text-align: justify;">Anyway “How to Compile PyISAPIe for a 64-bit Server in 5 Easy Steps!”…</p>
<h3 style="text-align: justify;"><span id="more-473"></span>1. Get 64-bit Python</h3>
<p style="text-align: justify;">You’ll need a 64 bit version of Python. All my scripts were running and developed using Python 2.5.4 so I wanted to compile PyISAPIe to work with this.</p>
<p style="text-align: justify;">The Python downloads <a href="http://www.python.org/download/releases/2.5.4/" target="_blank">are here</a>. I initially thought that as my server has an Intel processor I should use the version for Win64-Itanium users. However it appears Itanium is only used on some very high spec servers, and I should actually use the <a href="http://www.python.org/ftp/python/2.5.4/python-2.5.4.amd64.msi">python-2.5.4.amd64.msi</a> file. To quote the <a href="http://www.python.org/download/" target="_blank">Python site</a>:</p>
<p style="text-align: justify;"><em>The binaries for AMD64 will also work on processors that implement the Intel 64 architecture (formerly EM64T), i.e. the architecture that Microsoft calls x64, and AMD called x86-64 before calling it AMD64. They will not work on Intel Itanium Processors (formerly IA-64). </em></p>
<p style="text-align: justify;">If you are using the Itanium Python version on a x64 machine you’ll likely end up with the following error during compilation:</p>
<p style="text-align: justify;"><em>Error    10    fatal error LNK1112: module machine type &#8216;IA64&#8242; conflicts with target machine type &#8216;x64&#8242;    python25.lib<br />
</em></p>
<p style="text-align: justify;">The Python files are downloaded in a MSI (Microsoft Installer) file, and as I’m developing on a 32-bit laptop (to install on a 64-bit server later) I couldn’t install Python to access the files.</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border-width: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/04/image8.png" border="0" alt="image" width="250" height="99" /></p>
<p style="text-align: justify;">To workaround this I found a useful program called <a href="http://blogs.pingpoet.com/overflow/archive/2005/11/16/14995.aspx" target="_blank">Les MSIérables</a>. This extracts the files contained in an MSI without needing to install anything. I Had to click a few times around the interface before the extract button worked, but then I had a shiny new copy of the 64-bit Python files ready on my machine.</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border-width: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/04/image10.png" border="0" alt="image" width="450" height="225" /></p>
<h3 style="text-align: justify;">2. Get the PyISAPIe Source</h3>
<p style="text-align: justify;">I originally downloaded a zip of the latest PyISAPIe source code. However this is not the way to do things.. The build has an automated step which checks something in Subversion (or SVN &#8211; an online source control system), so the source code you compile needs to be a check-out. If you don’t do this you’ll get errors later on such as:</p>
<pre style="text-align: justify;">Error 2 fatal error C1083: Cannot open include file: 'Revision.h': No such file or directory</pre>
<p style="text-align: justify;">To connect to SubVersion I’d recommend downloading <a href="http://tortoisesvn.net/downloads" target="_blank">TortoiseSVN</a> (in fact as one of its .exe tools is used in a pre-build step later on – its a requirement). This adds a context menu to Windows Explorer that allows you to connect to SVN and get the latest code. Set up a new folder in Explorer, then right click and select SVN Checkout.<img style="margin: 0px auto; display: block; float: none; border-width: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/04/image11.png" border="0" alt="image" width="162" height="37" /></p>
<p style="text-align: justify;">The URL of the repository for the latest PyISAPIe code is <a title="http://pyisapie.svn.sourceforge.net/svnroot/pyisapie/Trunk/" href="http://pyisapie.svn.sourceforge.net/svnroot/pyisapie/Trunk/">http://pyisapie.svn.sourceforge.net/svnroot/pyisapie/Trunk/</a>. Entering this URL and Clicking OK should start downloading the latest source files via the magic of the Internet.</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border-width: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/04/image12.png" border="0" alt="image" width="302" height="232" /></p>
<h3 style="text-align: justify;">3. Configure the Visual Studio Project</h3>
<p style="text-align: justify;">Once the source code has downloaded you should be able to open up the PyISAPIe.sln file which references the PyISAPIe.vcproj C++ project file. This is set up to compile the 32-bit version by default. You’ll want to change this using Build &gt;&gt; Configuration Manager &gt;&gt; x64. If this is the first time you are compiling a 64-bit DLL you’ll need to create a “New Solution Platform” as shown below:</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border-width: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/04/image13.png" border="0" alt="image" width="193" height="125" /></p>
<p style="text-align: justify;">If you try to compile now you may get the following error:</p>
<pre style="text-align: justify;">Error 2 fatal error C1189: #error :  Please define PYI_PY_VERSION at the project level.</pre>
<p style="text-align: justify;">We need to tell the compiler the appropriate Python version to use. This can be set by going to Project &gt;&gt; Properties &gt;&gt;  Configuration Properties &gt;&gt; C/C++ &gt;&gt; Preprocessor. If these options seem to be missing then make sure the project itself is selected in the Solution Explorer when clicking on Properties.</p>
<p style="text-align: justify;">I’m using 2.5.4 so I set this value to be PY_25_4 (a list of valid codes can be seen in PyISAPIe.h from line 25 onwards). Also change the WIN32 variable to WIN64.</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/04/image20.png" border="0" alt="image" width="240" height="208" /></p>
<p style="text-align: justify;">Another compile, another error (again apparently fatal):</p>
<pre style="text-align: justify;"><em>fatal error C1083: Cannot open include file: 'Python25/include/Python.h': No such file or directory</em></pre>
<p style="text-align: justify;">Looking at line 84 in PyISAPIe.h you can see the header file wants to include the Python files:</p>
<pre style="text-align: justify;">#define PYI_PY_VERSION_MAJOR PY_25
#include &lt;Python25/include/Python.h&gt;
#include &lt;Python25/include/structmember.h&gt;
#include &lt;Python25/include/frameobject.h&gt;</pre>
<p style="text-align: justify;">To allow these files to be correctly referenced I copied the entire Python25 folder (see step 1) into a new Python\x64 folder. The folder structure should now look something like this:</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/04/image21.png" border="0" alt="image" width="142" height="113" /></p>
<p style="text-align: justify;">The project is set up to look for the Python files in the Python\x64 folder (for 64 bit release builds) by default. This setting can be seen in the “Additional Include Directories” shown below. The same project can be used with different versions of Python by adding folders such as Python\x64\Python26 and changing the project environment variables.</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/04/image22.png" border="0" alt="image" width="413" height="92" /></p>
<h3 style="text-align: justify;">4. Making the Pre-build Step</h3>
<p style="text-align: justify;">In the original project file there is a pre-build step that checks something in SubVersion (its description is “Subversion Revision Scan”). It can be seen at Project &gt;&gt; Properties &gt;&gt; Configuration Properties &gt;&gt; Build Events &gt;&gt; Pre-Build Event:</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/04/image23.png" border="0" alt="image" width="458" height="74" /></p>
<p style="text-align: justify;">It runs the following command from the (Windows not Visual Studio) command line:</p>
<pre style="text-align: justify;">subwcrev . PyISAPIe\Revision.in PyISAPIe\Revision.h</pre>
<p style="text-align: justify;">Fortunately the command line tool <a href="http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-subwcrev.html" target="_blank">SubWCRev</a> is downloaded as part of <a href="http://tortoisesvn.net/downloads" target="_blank">TortoiseSVN</a>. If you don’t have the prebuild step set up correctly then you may receive the following errors:</p>
<pre style="text-align: justify;"><em>error PRJ0019: A tool returned an error code from "Subversion Revision Scan"</em><em> </em></pre>
<p style="text-align: justify;">The syntax for this command is:</p>
<pre style="text-align: justify;">SubWCRev WorkingCopyPath [SrcVersionFile DstVersionFile] [-nmdfe]</pre>
<p style="text-align: justify;">Where <code>WorkingCopyPath</code> is the path to the working copy being checked. If you aren’t using a copy of the sourcecode from SVN then you will receive errors such as “<em>SubWCRev : &#8216;D:\PyISAPie’ is not a working copy.”</em> If you have only just installed TortoiseSVN then make sure you log off or restart Windows so that your <a href="http://geographika.co.uk/?p=428" target="_blank">environment variables are updated</a>.</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/04/image24.png" border="0" alt="image" width="225" height="91" /></p>
<p style="text-align: justify;">The prebuild step should work “out of the box”, however if you still get errors in Visual Studio then running the following commands (pointing to your project folders) from a Windows Shell may provide more useful debugging information.</p>
<pre>cd D:\PyISAPIe\PyISAPIe
subwcrev \ Revision.in Revision.h</pre>
<p style="text-align: justify;">All that is actually required by this pre-build step is to generate a Revision.h file of 5 lines..</p>
<h3 style="text-align: justify;">5. Compile!</h3>
<p style="text-align: justify;">Another attempt at compiling and I get:</p>
<pre style="text-align: justify;"><em>Error 14 fatal error LNK1104: cannot open file 'python25_d.lib'</em></pre>
<p style="text-align: justify;">From <a href="http://www.panda3d.org/phpbb2/viewtopic.php?t=4970" target="_blank">this post</a> I read <em>&#8220;python25_d.dll is the debug version. If you want to compile against python25.dll instead, you need to build a Release build of your application, not a Debug build. Or, you can go to python.org and download the debug python25_d.lib and python25_d.dll.&#8221;</em></p>
<p style="text-align: justify;">I changed my build to Release and on the next compile…it worked! And look I have proof..</p>
<h3 style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border-width: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/04/image19.png" border="0" alt="image" width="496" height="92" /></h3>
<h3 style="text-align: justify;">Aftermath</h3>
<p style="text-align: justify;">I then set up the PyISAPIe.DLL on IIS7 (using the <a href="http://geographika.co.uk/setting-up-python-on-iis7" target="_blank">same process as I detailed here</a>), but using my newly compiled 64-bit, and using the DefaultAppPool which should run 64 bit applications. I also installed the Python 2.5.4 for 64-bit AMD processors (the same MSI as detailed above).</p>
<p style="text-align: justify;"><span style="text-decoration: line-through;">Unfortunately I currently get HTTP 404.4 errors, with nothing in the logs of use to help diagnose further. I suspect the references to WIN32 may be the issue, but I’ve no idea what to change them to. I’m posting to the PyISAPIe forum with the hope of trying to get this working, and hope that this is not the final revision of this post.</span></p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/L3HusQw79Ko" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/compiling-a-64-bit-version-of-pyisapie/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/compiling-a-64-bit-version-of-pyisapie?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=compiling-a-64-bit-version-of-pyisapie</feedburner:origLink></item>
		<item>
		<title>Setting up Visual Studio 2008 for Compiling 64-bit DLLs</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/o31fPanZQ9E/setting-up-visual-studio-2008-for-compiling-64-bit-dlls</link>
		<comments>http://geographika.co.uk/setting-up-visual-studio-2008-for-compiling-64-bit-dlls#comments</comments>
		<pubDate>Fri, 16 Apr 2010 08:17:59 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[bugs]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[64bit]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[compiling]]></category>
		<category><![CDATA[service pack]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=457</guid>
		<description><![CDATA[This step should be simple. Run the Visual Studio 2008 SetUp program and check the “X64 Compilers and Tools” option under Visual C++ However firstly don’t run the set up program from the DVD or from an ISO on your hard-disk or you&#8217;ll end up with the following error: &#8216;A problem has been encountered while <a href='http://geographika.co.uk/setting-up-visual-studio-2008-for-compiling-64-bit-dlls'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">This step should be simple. Run the Visual Studio 2008 SetUp program and check the “X64 Compilers and Tools” option under Visual C++</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image5" src="http://geographika.co.uk/wp-content/uploads/2010/04/image51.png" border="0" alt="image5" width="212" height="98" /></p>
<p style="text-align: justify;"><span id="more-457"></span>However firstly don’t run the set up program from the DVD or from an ISO on your hard-disk or you&#8217;ll end up with the following error:</p>
<p style="text-align: center;"><em>&#8216;A problem has been encountered while loading the setup components. Canceling setup&#8217;</em></p>
<p style="text-align: justify;">You need to run the Visual Studio set up through Add/Remove Programs. However once I’d selected the components I got the error below &#8211; <em>“A selected drive is no longer valid. Please review your installation path settings before continuing with setup.” </em>Of course <strong><em>there is no</em> </strong><em><strong>option</strong> </em>to review or even see your drive settings…</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image9" src="http://geographika.co.uk/wp-content/uploads/2010/04/image9.png" border="0" alt="image9" width="384" height="76" /></p>
<p style="text-align: justify;">Thanks to <a href="http://social.msdn.microsoft.com/Forums/en-US/vssetup/thread/2f3d0378-3175-49ae-acb7-012594a1bf3c" target="_blank">this thread</a>, the solution was to uninstall Visual Studio SP1 through Add/Remove programs (check the “Show Updates” box to see service packs and hot fixes for various programs).</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image14" src="http://geographika.co.uk/wp-content/uploads/2010/04/image14.png" border="0" alt="image14" width="294" height="88" /></p>
<p style="text-align: justify;">Finally I got the 64-bit compilers installed, and could begin trying to compile <a href="http://sourceforge.net/apps/trac/pyisapie" target="_blank">PyISAPIe</a> for a 64-bit processor which is a whole different set of problems.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/o31fPanZQ9E" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/setting-up-visual-studio-2008-for-compiling-64-bit-dlls/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/setting-up-visual-studio-2008-for-compiling-64-bit-dlls?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=setting-up-visual-studio-2008-for-compiling-64-bit-dlls</feedburner:origLink></item>
		<item>
		<title>Logging OpenLayers with Firebug</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/K95fA-ejhuo/logging-openlayers-with-firebug</link>
		<comments>http://geographika.co.uk/logging-openlayers-with-firebug#comments</comments>
		<pubDate>Tue, 13 Apr 2010 18:07:22 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[bugs]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[firebug]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[logging]]></category>
		<category><![CDATA[openlayers]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=445</guid>
		<description><![CDATA[I take it as given that anyone developing with Firefox and OpenLayers has Firebug installed. Firebug has a number of powerful tools that can make the previous nightmare of JavaScript debugging tolerable. One feature I recently “discovered” are the logging options. It&#8217;s definitely a timesaver over my previous method of putting temporary alert(vals); throughout my <a href='http://geographika.co.uk/logging-openlayers-with-firebug'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a title="http://code.google.com/p/fbug/source/browse/branches/firebug1.6/lite/firebugx.js" href="http://code.google.com/p/fbug/source/browse/branches/firebug1.6/lite/firebugx.js"><img style="margin: 0px; display: inline; border-width: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/04/image5.png" border="0" alt="image" width="140" height="107" align="left" /></a>I take it as given that anyone developing with Firefox and <a href="http://openlayers.org/" target="_blank">OpenLayers</a> has <a href="http://getfirebug.com/" target="_blank">Firebug</a> installed. Firebug has a number of powerful tools that can make the previous nightmare of JavaScript debugging tolerable.</p>
<p style="text-align: justify;">One feature I recently “discovered” are the logging options. It&#8217;s definitely a timesaver over my previous method of putting temporary alert(vals); throughout my code. As well as debugging the logging is very useful for <a href="../category/documentation" target="_blank">automatically  documenting</a> formulae in JavaScript with worked examples that can  then be pasted straight into the documentation.</p>
<p style="text-align: justify;">An example of the logging capabilities can be seen on my sample <a href="http://geographika.co.uk/samples/ol_debug.html" target="_blank">OpenLayers page</a>. If you already have Firebug installed you should be able to see the output similar to that below when the page loads.</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border-width: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/04/image6.png" border="0" alt="image" width="275" height="149" /></p>
<h3 style="text-align: justify;"><span id="more-445"></span>Console.log</h3>
<p style="text-align: justify;">The full range of options for logging can be seen in the Firebug <a href="http://getfirebug.com/wiki/index.php/Console_API" target="_blank">Console API wiki page</a>. The <a href="http://geographika.co.uk/samples/ol_debug.html" target="_blank">sample page</a> has a few different logging options briefly explained below.</p>
<p style="text-align: justify;">To list all properties and functions for the <a href="http://dev.openlayers.org/apidocs/files/OpenLayers/Layer-js.html" target="_blank">layer object</a> simply add:</p>
<pre style="text-align: justify;">console.dir(layer);</pre>
<p style="text-align: justify;">To list only an objects properties (without all its associated functions), use a construct similar to:</p>
<pre style="text-align: justify;">//an alternative to just list properties
var prop;
for (prop in layer) {
    if (typeof layer[prop] !== 'function') {
        console.log('%s : %s', prop, layer[prop]); //log values to Firebug
    }
}</pre>
<p style="text-align: justify;">This example below prints details about the <a href="http://dev.openlayers.org/apidocs/files/OpenLayers/Map-js.html" target="_blank">map object</a>. Handily Firebug adds a hyperlink in the output to the line where  console.info is called. String substitutions can be used (e.g. replace %s with a string, or %i with an integer) for easier formatting.</p>
<pre style="text-align: justify;">// write out some info
console.info("The map projection is %s and has %i layers", map.projection, map.layers.length);
console.info('Layer Name: \'%s\'', layer.name);</pre>
<p style="text-align: justify;">Assertions can be placed in code as follows:</p>
<pre style="text-align: justify;">// make an assertion
console.assert(map.layers.length === 1);</pre>
<p style="text-align: justify;">I was taught to use the <a href="http://en.wikipedia.org/wiki/Assertion_%28computing%29" target="_blank">assert statement</a> as often as possible in code. Its amazing (and disconcerting) how many times “impossible” situations can occur. Whilst assertions are normally removed from production code for desktop applications, a JavaScript error message may prove invaluable when trying to debug a user’s problem remotely. As with everything in programming its a personal choice whether or not to use assertions – some people clearly <a href="http://stackoverflow.com/questions/1854302/is-assert-evil" target="_blank">assertions are evil</a>.</p>
<p style="text-align: justify;">The console API also supports timers, and writing out the call stack at points in your application for when things start getting more complicated.</p>
<h3 style="text-align: justify;">Miscellaneous</h3>
<ul>
<li><a href="http://code.google.com/p/fbug/source/browse/branches/firebug1.6/lite/firebugx.js" target="_blank">This function</a> makes sure that no JavaScript errors are thrown for browsers without Firebug installed. It is included in the sample.</li>
<li>Sometimes you may have to restart your browser, or make sure there is only one instance of Firefox is running for the logging messages to appear.</li>
<li>Internet Explorer 8 has similar development tools that can be downloaded from the <a href="http://msdn.microsoft.com/en-us/library/dd565628%28VS.85%29.aspx" target="_blank">Microsoft site</a>. It appears to support similar <a href="http://msdn.microsoft.com/en-us/library/dd565625%28v=VS.85%29.aspx" target="_blank">logging functions</a> as Firebug, but I’ve not gone into these in any depth.</li>
</ul>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/K95fA-ejhuo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/logging-openlayers-with-firebug/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/logging-openlayers-with-firebug?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=logging-openlayers-with-firebug</feedburner:origLink></item>
		<item>
		<title>Automated Diagrams and Documentation</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/vt59OnL97Zo/automated-diagrams-and-documentation</link>
		<comments>http://geographika.co.uk/automated-diagrams-and-documentation#comments</comments>
		<pubDate>Fri, 09 Apr 2010 13:07:52 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[documentation]]></category>
		<category><![CDATA[general]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[diagrams]]></category>
		<category><![CDATA[shapely]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=438</guid>
		<description><![CDATA[As I previously wrote, one of the ways to get through the task of documenting a project is to turn the documentation process into a coding project. Documentation sometimes seems pointless as the likelihood of anyone other than yourself reading it are low to nil. To increase the chances pretty pictures always help. If they <a href='http://geographika.co.uk/automated-diagrams-and-documentation'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">As I <a href="http://geographika.co.uk/task-13-user-documentation" target="_blank">previously wrote</a>, one of the ways to get through the task of documenting a project is to turn the documentation process into a coding project. Documentation sometimes seems pointless as the likelihood of anyone other than yourself reading it are low to nil.</p>
<p style="text-align: justify;">To increase the chances pretty pictures always help. If they are also useful then the documentation starts to have real value. Up until now I’ve been using Microsoft’s Visio, but recently I tried out a couple of online tools.</p>
<h3>Class Diagrams</h3>
<p style="text-align: justify;">The MapServer <a href="http://mapserver.org/mapscript/mapscript.html" target="_blank">Mapscript documentation</a> currently uses of diagrams made from ASCII text to illustrate relationships between classes. I’m not sure if these were generated automatically, but the images now appear a little dated. They do  however have the advantage over an image of being able to copy and paste class names.</p>
<pre style="text-align: center;">+-------+ 0..*     1 +-------+
| Class | &lt;--------&gt; | Layer |
+-------+            +-------+</pre>
<p style="text-align: justify;">I tried to recreate these diagrams using the online service <a title="http://yuml.me/" href="http://yuml.me/">http://yuml.me/</a>. On the site you enter your model description using a fairly basic syntax. From then on the same diagram can be accessed using different URLs, which are used to control display and formatting options.</p>
<p><img style="display: block; float: none; margin-left: auto; margin-right: auto;" src="http://yuml.me/diagram/scruffy;dir:lr/class/%5BHashtable%5D1..1-%3E1%5BClass%7Bbg:yellow%7D%5D,%5BLabel%20%5D0..1-%3E1%5BClass%5D,%20%5BStyle%5D0..*-%3E1%5BClass%5D,%5BClass%5D0..*-%3E1%5BLayer%7Bbg:green%7D%5D" alt="http://yuml.me/diagram/scruffy;dir:lr/class/%5BHashtable%5D1..1-%3E1%5BClass%7Bbg:yellow%7D%5D,%5BLabel%20%5D0..1-%3E1%5BClass%5D,%20%5BStyle%5D0..*-%3E1%5BClass%5D,%5BClass%5D0..*-%3E1%5BLayer%7Bbg:green%7D%5D" width="401" height="180" /></p>
<p>The diagram above was created using the syntax below. You can play around with this sample by <a href="http://yuml.me/diagram/scruffy/class/edit/%5Bnote:%20Mapscript%20Classes%20from%20the%20SWIG%20MapScript%20API%20Reference%7Bbg:cornsilk%7D%5D,%5BHashtable%5D1..1-%3E1%5BClass%7Bbg:yellow%7D%5D,%5BLabel%20%5D0..1-%3E1%5BClass%5D,%20%5BStyle%5D0..*-%3E1%5BClass%5D,%5BClass%5D0..*-%3E1%5BLayer%7Bbg:green%7D%5D" target="_blank">clicking here</a>.</p>
<pre style="text-align: left;">[Hashtable]1..1-&gt;1[Class{bg:yellow}],
[Label ]0..1-&gt;1[Class],
[Style]0..*-&gt;1[Class],
[Class]0..*-&gt;1[Layer{bg:green}]</pre>
<p><span id="more-438"></span></p>
<p style="text-align: justify;"><img style="margin: 0px; display: inline;" src="http://yuml.me/diagram/scruffy/class/%5BClass%7Ckeyimage%20string;label%20labelObj;layer%20layerObj;maxscale%20float;metadata%20hashTableObj;minscale%20float;name%20string;numstyles%20int;status%20int;template%20string;title%20string;type%20int;debug%20int;%5D" alt="" width="193" height="274" align="right" /><a href="http://yuml.me/diagram/scruffy/class/[Class|keyimage string;label labelObj;layer layerObj;maxscale float;metadata hashTableObj;minscale float;name string;numstyles int;status int;template string;title string;type int;debug int;]" target="_blank">The class diagram</a> on the left shows the properties of the <a href="http://mapserver.org/mapscript/mapscript.html#classobj" target="_blank">MapServer Class object</a>. Anyone can add <a href="http://yuml.me/diagram/edit/scruffy/class/[Class|keyimage string;label labelObj;layer layerObj;maxscale float;metadata hashTableObj;minscale float;name string;numstyles int;status int;template string;title string;type int;debug int;]" target="_blank">/edit/</a> to the URL path to make a new diagram based on this. A “clean” format of the diagram can be seen <a href="http://yuml.me/7967b1d6" target="_blank">here</a>.</p>
<p style="text-align: justify;"><a title="http://yuml.me/" href="http://yuml.me/">http://yuml.me/</a> has plenty of samples, but I couldn’t find full documentation on all the available syntax. As this is an online service you can never be sure when, or if, they might start charging. They do offer a download including sourcecode ($50 for a single user) to install locally so you can avoid paying a per diagram charge.</p>
<p style="text-align: justify;">In response to the accusations that <a href="http://en.wikipedia.org/wiki/Unified_Modeling_Language" target="_blank">UML</a> is evil <a title="http://yuml.me/" href="http://yuml.me/">http://yuml.me/</a> responds:</p>
<blockquote style="text-align: justify;"><p><em>UML is evil when you use it too much for your given project; it&#8217;s easy to burn hours and hours doing UML stuff when you could be writing code or doing something more useful. Some projects use a lot of UML and that really helps them.</em></p></blockquote>
<h3 style="text-align: justify;">Sequence Diagrams</h3>
<p style="text-align: justify;">Next I wanted to make a simple to show the interaction between various parts of a MapServer and TileCache system I’ve been working on. For this I needed to create a <a href="http://en.wikipedia.org/wiki/Sequence_diagram" target="_blank">sequence diagram</a> that <em>“shows how processes operate with one another and in what order.”</em></p>
<p style="text-align: justify;"><a href="http://www.amazon.com/gp/product/0521540186?ie=UTF8&amp;tag=geographika-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0521540186" target="_blank">Scott Ambler</a> at <a href="http://www.agilemodeling.com/artifacts/sequenceDiagram.htm" target="_blank">Agile Modelling</a> thoughts on these diagrams are:</p>
<blockquote style="text-align: justify;"><p><em>My advice is to only create a sequence diagram when you have complex logic that you want to think through – if the logic is straightforward the sequence diagram won’t add any value, you had might as well go straight to code.&#8221;</em></p></blockquote>
<p style="text-align: justify;">Whether or not my example fits into that category I&#8217;m not sure &#8211; this example was principally to test a different service. This time used I used the online service at <a title="http://www.websequencediagrams.com" href="http://www.websequencediagrams.com">http://www.websequencediagrams.com</a>. The whole diagram generation process can be automated using Python &#8211; the script used to generate the diagram below can be <a href="http://geographika.co.uk/downloads/diagram.py" target="_blank">downloaded here</a>. Again by changing parameters in the URL you can change the “scruffy” appearance to a more clean style depending on the diagrams audience for example a more formal version could be included in a bug report, and a more colourful version in a user wiki.</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border-width: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/04/image3.png" border="0" alt="image" width="258" height="183" /></p>
<h3 style="text-align: justify;"><a href="http://pypi.python.org/pypi/Shapely" target="_blank">Shapely</a></h3>
<p style="text-align: justify;"><a href="http://gispython.org/shapely-1.2/manual/manual.html#simplification"><img style="margin: 0px 5px 0px 0px; display: inline; border-width: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/04/image4.png" border="0" alt="image" width="192" height="134" align="left" /></a></p>
<p style="text-align: justify;"><a href="http://sgillies.net/blog/1015/shapely-1-2b5" target="_blank">Sean Gillies</a> has just finished documenting the Shapely a “Python package for manipulation and analysis of planar geometries.”</p>
<p style="text-align: justify;">The first impression you get is that it&#8217;s attractive. The images of geometry (generated by the Python package <a href="http://pypi.python.org/pypi/descartes/" target="_blank">descartes</a>) catch the eye, and it was these images as much as anything else that led me to trying Shapely in the first place.</p>
<p style="text-align: justify;">The documentation also has plenty of code samples – which as any developer knows is by far the easiest way to start using a new library or framework. If you can combine writing code samples with generating nice diagrams for a user manual then no wonder he is:</p>
<blockquote style="text-align: justify;"><p><a href="http://twitter.com/sgillies/status/11481274612" target="_blank">Enjoy(ing) writing some documentation. Crazy, I know.</a></p></blockquote>
<p style="text-align: justify;">Hit F5 and let the computer do the work.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/vt59OnL97Zo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/automated-diagrams-and-documentation/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/automated-diagrams-and-documentation?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=automated-diagrams-and-documentation</feedburner:origLink></item>
		<item>
		<title>Reboot to Refresh Environment Variables</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/EnXbo_Z9WHA/reboot-to-refresh-environment-variables</link>
		<comments>http://geographika.co.uk/reboot-to-refresh-environment-variables#comments</comments>
		<pubDate>Tue, 06 Apr 2010 08:00:41 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[environment variables]]></category>
		<category><![CDATA[idle]]></category>
		<category><![CDATA[iis]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=428</guid>
		<description><![CDATA[I wasn’t aware that if you change Windows environment variables that are used by IIS then you need to reboot the machine for the changes to take effect. As described by David Wong This is because NT services like IIS inherit their environment from services.exe, which does not get updated when you change system environment <a href='http://geographika.co.uk/reboot-to-refresh-environment-variables'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">I wasn’t aware that if you change Windows environment variables that are used by IIS then <span style="text-decoration: underline;"><strong>you need to reboot the machine</strong></span> for the changes to take effect. As described by <a href="http://w3-4u.blogspot.com/2006/12/qa-iis-and-environment-variable-updates.html">David Wong</a></p>
<blockquote style="text-align: justify;"><p><em>This is because NT services like IIS inherit their environment from services.exe, which does not get updated when you change system environment until you reboot.</em></p></blockquote>
<p style="text-align: justify;">This knowledge may save a couple of hours of frustration if you are running Python scripts on IIS through <a href="http://geographika.co.uk/setting-up-python-on-iis7">PyISAPIe</a>.</p>
<p style="text-align: justify;"><span id="more-428"></span></p>
<p style="text-align: justify;"><img style="margin: 0px 5px 0px 0px; display: inline; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/04/image2.png" border="0" alt="image" width="172" height="111" align="left" /></p>
<p style="text-align: justify;">If you add paths to your PYTHONPATH or PATH system variables to use a Python package (such as MapScript or GDAL), then the same script may run without problems in IDLE, but continue to produce errors when run through the web server.</p>
<p style="text-align: justify;">If you are running a script in <a href="http://en.wikipedia.org/wiki/IDLE_%28Python%29">IDLE</a> then you need to restart IDLE itself to refresh the environment variables.</p>
<h3 style="text-align: justify;">Other Options</h3>
<p style="text-align: justify;">I’ve not tried this method myself but <a href="http://www.teachout.com/Blog/tabid/165/EntryId/246/Windows-Environment-Variables-Overrides-for-IIS6.aspx">R. Teachout</a> suggests a registry hack that allows you to override the Windows environment variables in IIS 6.</p>
<p style="text-align: justify;">You can also override the environment variables in the Python scripts themselves. For example to change the GDAL_DRIVER_PATH variable use:</p>
<pre style="text-align: justify;">os.environ[“GDAL_DRIVER_PATH”] = “C:\ms4w\gdalplugins”</pre>
<p style="text-align: justify;">To print out current environment variables (assuming you are testing in IDLE):</p>
<pre>print os.getenv(“GDAL_DRIVER_PATH”)
</pre>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/EnXbo_Z9WHA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/reboot-to-refresh-environment-variables/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/reboot-to-refresh-environment-variables?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=reboot-to-refresh-environment-variables</feedburner:origLink></item>
		<item>
		<title>Masquerades, Geocaching, and Easter Eggs</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/UryOn_3gJX0/masquerades-geocaching-and-easter-eggs</link>
		<comments>http://geographika.co.uk/masquerades-geocaching-and-easter-eggs#comments</comments>
		<pubDate>Fri, 02 Apr 2010 10:10:43 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[opinion]]></category>
		<category><![CDATA[easter eggs]]></category>
		<category><![CDATA[garcia]]></category>
		<category><![CDATA[geocaching]]></category>
		<category><![CDATA[jerry]]></category>
		<category><![CDATA[kitt williams]]></category>
		<category><![CDATA[treasure]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=418</guid>
		<description><![CDATA[Thirty years ago Kitt Williams wrote, or rather painted, the children’s book  Masquerade. Each page had a picture that contained hidden clues pointing to the location of an 18-carat gold, jewel-encrusted hare buried somewhere in Britain. It sparked a National treasure hunt and sold 2 million copies. I remember being fascinated with the pictures and <a href='http://geographika.co.uk/masquerades-geocaching-and-easter-eggs'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://en.wikipedia.org/wiki/Masquerade_%28book%29"><img style="margin: 0px 5px 0px 0px; display: inline; border: 0px;" title="Masquerade" src="http://geographika.co.uk/wp-content/uploads/2010/04/image.png" border="0" alt="Masquerade" width="137" height="180" align="left" /></a>Thirty years ago <a href="http://en.wikipedia.org/wiki/Kit_Williams">Kitt Williams</a> wrote, or rather painted, the children’s book  <a href="http://www.amazon.com/gp/product/080523747X?ie=UTF8&amp;tag=geographika-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=080523747X">Masquerade</a>. Each page had a picture that contained hidden clues pointing to the location of an 18-carat gold, <a href="http://www.guardian.co.uk/artanddesign/2009/aug/20/kit-williams-golden-hare-masquerade">jewel-encrusted hare</a> buried somewhere in Britain. It sparked a National treasure hunt and sold 2 million copies.</p>
<p style="text-align: justify;">I remember being fascinated with the pictures and the theories and solutions bandied about by those older and wiser than I. The majority of programmers seem to have a fondness for puzzles and riddles, and the beauty and success of the book was that it involved transposing clues to maps and real-world locations.</p>
<h3 style="text-align: justify;">Geocaching</h3>
<p style="text-align: justify;">Geocaching could be seen as a successor to Williams’s book.  As someone working in technology and geography it should seemingly be an ideal pastime. However the fact geocaching is a <a href="http://tess2.uspto.gov/bin/showfield?f=doc&amp;state=4010:sfj3s6.2.1">trademarked word</a> owned by a company named <a href="http://www.groundspeak.com/">Groundspeak</a> kills a little of the mystique. Secondly it appears to me to be the equivalent of driving around in the middle of nowhere with a bad in-car GPS trying to find an address that’s missing from the database.</p>
<p style="text-align: justify;"><span id="more-418"></span>I wouldn’t go as far as police Inspector Tyrus Cameron who <a href="http://www.canada.com/ottawacitizen/news/story.html?id=c7628126-a0f6-4a9e-a396-a40fa1948eab">mistook a geocache for a bomb</a> and was quoted as saying:</p>
<blockquote style="text-align: justify;"><p><em>“They can have their fun, but we can’t be responding in this nature, or it’s a huge issue for the citizens of the city.” </em></p></blockquote>
<p style="text-align: justify;">But it does seems to be a mechanical process with little puzzle-solving involved. As I’ve never tried it my opinion clearly counts for little, and I’m open to persuasion.</p>
<h3 style="text-align: justify;">Easter Eggs</h3>
<p style="text-align: justify;">In keeping with the theme of buried secrets and Easter, I’m wondering if the programmer tradition of inserting <a href="http://en.wikipedia.org/wiki/Easter_egg_%28media%29">Easter Eggs</a> into software is now extinct. Microsoft have hidden many <a href="http://content.techrepublic.com.com/2346-10877_11-161976.html">eggs over the years</a>, but now officially ban the practice to calm corporate security concerns. And where Microsoft lead, desktop GIS will undoubtedly follow.</p>
<p style="text-align: justify;">Previously typing <a href="http://www.eggheaven.com/eggs/software/1257-arcmap">Jerry in ArcMap</a> version 8.x would pop up an image of <a href="http://en.wikipedia.org/wiki/Jerry_Garcia">the man himself</a>. This has been “fixed” from version 9.1 on as it seemingly caused <a href="http://forums.esri.com/Thread.asp?c=93&amp;f=982&amp;t=62574">issues for several users</a> while editing.</p>
<p style="text-align: justify;">Google Maps has <a href="http://www.eeggs.com/tree/11263.html">a few Easter Eggs</a>, and this year the <a href="http://maps.google.com.au/">Australian site</a> gave directions and toll information in Aussie dialect for <a href="http://en.wikipedia.org/wiki/April_Fools%27_Day">April Fool’s Day</a> &#8211; “<em>Ya might have to cough up some cash along here.</em>” Due to the nature of web applications, and Google’s now familiar quirky approach, they aren’t as as much of a thrill to find as a mode staid GIS application. <a href="http://www.safe.com/">FME</a> have the <a href="http://geographika.co.uk/baking-donuts">odd one-liner</a> in their geo-processing output, and hopefully there are still a few treasures to be found, and a few treasures to place.</p>
<h3 style="text-align: justify;">Riddle Me This</h3>
<p style="text-align: justify;">
<div class="mceTemp mceIEcenter" style="text-align: justify;">
<dl class="wp-caption aligncenter" style="width: 226px;">
<dt class="wp-caption-dt"><img style="margin: 0px auto; display: block; border: 0pt none;" title="The hare dreamt of parallax scrolling.." src="http://geographika.co.uk/wp-content/uploads/2010/04/image1.png" border="0" alt="The hare dreamt of parallax scrolling.." width="216" height="157" /></dt>
<dd class="wp-caption-dd">Even in 1984 this game only got 3/10</dd>
</dl>
</div>
<p style="text-align: justify;">
<p style="text-align: justify;">On my trip down memory lane I found a <a href="http://www.bunnyears.net/kitwilliams/faq.html">riddle</a>. A copy of <a href="http://www.bunnyears.net/kitwilliams/Hareraiser_All_Spectrum.zip">Hareraiser</a> (and <a href="http://www.worldofspectrum.org/emulators.html">Spectrum emulator</a>) for the answer.</p>
<blockquote style="text-align: justify;"><p><em>There came four men from out the wood</em><em><br />
Their way was straight and their strength was good<br />
Then over a bridge the four men ran<br />
To come together as one man<br />
There came a horse without a bone<br />
That made the four men whine and moan<br />
Wood and men and bridge are all but one<br />
Put them together and you&#8217;ll find my riddle is undone.</em></p></blockquote>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/UryOn_3gJX0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/masquerades-geocaching-and-easter-eggs/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/masquerades-geocaching-and-easter-eggs?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=masquerades-geocaching-and-easter-eggs</feedburner:origLink></item>
		<item>
		<title>Politics, IT, Spending, and GIS</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/Ck-2Z70nHHk/politics-it-spending-and-gis</link>
		<comments>http://geographika.co.uk/politics-it-spending-and-gis#comments</comments>
		<pubDate>Tue, 30 Mar 2010 22:17:44 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[opinion]]></category>
		<category><![CDATA[australia]]></category>
		<category><![CDATA[datalinking]]></category>
		<category><![CDATA[gis]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[politics]]></category>
		<category><![CDATA[spending]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=403</guid>
		<description><![CDATA[With an impending election in the UK, the Conservatives, the current opposition party have decided to try and win some votes by cutting spending in IT. On the upside they plan to scrap ID cards if elected. Which GIS projects this may affect is impossible to tell as: He [the shadow chancellor] was unable to <a href='http://geographika.co.uk/politics-it-spending-and-gis'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://www.amazon.com/gp/product/1411678273?ie=UTF8&amp;tag=geographika-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1411678273"><img style="margin: 0px 5px 0px 0px; display: inline; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/03/image10.png" border="0" alt="image" width="126" height="118" align="left" /></a> With an <a href="http://news.bbc.co.uk/2/hi/uk_news/politics/8496591.stm">impending election</a> in the UK, the Conservatives, the current opposition party have decided to try and win some votes by <a href="http://www.theregister.co.uk/2010/03/29/osborne_it/">cutting spending in IT</a>. On the upside they plan to scrap <a href="http://www.no2id.net/">ID cards</a> if elected. Which GIS projects this may affect is impossible to tell as:</p>
<p style="text-align: justify;"><em>He [the shadow chancellor] was unable to cite specific projects, as opposition parties are not allowed to inspect government contracts.</em></p>
<p style="text-align: justify;">What would be ideal is if IT projects were able to be scrutinised by the opposition parties, <em>and</em> the public. It appears Australia is far more open with their government tenders, and even include the <em><a href="https://www.tenders.gov.au/?keyword=gis&amp;event=public.advancedsearch.keyword&amp;orderBy=Publish+Date&amp;submitSort=Go">actual costs</a></em> involved which would be considered as extremely sensitive business data in other countries.</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/03/image11.png" border="0" alt="image" width="271" height="136" /></p>
<p style="text-align: justify;"><span id="more-403"></span>During the good times IT projects are always associated with savings and efficiencies. During the bad times they now seem to be seen as an extravagance, and <a href="http://www.computing.co.uk/computing/comment/2248138/why-failure-comes-easy-4785962">prone to failure</a>. A good point made in <a href="http://forums.theregister.co.uk/forum/1/2010/03/29/osborne_it/">the comments</a> on <a href="http://www.theregister.co.uk/2010/03/29/osborne_it/">The Register article</a> was:</p>
<blockquote style="text-align: justify;"><p>Personally, I&#8217;d like all large businesses subject to the same auditing and publishing requirements that government IT projects are so we can get some perspective. Starting with the media. I strongly suspect that government projects are no worse than anyone else&#8217;s, but they&#8217;re the only ones open to serious scrutiny.</p></blockquote>
<p style="text-align: justify;">Amongst the projects likely to face cuts is the <a href="http://en.wikipedia.org/wiki/NHS_National_Programme_for_IT">National Programme for IT</a> a National Health Service IT project with  a budget of around £12bn, that was set to be <em>“the world&#8217;s biggest civil information technology programme.&#8221; </em>Whether or not patients are likely to benefit is very much <a href="http://www.telegraph.co.uk/news/uknews/1548813/Patients-wont-benefit-from-12bn-IT-project.html">up for debate</a>. What does seem to be lacking in this plan is the use of GIS and geospatial technologies, apparently due to a <a href="http://www.gisdevelopment.net/magazine/years/2005/jun/service1.htm">lack of expertise</a>. Maybe ESRI should have sent the NHS <a href="http://www.amazon.com/gp/product/187910265X?ie=UTF8&amp;tag=geographika-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=187910265X">their brochure</a>.</p>
<h3 style="text-align: justify;">Send me the Link</h3>
<p style="text-align: justify;">Where the government (or their advisors) may previously have <a href="http://www.epicfail.com/">FAIL</a>ed is their desire for centralised databases and systems. This approach may have recently changed to a more decentralised <a href="http://www.jenitennison.com/blog/node/140">linked data approach</a>.</p>
<blockquote style="text-align: justify;"><p><em>[Linked data] is about using URIs to identify things, providing information at the end of those URIs that is self-descriptive, and linking those things to other things through typed links. </em></p></blockquote>
<p style="text-align: justify;"><img style="margin: 0px 5px 0px 0px; display: inline; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/03/image12.png" border="0" alt="image" width="200" height="151" align="left" /> <a href="http://sgillies.net/blog/987/linking-uk-data/">Sean Gillies</a> seems to think it’s a step in the right direction &#8211; which is always a good thing. Have a look at the <a href="http://data.gov.uk/">new site</a> to judge for yourselves. The use of linked data rather than databases in <a href="http://en.wikipedia.org/wiki/Walled_garden_%28technology%29">walled gardens</a>, allows for all sorts of applications to be created by both the public and private sector such as this <a href="http://ishortman.com/projects/expendituremap/">expenditure map</a> (I’ll forgive the use of Flash just this once..). The amount of mash-ups that can be created is now only limited by the imagination. Notice how maps are high on the <a href="http://data.gov.uk/ideas">list of ideas</a>.</p>
<p style="text-align: justify;">A change that has occurred in the UK that could be seen as on a par with <a href="http://news.bbc.co.uk/2/hi/americas/8579322.stm">Obama’s health reforms</a> is the <a href="http://www.guardian.co.uk/technology/free-our-data">freeing of data</a>. Recently the <a href="http://www.ordnancesurvey.co.uk">Ordnance Survey</a> <a href="http://www.guardian.co.uk/technology/2009/nov/19/ordnance-survey-maps-free-online">released free mapping</a>. This seems to have had a knock on effect with the Post Office <a href="http://data.gov.uk/ideas/post-office-and-os-relax-copyright-and-licences-uk-address-and-coordinate-data">relaxing copyright</a> on postcodes (the zip code equivalent). Although it may have helped that this has been available for download on <a href="http://thepiratebay.org/torrent/5090599/UK_government_database_of_all_1_841_177_post_codes">The Pirate Bay</a> since last September.  [<strong>Clarification</strong> - the Ordnance Surey have released the geographic locations of postcodes, but the Post Office have <em>not </em>released the database <a href="http://news.bbc.co.uk/2/hi/technology/8402327.stm">linking actual postal addresses to postcodes</a>].</p>
<p style="text-align: justify;">So even though the cuts to IT may have an impact if there is a change of government, the opening up of data will create far more opportunities to geospatial developers, who will now be able to build workable systems and prototypes using real data to proactively drive IT projects rather than wait for the high hand of government to possibly offer them some crumbs from the table.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/Ck-2Z70nHHk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/politics-it-spending-and-gis/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/politics-it-spending-and-gis?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=politics-it-spending-and-gis</feedburner:origLink></item>
		<item>
		<title>The Seven Bridges of Königsberg</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/jAmD9irsvDk/the-seven-bridges</link>
		<comments>http://geographika.co.uk/the-seven-bridges#comments</comments>
		<pubDate>Mon, 29 Mar 2010 14:07:00 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[opinion]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[maths]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[typology]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=385</guid>
		<description><![CDATA[..or do geodevelopers require mathematics? Alan Skorkin has a great post on “you don’t need math skills to be a good developer but you do need them to be a great one.” Geo-technology developers have similar requirements, and the majority of GISs revolve around CRUD operations. However due to the nature of spatial data we <a href='http://geographika.co.uk/the-seven-bridges'>[...]</a>]]></description>
			<content:encoded><![CDATA[<h3>..or do geodevelopers require mathematics?</h3>
<p style="text-align: justify;"><img style="margin: 0px 5px 5px 0px; display: inline; border: 0px;" title="MyCircle.Area seems simpler.." src="http://geographika.co.uk/wp-content/uploads/2010/03/image5.png" border="0" alt="MyCircle.Area seems simpler.." width="149" height="64" align="left" /> Alan Skorkin has a great post on “<a href="http://www.skorks.com/2010/03/you-dont-need-math-skills-to-be-a-good-developer-but-you-do-need-them-to-be-a-great-one/" target="_blank">you don’t need math skills to be a good developer but you do need them to be a great one</a>.” Geo-technology developers have similar requirements, and the majority of GISs revolve around <a href="http://en.wikipedia.org/wiki/Create,_read,_update_and_delete" target="_blank">CRUD</a> operations. However due to the nature of spatial data we occasionally get to meddle in the world’s of <a href="http://en.wikipedia.org/wiki/Map_projection">projections</a>, geometry, <a href="http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Topology_basics">typology</a>, and <a href="http://en.wikipedia.org/wiki/Set_theory">set theory</a> more than our counterparts in other sectors.</p>
<h3>The Ancient Mysteries</h3>
<p style="text-align: justify;"><img style="margin: 0px 0px 5px 5px; display: inline; border: 0px;" title="There are now five bridges in Königsberg.." src="http://geographika.co.uk/wp-content/uploads/2010/03/image6.png" border="0" alt="There are now five bridges in Königsberg.." width="164" height="130" align="right" />Whilst concentrating on algorithms and <a href="http://en.wikipedia.org/wiki/Tower_of_Hanoi">recursion</a> is a definite benefit to all developers, us <em>spatial</em> developers need a few more specific tricks.  <a href="http://en.wikipedia.org/wiki/Leonhard_Euler">Euler&#8217;s</a> 1736 paper on <a href="http://en.wikipedia.org/wiki/Seven_Bridges_of_K%C3%B6nigsberg">Seven Bridges of Königsberg</a><em> </em> is one of the first academic writings on modern topology. The titles of these mathematics puzzles create an aura of mysteriousness and arcane knowledge that definitely sweetens the somewhat dour algebra underneath.</p>
<p style="text-align: justify;">The solution (or non-solution) to this problem underpins many of the more advanced techniques used by GIS packages today. The “<a href="http://gebweb.net/optimap/">Travelling Salesman</a>”, whilst conjuring up less interesting images, relies on similar principles of graph theory. <span id="more-385"></span></p>
<div class="wp-caption aligncenter" style="width: 212px"><img style="margin: 0px auto; display: block; border: 0pt none;" title="Traditional desktop GIS sales take a slump.." src="http://geographika.co.uk/wp-content/uploads/2010/03/image7.png" border="0" alt="Traditional desktop GIS sales take a slump.." width="202" height="114" /><p class="wp-caption-text">Traditional desktop GIS sales take a slump..</p></div>
<h3><a href="http://en.wikipedia.org/wiki/Graph_theory">Graph Theory</a></h3>
<p>The excellent ESRI online documentation provides details on all aspects of GIS, including <a href="http://resources.esri.com/help/9.3/arcgisengine/dotnet/e084da94-d4f7-4da7-86ed-7df684ff2144.htm">networks and graphs</a>.</p>
<div class="wp-caption alignleft" style="width: 177px"><img style="margin: 0px 5px 0px 0px; display: inline; border: 0pt none;" title="Some M. C. Escher works illustrate topological concepts, such as Möbius strips and non-orientable spaces" src="http://geographika.co.uk/wp-content/uploads/2010/03/image8.png" border="0" alt="Some M. C. Escher works illustrate topological concepts, such as Möbius strips and non-orientable spaces" width="167" height="213" align="left" /><p class="wp-caption-text">What can happen if you don’t understand typology</p></div>
<blockquote>
<p style="text-align: justify;"><em>Graph theory is the foundation for understanding networks and topology. A geographic information system (GIS) modeller should be familiar with the concepts and terminology of graph theory because it helps to classify and model connectivity and adjacency relationships among geographic features.</em></p>
</blockquote>
<p style="text-align: justify;">The underlying graphs of a network allow us to solve problems such as finding a shortest route, or analysing connectivity between points on a river network. It could certainly help a <a href="http://www.uclic.ucl.ac.uk/harold/cpp/">Chinese Postman</a>.</p>
<p style="text-align: justify;">Whilst being able to implement these algorithms from scratch is beyond the call of duty for most developers (except those who like to <a href="http://www.mostlymaths.net/2010/03/8-reasons-for-re-inventing-wheel-as.html">reinvent the wheel</a>), an understanding of how they work, and being able to recognise the situations where they can be used, can save weeks of development time and lead to cleaner more elegant coding solutions.</p>
<h3><a href="http://en.wikipedia.org/wiki/Autodidacticism">Self-Learning</a></h3>
<p style="text-align: justify;">Once you out in the “real-world” it is highly unlikely you are ever going to get taught this maths, and it becomes a little daunting realising you are now responsible for <a href="http://lifehacker.com/software/education/technophilia-get-a-free-college-education-online-201979.php">your own education</a>. Even if you’ve already studied maths to a reasonable level, as the adage says &#8211; <a href="http://www.sciencedaily.com/releases/2008/02/080207091859.htm"><em>use it or lose it</em></a>. This is brought home by my worriying belief that my mental arithmetic was superior as a child through constant use and learning tables by rote, than it is now after 10 years of programming.</p>
<p style="text-align: justify;">Every now and again its useful to buy a book that deals with areas <a href="http://www.amazon.com/gp/product/0486247759?ie=UTF8&amp;tag=geographika-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0486247759">related to computer science</a>, rather than a “How to..” book of the latest programming language or framework, to try and attain a broader understanding of the maths behind the APIs.</p>
<h3>Graph-ics</h3>
<p style="text-align: justify;">To try and illustrate my point that only a basic understanding of a branch of mathematics is required to produce useful, and sometimes spectacular results I attempted to use a specialised open-source tool armed with only a basic glossary of the <a href="http://primes.utm.edu/cgi-bin/caldwell/tutor/graph/glossary.html" target="_blank">terms used</a> in graph theory.</p>
<p style="text-align: justify;"><a href="http://gephi.org/">Gephi</a> is “an interactive visualization and exploration <a href="http://gephi.org/features/">platform</a> for all kinds of networks and complex systems, dynamic and hierarchical graphs.”</p>
<p style="text-align: justify;">Amongst the <a href="http://wiki.gephi.org/index.php/Datasets">sample datasets</a> there is an adjacency network of common adjectives and nouns in the <a href="http://en.wikipedia.org/wiki/David_Copperfield_%28novel%29">David Copperfield</a>. I was able to import the data into the program and then export the SVG image shown below. Interestingly “happy” is seems to have as many connections to love as money, which is pleasant.</p>
<p><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/03/image9.png" border="0" alt="image" width="355" height="205" /></p>
<p style="text-align: justify;"><a href="http://gephi.org/">Gephi</a> produces <a href="http://www.amazon.com/gp/product/0596157118?ie=UTF8&amp;tag=geographika-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0596157118">beautiful data</a> and is definitely a project to keep an eye on &#8211; the <a href="http://wiki.gephi.org/index.php/Roadmap">Road map for version 1.0</a> includes Geographic data (latitude/longitude) which will open up all sorts of possibilities.</p>
<h3>Do the Math(s)?</h3>
<p style="text-align: justify;">I’d categorise most people coding in the geospatial area (outside of those in academia or writing the internals of a GIS library), as developers, rather than <a href="http://www.skorks.com/2010/03/the-difference-between-a-developer-a-programmer-and-a-computer-scientist/">computer scientists or programmers</a>.</p>
<blockquote>
<p style="text-align: justify;"><em><strong>(Developers) are consummate generalists without any truly deep specializations</strong>. They are expert at finding ways around problems and plugging components together to fulfil a set of requirements.</em></p>
</blockquote>
<p style="text-align: justify;">A basic understanding of each of the branches of mathematics used by GIS is required to know what exactly you need to input, and to understand the output, of algorithms implemented by others. A grasp of terminology certainly helps navigate the user interfaces of specialised tools, or find help through search engines. At the very least it leads to an understanding of why <a href="http://www.manifold.net/index.shtml" target="_blank">Manifold</a> is named <a href="http://en.wikipedia.org/wiki/Manifold" target="_blank">manifold</a>, and can stop or start us going round in <a href="http://www.google.com/search?q=recursion">circles</a>.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/jAmD9irsvDk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/the-seven-bridges/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/the-seven-bridges?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=the-seven-bridges</feedburner:origLink></item>
		<item>
		<title>Does SQL Azure have Allure?</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/sX43DJPWClo/does-sql-azure-have-allure</link>
		<comments>http://geographika.co.uk/does-sql-azure-have-allure#comments</comments>
		<pubDate>Fri, 26 Mar 2010 14:10:00 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[opinion]]></category>
		<category><![CDATA[sql server 2008]]></category>
		<category><![CDATA[azure]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[geodatabase]]></category>
		<category><![CDATA[sqlserver]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/does-sql-azure-have-allure</guid>
		<description><![CDATA[I love SQL Server 2008 spatial functionality. Not only because it has effectively killed off the middle-man GIS database software, but it even sticks to OGC standards allowing the same data and tables to be used in nearly all GIS software. However I have some reservations about the use of SQL Azure for GIS applications. <a href='http://geographika.co.uk/does-sql-azure-have-allure'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><img style="margin: 0px 5px 0px 0px; display: inline; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/03/image2.png" border="0" alt="image" width="167" height="46" align="left" /> I love SQL Server 2008 spatial functionality. Not only because it has effectively killed off the middle-man GIS database software, but it even sticks to <a href="http://www.opengeospatial.org/standards/sfa">OGC standards</a> allowing the same data and tables to be used in nearly all GIS software. However I have some reservations about the use of <a href="http://blogs.msdn.com/edkatibah/archive/2010/03/21/spatial-data-support-coming-to-sql-azure.aspx" target="_blank">SQL Azure for GIS applications</a>.</p>
<h3 style="text-align: justify;"><a href="http://www.microsoft.com/windowsazure/faq/#" target="_blank">FAQ</a></h3>
<blockquote style="text-align: justify;"><p><em>How is SQL Azure Database different from working with a hoster using SQL Server?</em></p></blockquote>
<blockquote style="text-align: justify;"><p>Developers do not have to install, setup, patch or manage any software. High Availability and fault tolerance is built-in and no physical administration of hardware, storage or servers is required.</p></blockquote>
<p style="text-align: justify;">If you have a good hosting solution then the same benefits apply (well maybe not the &#8220;self-healing&#8221; also mentioned). The only real difference I can tell is that you pay a lot more, to be able to scale more easily. Its unlikely your <a href="http://www.esri.com/industries/planning/index.html">Local Planning Mapping</a> system is suddenly going to need to scale up to meet the expectations of millions of new users, no matter how great the system looks.</p>
<p style="text-align: justify;"><span id="more-359"></span><strong>Update</strong>: Many thanks to <a href="http://blogs.msdn.com/dachou/">David Chou</a> for his clarifications on this &#8211; see comments below. In essence a SQL Azure database uses three replicas of your database with a layer on top that makes it appear to the application and user as a single instance. It is this new architecture that allows for scalability, and the self-healing (which still makes me think of Tekken&#8217;s <a href="http://thelonegamer.wordpress.com/2009/09/07/tekken-6-character-countdown-part-39-yoshimitsu/">Yoshimitsu</a>).</p>
<blockquote style="text-align: justify;"><p><em>Windows Azure and SQL Azure SLAs are independent of our on-premises Microsoft licensing agreements.</em></p></blockquote>
<p style="text-align: justify;">So if you do plan to continue standard &#8220;earth&#8221; development, you&#8217;ll still be paying SQL Server licences. For most government departments and large businesses there will always be some data that needs to be stored locally.</p>
<h3 style="text-align: justify;"><!--more-->For Developers</h3>
<blockquote style="text-align: justify;"><p>Currently you can’t bring your existing on-premises Windows Server, SQL Server to Windows Azure, SQL Azure.</p></blockquote>
<p style="text-align: justify;"><span style="text-decoration: line-through;">So it doesn&#8217;t seem possible to develop database applications locally and then upload all your views, stored procedures, functions and data in one go to Azure.</span> It appears this only applies to the server software (see comments) &#8211; I&#8217;d imagine Enterprise level funcitonality such as mirroring or replication. The actual tables, stored procedures, and views will be fine to import.</p>
<p style="text-align: justify;">SQL Server Management Studio will be able to access the online databases, but I would be interested to see how quickly a result set from a query would be returned. Would this data be returned locally and slowly, or would it work in a similar way to Remote Desktop by returning images from the server?</p>
<h3 style="text-align: justify;">Cheque Please</h3>
<p style="text-align: justify;">The <a href="http://www.microsoft.com/windowsazure/pricing/#sql" target="_blank">pricing structure</a> is as follows:</p>
<ul style="text-align: justify;">
<li>Web Edition:  Up to 1 GB relational database = $9.99 / month</li>
<li>Business Edition:  Up to 10 GB relational database = $99.99 / month</li>
<li>Data transfers = $0.10 in / $0.15 out / GB &#8211; ($0.30 in / $0.45 out / GB in Asia)*</li>
</ul>
<p style="text-align: justify;"><img style="margin: 0px 5px 0px 0px; display: inline; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/03/image3.png" border="0" alt="image" width="136" height="101" align="left" /></p>
<p style="text-align: justify;">I’ve just completed a GIS project using SQL Server 2008, with around 60 different layers. The database is around 15 GB (<a href="http://msdn2.microsoft.com/en-us/library/ms188776(SQL.90).aspx" target="_blank">this stored procedure</a> returns disk space on a table by table basis). Uploading this data would be cheap enough at only $1.50, but would take hours. It was far easier to go round to the hosts with an external hard-drive, than upload from our network.</p>
<p style="text-align: justify;">Where things get scary for a GIS developer is considering the data transfers out of a system as soon as the <a href="http://www.microsoft.com/sqlserver/2008/en/us/spatial-data.aspx" target="_blank">Microsoft spatial data types</a> get involved.</p>
<p style="text-align: justify;">The amount amount of bytes sent over the network in SQL Server for each query can be viewed using <a href="http://blog.sqlauthority.com/2009/10/01/sql-server-sql-server-management-studio-and-client-statistics/" target="_blank">Client Statistics</a>. Selecting 100 records from one of my tables resulted in 14 KB of data transfer.  Selecting 100 records and their associated polygons resulted <strong><em>in over 10 times more traffic</em></strong> at 151 KB (here’s an <a href="http://easycalculation.com/bandwidth-calculator.php" target="_blank">online calculator</a> for bit/kilobyte conversions).</p>
<p style="text-align: justify;"><img style="margin: 0px auto; display: block; float: none; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/03/image4.png" border="0" alt="image" width="389" height="203" /></p>
<p style="text-align: justify;">Whilst I presume it is possible to set up a <a href="http://en.wikipedia.org/wiki/Web_Map_Service" target="_blank">WMS</a> server such as <a href="http://mapserver.org/">MapServer</a> in Azure, it is unclear whether the &#8220;data out&#8221; costs apply to data that leaves <em>the cloud</em> or to <strong>any data</strong> that leaves the database (thanks to <a href="http://blogs.msdn.com/edkatibah/">Ed Katibah</a> for more details &#8211; charges only apply to data leaving Azure sub-region (Western Europe is a sub-region). In this second scenario it could well be game over. It is easy to imagine spiralling costs if you wish to display a few dynamic vector layers, and the database takes a hit on every user&#8217;s zoom or pan.</p>
<h3 style="text-align: justify;">It’s (not) all about the Data(base)</h3>
<p style="text-align: justify;">The target market for SQL Azure in GIS however may not be individual applications, but rather business to business spatial services. Datasets used for geolocation and navigation could be stored in one place with an <a href="http://code.google.com/apis/maps/" target="_blank">API</a> that could then be called by any number of web applications. These “clients” could then be charged a premium on top of Azure’s costs for the additional services. Heavy use of results caching would mitigate the price of data transfer.</p>
<p style="text-align: justify;">Unfortunatley for Microsoft it appears once again Google already has a big chunk of this (spatial) market wrapped up. For free, or <a href="http://www.google.com/enterprise/earthmaps/maps_features.html" target="_blank">$10,000 if charging for your service</a>.  Another example is James Fee&#8217;s <a href="http://www.weogeo.com/" target="_blank">WeoGeo</a>. I presume by James&#8217;s quote about <a href="http://www.spatiallyadjusted.com/2010/03/22/spatial-database-in-the-cloud/" target="_blank">getting your ducks in a row</a> his is clearly a business model that could benefit from SQL Azure. Both examples differ from the SQL Azure model of selling database services in that they both provide <em><strong>data </strong></em>as part of a cloud solution.</p>
<p style="text-align: justify;">There are still many unknowns on how this will develop over time, and who will benefit from Azure. Its nice to know the spatial functionality is out there in the cloud, but for the majority of web mapping applications the risk of sky-high costs may keep it there. Case studies and early-adopter&#8217;s experiences will hopefully help paint a clearer picture. Microsoft&#8217;s main competitor could well be Microsoft. <a href="http://www.microsoft.com/express/database/">SQL Server 2008  Express</a> is free (however with a 4GB limit), and includes both  spatial functionality and Reporting Services. If you need to scale up it seems simpler to change your licence rather than your entire mindset.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/sX43DJPWClo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/does-sql-azure-have-allure/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/does-sql-azure-have-allure?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=does-sql-azure-have-allure</feedburner:origLink></item>
		<item>
		<title>MapInfo and SQL Server 2008</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/JEmsBJ0Gmdg/mapinfo-and-sql-server-2008</link>
		<comments>http://geographika.co.uk/mapinfo-and-sql-server-2008#comments</comments>
		<pubDate>Wed, 24 Mar 2010 10:09:01 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[bugs]]></category>
		<category><![CDATA[geodatabases]]></category>
		<category><![CDATA[mapinfo]]></category>
		<category><![CDATA[sql server 2008]]></category>
		<category><![CDATA[geodatabase]]></category>
		<category><![CDATA[gis]]></category>
		<category><![CDATA[sqlserver]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=347</guid>
		<description><![CDATA[For a new project I am working for the first time with MapInfo 10 &#8220;the world&#8217;s premier desktop mapping application.&#8221; In an effort to move away from MapInfo&#8217;s .tab files (the shapefile equivalent) I was keen to test out the direct connection to geometry stored in SQL Server 2008. Until version 9.5 data could only <a href='http://geographika.co.uk/mapinfo-and-sql-server-2008'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://geographika.co.uk/wp-content/uploads/2010/03/mapinfo_pro.gif"><img class="alignleft size-full wp-image-348" style="margin-left: 0px; margin-right: 3px;" title="mapinfo_pro" src="http://geographika.co.uk/wp-content/uploads/2010/03/mapinfo_pro.gif" alt="" width="194" height="171" /></a>For a new project I am working for the first time with <a href="http://www.pbinsight.com/products/location-intelligence/applications/mapping-analytical/mapinfo-professional/">MapInfo</a> 10 <em>&#8220;the world&#8217;s premier desktop mapping application.&#8221;</em></p>
<p style="text-align: justify;">In an effort to move away from MapInfo&#8217;s .tab files (the shapefile equivalent) I was keen to test out the direct connection to geometry stored in SQL Server 2008. Until version 9.5 data could only be stored and accessed in a relational database using <a href="http://www.pbinsight.com/products/location-intelligence/developer-tools/enterprise-software/spatialware/">SpatialWare</a>. Again to use ESRI terminology this is the ArcSDE equivalent. Fortunately MapInfo was quick off the mark in removing this barrier.</p>
<p style="text-align: justify;">Access to SQL Server 2008 spatial data is provided by integrating FME functionality directly into the product, and having a &#8220;Universal Data&#8221; option on the File menu. There is also a tool named <a href="http://www.pbinsight.com/support/product-downloads/item/easyloader-v10.0">Easy Loader</a> that allows loading .tab files into SQL Server as geometry.</p>
<p style="text-align: justify;"><span id="more-347"></span>Unfortunately on trying to use the Universal Data menu after installing a fresh copy of MapInfo 10 I was met with the error <em>&#8220;This application has failed to start because qfmeext.dll was not found. Re-installing the application may fix this problem.&#8221;</em></p>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/03/map_info_crash.png"><img class="aligncenter size-full wp-image-349" title="map_info_crash" src="http://geographika.co.uk/wp-content/uploads/2010/03/map_info_crash.png" alt="" width="532" height="96" /></a></p>
<p style="text-align: justify;">Hardly a good <em>premier </em>start..Anyway it appears upgrading to the 10.0.1 maintenance release fixes this issue. <span style="text-decoration: line-through;">No mention of the issue itself in the <a href="http://reference.mapinfo.com/software/mapinfo_pro/english/10.0.1/MapInfoProfessionalReleaseNotes_1001.pdf">release notes</a></span> (<strong>Update</strong>: It is in the <a href="http://reference.mapinfo.com/software/mapinfo_pro/english/10.0.1/MapInfoProfessionalReleaseNotes_1001.pdf">release  notes</a>, see comments below, and only occurs when ArcGIS is also installed). There were also a couple of additional fixes for SQL Server (fhe following text direct from the maintenance release notes).</p>
<h3>Improving Performance when Connecting to a SQL Server Database</h3>
<p>To improve performance when accessing large SQL Server tables, add a Multiple Active Result Sets (MARS) connection setting to the connection string in the live access .TAB file. The connection attribute to update is \DATALINK\ConnectionString, for example:</p>
<pre>"\DATALINK\ConnectionString" = "DSN=local-native10;UID=username;
Trusted_Connection=Yes;APP=MapInfo Professional®;
WSID=hostname;DATABASE=test;MARS_Connection=Yes;"</pre>
<p>You may also add the MARS connection setting to the connection string of MapBasic Server_Connect( ) command. Note that a MARS connection:</p>
<ul>
<li>does not work for SpatialWare tables.</li>
<li>only applies to SQL Native Client or SQL Server Native Client 10. Other connection types so not benefit from this setting.</li>
</ul>
<h3>Also Fixed..</h3>
<p>T25293 Opening a SQL Server table containing a column with type NCHAR causes an error message, “Unsupported data type for column&#8230;”<br />
Resolution: Issue is resolved.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/JEmsBJ0Gmdg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/mapinfo-and-sql-server-2008/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/mapinfo-and-sql-server-2008?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=mapinfo-and-sql-server-2008</feedburner:origLink></item>
		<item>
		<title>6 Tips for Developers Moving into GIS</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/W1DjLO0dNUA/6-tips-for-developers-moving-into-gis</link>
		<comments>http://geographika.co.uk/6-tips-for-developers-moving-into-gis#comments</comments>
		<pubDate>Tue, 16 Mar 2010 13:49:49 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[opinion]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[developers]]></category>
		<category><![CDATA[neogeographers]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=314</guid>
		<description><![CDATA[With the rise of the neogeographers, along with the increased awareness and use of GIS thanks to the web, more and more positions are open for developers looking to move away from writing business accounting logic, and into the exciting “new” world of spatial data. I’ve noticed a few gotchas that have happened to developers <a href='http://geographika.co.uk/6-tips-for-developers-moving-into-gis'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">With the rise of the <a href="http://veryspatial.com/2009/05/a-veryspatial-podcast-episode-202/" target="_blank">neogeographers</a>, along with the increased awareness and use of GIS thanks to the web, more and more positions are open for developers looking to move away from writing business accounting logic, and into the exciting “new” world of spatial data. I’ve noticed a few gotchas that have happened to developers with no GIS background while working on projects, so this list may at least raise awareness of some of the hurdles.</p>
<h3 style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/03/image.png"><img style="margin: 0px 5px 0px 0px; display: inline; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/03/image_thumb.png" border="0" alt="image" width="166" height="143" align="left" /></a></h3>
<h3 style="text-align: justify;">1. Get to Know your GIS Application</h3>
<p style="text-align: justify;">Most desktop development in GIS involves building extensions to an existing application using an existing programming library. In order to avoid reinventing the wheel you need to be able to use your GIS desktop package.</p>
<p style="text-align: justify;">Before developing any automated tasks, manually go through the process to get a feel for any issues that may arise, and learn some of the terminology used by the program for the various functions. If the application has an option for hatched polygon fills, this option is also likely to be buried somewhere in the API. If you can’t find what you are looking for then run what you are trying to accomplish past a GIS user.</p>
<h3 style="text-align: justify;"><span id="more-314"></span>2. Learn some Basic Terminology</h3>
<p style="text-align: justify;">A good GIS glossary can be found on the<a title="http://support.esri.com/index.cfm?fa=knowledgebase.gisDictionary.gateway" href="http://" target="_blank"> ESRI site</a>, and it is also available in a <a href="http://www.amazon.com/gp/product/1589481402?ie=UTF8&amp;tag=geographika-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1589481402">A to Z of GIS</a><img style="margin: 0px; border-style: none !important;" src="http://www.assoc-amazon.com/e/ir?t=geographika-20&amp;l=as2&amp;o=1&amp;a=1589481402" border="0" alt="" width="1" height="1" /> book. Of course nothing is simple as different software companies use different terms for the same thing so a <em>Layer </em>in ArcMap, is the equivalent of an <em>Overlay </em>in Google Maps.</p>
<p style="text-align: justify;">If you want to find all the point addresses within 100m of a road you don&#8217;t need to spend weeks writing your own algorithms (I’ve seen this happen..), armed with a good GIS vocabulary you will be aware of the term <em>buffering </em>and can find how to do this programmatically in your software. Your new employer will prefer a basic question related to GIS or geography than 2 weeks developing a function that could be achieved with a single line of code.</p>
<p style="text-align: justify;">If developing for the web there are a plethora of technical terms you will have to learn such as WMS, WFS, GeoJSON, GeoXML (most web standards also seem to take a Geo- prefix), KML, tile caches etc.</p>
<h3>3. Get to Know your Datasets</h3>
<p><a href="http://geographika.co.uk/wp-content/uploads/2010/03/image1.png"><img style="margin: 0px; display: inline; border: 0px;" title="image" src="http://geographika.co.uk/wp-content/uploads/2010/03/image_thumb1.png" border="0" alt="image" width="124" height="124" align="left" /></a> Half the battle with GIS development is getting data into a consistent format so you can run analyses on it. Get ready to start dealing with Excel spreadsheets, strange proprietary GIS formats, and file dumps that may or may not resemble databases. Remember that many of these datasets will be coming from GIS technicians rather than database developers. <a href="http://www.safe.com/" target="_blank">Safe’s FME</a> can convert pretty much anything to anything else, and the translations can be saved and automated saving plenty of time.</p>
<p>Spatial data is not <em>too</em> complicated. Most features can be represented as points, lines, or polygons. Obviously things can get more complicated such as multipart polygons, <a href="http://www.aubreyrhea.net/gis/index.php/2009/08/creating-a-doughnut-polygon/" target="_blank">doughnuts</a>, geometric networks etc. but these features are not overly common. However learn about <a href="http://en.wikipedia.org/wiki/Map_projection" target="_blank">projections</a> and how to reproject data. If your data is invisible with no errors then projections are often the issue.</p>
<p>There is also a semi-mythical object called <a href="http://en.mimi.hu/gis/metadata.html" target="_blank">metadata</a>. If this doesn’t exist expect to spend plenty of time trying to track down what various fields mean, if look-up tables are available, and what projection the data is in.</p>
<h3 style="text-align: justify;">4. Learn the differences between <a title="http://en.wikipedia.org/wiki/Geographic_information_system#Raster" href="http://" target="_blank">Raster</a> and <a title="http://en.wikipedia.org/wiki/Geographic_information_system#Vector" href="http://" target="_blank">Vector</a>.</h3>
<p style="text-align: justify;">If you want to display cells across a whole country then you will need to user raster, vector data will take an age to draw. Don’t make the mistake or drawing lots of nicely coloured geometric squares.</p>
<h3 style="text-align: justify;">5. Find New Programming Forums</h3>
<p style="text-align: justify;">You may need to look further afield than <a href="http://stackoverflow.com/" target="_blank">StackOverflow</a> for answers to technical problems (except maybe Google Maps on Android).  Where to look depends on what you work with. Each major GIS vendor’s site is likely to have a forum which serves as the focal point for all developers using their software, for example ESRI has widely used <a href="http://support.esri.com/index.cfm?fa=forums.gateway" target="_blank">user forums</a>. For open source mailing lists seem to be the support technology of choice – here <a href="http://www.nabble.com/" target="_blank">Nabble</a> is your friend.</p>
<h3>6. Bring your experience</h3>
<p style="text-align: justify;">Many people working in GIS come from a geography background, and are self-taught programmers. If you are working with a team then try to introduce concepts that are now commonplace in other areas of software development &#8211; source control, unit tests, object programming etc.</p>
<p style="text-align: justify;">You may also see GIS users spending hours doing things by hand that can clearly be automated. If you know some Python then you will be able to save hundreds of man hours with geoprocessing scripts for both proprietary and open source applications. For unknown reasons Python has become the scripting language of choice in GIS. Its good for web GIS too.</p>
<p style="text-align: justify;">Along with software development practices any previous experience with databases will be huge plus. If you know what the following are you will soon become a very productive member of staff &#8211; primary key, normalisation, relationships may be new concepts to your new organisation. <a href="http://en.wikipedia.org/wiki/Geodatabase" target="_blank">Geodatabases</a> introduce a few new concepts, such as spatial indexes, projections, and geometry types, but if you have a good grounding in standard databases you will pick things up easily.</p>
<p style="text-align: justify;">Feel free to add anything I’ve missed in the comments below, and good luck!</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/W1DjLO0dNUA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/6-tips-for-developers-moving-into-gis/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/6-tips-for-developers-moving-into-gis?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=6-tips-for-developers-moving-into-gis</feedburner:origLink></item>
		<item>
		<title>Task #13: User Documentation</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/5gf5NQfZR4I/task-13-user-documentation</link>
		<comments>http://geographika.co.uk/task-13-user-documentation#comments</comments>
		<pubDate>Mon, 15 Mar 2010 15:36:39 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[handler]]></category>
		<category><![CDATA[screwturnwiki]]></category>
		<category><![CDATA[wiki]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=296</guid>
		<description><![CDATA[All projects I&#8217;ve worked on have a few days set aside for the dreaded &#8220;documentation.&#8221; Clients often try and reduce the billable hours set aside for documentation and when project delivery times are closing its often the last thing on a developers mind, so it gets cut from both sides. I&#8217;ve come to the conclusion <a href='http://geographika.co.uk/task-13-user-documentation'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/03/documentation.jpg"><img class="alignleft size-medium wp-image-297" style="margin: 2px;" title="documentation" src="http://geographika.co.uk/wp-content/uploads/2010/03/documentation-300x299.jpg" alt="" width="189" height="189" /></a>All projects I&#8217;ve worked on have a few days set aside for the dreaded &#8220;<em>documentation</em>.&#8221; Clients often try and reduce the billable hours set aside for documentation and when project delivery times are closing its often the last thing on a developers mind, so it gets cut from both sides.</p>
<p style="text-align: justify;">I&#8217;ve come to the conclusion that a detailed and long word document, while it may tick the box on the client&#8217;s checklist, is an exercise in futility. No-one ever reads it, you&#8217;re lucky if you can even find it a year later, and its out of date the moment its written (or  if its a rehash of the technical specification its never actually <em>in-date</em>).</p>
<p style="text-align: justify;">
<p style="text-align: justify;">My key requirements for user documentation are:</p>
<ul>
<li>make it easily accessible from within and from without the system</li>
<li>have only one repository for the user documentation</li>
<li>allow people other than the developer to create and edit the documentation</li>
<li>auto-generate when and if possible</li>
</ul>
<p style="text-align: justify;"><span id="more-296"></span>I initially started creating web pages, even for desktop systems, as these could be accessed by both project managers and users of the system. This met most of my criteria above, but I knew that if anything in the system changed I&#8217;d be the one who would have to go in and edit the HTML. Step forward..</p>
<h3>Wikis</h3>
<p style="text-align: justify;">Despite a name that makes me cringe every time I say it, an online wiki has all the benefits of using web pages for user help systems, but with an additional  number of advantages:</p>
<ul>
<li>non-developers can learn how to use wiki markup much more easily than writing HTML pages</li>
<li>edits are attributed to users</li>
<li>edits are stamped with a time and date which gives you an overview of how up to date the documentation is (this may not necessarily be a good thing..)</li>
<li>inbuilt search functionality</li>
<li>premade themes and templates</li>
<li>administration tools</li>
</ul>
<h3>ScrewTurn Wiki</h3>
<p style="text-align: justify;">I&#8217;ve been moving more and more towards open source tools, and after a brief dalliance with a few different wikis I settled on <a href="http://www.screwturn.eu/">Screwturn Wiki</a>. It is written in .NET which I am very familiar with, and most of my client&#8217;s sites are hosted under IIS/Windows. While some clients do use Microsoft&#8217;s Sharepoint, and Sharepoint includes a wiki, it seems overly complicated to develop a help system internally and then try and import to the client&#8217;s Sharepoint set up. A new ScrewTurn Wiki site can be set up in about 10 minutes, and an existing site can be installed on a client&#8217;s server by simply copying over a folder.</p>
<h3 style="text-align: justify;">Now the fun part..</h3>
<p style="text-align: justify;">While the actual writing of user help is tedious, the creation of a help system need not be. And if you are using a wiki you may be able to &#8220;delegate&#8221; the user help to someone else (depending on the size of your company). Once the wiki is being populated the more you can use this information throughout your system the better.</p>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/03/user_help.png"><img class="aligncenter size-medium wp-image-298" title="user_help" src="http://geographika.co.uk/wp-content/uploads/2010/03/user_help-300x126.png" alt="" width="300" height="126" /></a></p>
<p style="text-align: justify;">For a <a href="http://mapfish.org/">MapFish</a> based online mapping system I am creating, I was able to automate my help system to display the toolbar buttons, along with their associated icons, as part of my help menu structure. If the icons are changed, the button removed or renamed, or new buttons added, the help system will update accordingly. The next step was to load the relevant tool description text from the wiki when the tool was selected in the menu.</p>
<p style="text-align: justify;">To do this I created basic pages in the wiki, and gave each toolbar button a custom helpPage attribute with the name of the wiki page. I then took my first look at the ScrewTurn Wiki (version 2.0) sourcecode to see how to retrieve the relevant HTML.</p>
<p style="text-align: justify;">I created an ASP.NET handler that would retrieve the HTML from a pre-made wiki page, without requiring IFrames. The class <a href="http://geographika.co.uk/downloads/wikiHandler.ashx.txt">can be seen here</a>.</p>
<p style="text-align: justify;">I had to edit the Global.asax file to allow my wikiHandler.ashx web handler to be accessed (by default all .ashx are seen as wiki pages).</p>
<pre style="text-align: justify;">if(ext.Equals("ashx")) {
    if(pageName != "wikiHandler"){
      // Demand the request to Default.aspx
      HttpContext.Current.RewritePath("~/Default.aspx?Page=" +
      ScrewTurn.Wiki.Tools.UrlEncode(pageName) + qs);
    }
 }
</pre>
<p style="text-align: justify;">I could then make requests such as <a href="http://">wikiHandler.ashx?Page=ZoomIn</a> to return snippets of HTML that would be loaded dynamically into my help system. Knowing that wiki text may actually be read helps to get that &#8220;documentation&#8221; task finally checked off and a project signed off.  A client is also happy to know that they can update and add to the help notes without requiring developers.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/5gf5NQfZR4I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/task-13-user-documentation/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/task-13-user-documentation?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=task-13-user-documentation</feedburner:origLink></item>
		<item>
		<title>MapServer+Windows 64 bit+Apache=Crash?</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/iK6_dTH4RsA/mapserverwindowsapachecrash</link>
		<comments>http://geographika.co.uk/mapserverwindowsapachecrash#comments</comments>
		<pubDate>Thu, 11 Mar 2010 14:38:47 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[bugs]]></category>
		<category><![CDATA[mapserver]]></category>
		<category><![CDATA[64bit]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[bug]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=267</guid>
		<description><![CDATA[I developed my MapServer application on Windows 2003 (a virtual 64 bit server running), using MS4W (MapServer for Windows), and had set up TileCache, and some Python scripts to run through Apache. I had managed to crash the set up numerous times in development, but I hadn&#8217;t come across any errors not of my own <a href='http://geographika.co.uk/mapserverwindowsapachecrash'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/01/mapserver_error.png"><img class="alignleft size-medium wp-image-269" style="border: 1px solid black; margin: 3px;" title="mapserver_error" src="http://geographika.co.uk/wp-content/uploads/2010/01/mapserver_error-277x300.png" alt="" width="277" height="300" /></a>I developed my MapServer application on Windows 2003 (a virtual 64 bit server running), using MS4W (MapServer for Windows), and had set up TileCache, and some Python scripts to <a href="http://geographika.co.uk/running-python-through-apache">run through Apache</a>. I had managed to crash the set up numerous times in development, but I hadn&#8217;t come across any errors not of my own making.</p>
<p style="text-align: justify;">The installation went well  on the production server which was also a 64 bit machine, but was using Windows Server 2008. The site had an unpublicised release as it is still in beta, and from this was getting about 60 &#8211; 70 visitors a day.</p>
<p style="text-align: justify;">I use <a href="http://host-tracker.com/">host-tracker.com</a> &#8211; a web site monitoring service which lets me know if a site is down, and I was soon made aware that it was.. There were no responses at all coming from Apache, even though the Apache service was still running. Not even HTML pages were returned. Restarting Apache returned the service to normal, but this was happening every other day.</p>
<p style="text-align: justify;">
<h3 style="text-align: justify;"><span id="more-267"></span>The Windows Error Log</h3>
<p style="text-align: justify;">The Windows Event Log had lots of the following errors:</p>
<pre style="text-align: justify;">Faulting application name: mapserv.exe, version: 0.0.0.0, time stamp: 0x4935ad86
Faulting module name: MSVCR71.dll, version: 7.10.3052.4, time stamp: 0x3e561eac
Exception code: 0xc0000005Faulting process id: 0xe08
Faulting application start time: 0x01caa0e28e6dcbb6
Faulting application path: C:\ms4w\Apache\cgi-bin\mapserv.exe
Faulting module path: C:\ms4w\Apache\cgi-bin\MSVCR71.dll
Report Id: 4bc3555e-0cd7-11df-9e56-00155d002601</pre>
<p style="text-align: justify;">The MSVCR71 refers to the Microsoft C run-time libraries, so I *think* the errors are likely to be from a program that uses them (ie. MapServer) rather than the DLL itself. Windows 2003 has this DLL in its system32 folder, whereas Windows 2008 does not, but as long as it is in the application directory (cgi-bin in MapServer&#8217;s case) then it should not be a problem. In short I don&#8217;t believe this DLL was the root of the problem. I tried turning on MapServer debugging, but there were no errors reported from MapServer itself.</p>
<h3 style="text-align: justify;">The Apache Error Log</h3>
<p style="text-align: justify;">On the other hand the Apache log (C:\ms4w\Apache\logs\error.log) had several warnings such as the following:</p>
<pre>[Thu Jan 28 15:37:15 2010] [warn] (OS 64)The specified network name is no longer available.  :
winnt_accept: Asynchronous AcceptEx failed.</pre>
<p style="text-align: justify;">The Apache documentation suggests that a possible cause of these errors is due to <em>&#8220;virus scanning or virtual private network packages, have bugs that interfere with the proper operation of AcceptEx().&#8221;</em> While I could rule the first out, the second was a definite possibility as I was required to use Juniper&#8217;s <a href="http://www.nscreensales.com/NetScreen_Remote_s/10.htm">NetScreenRemote</a> to connect to the server. The Juniper site now states <em>&#8220;N</em><em>o Longer Available. Use Standards based IPSec client.&#8221; </em></p>
<p style="text-align: justify;">I&#8217;ve had horrible problems with this software before, including no longer being able to connect to wi-fi networks (repairing IPSEC was the eventually solution), and corrupting a Cisco VPN client. The 0.5 star <a href="http://reviews.cnet.com/remote-access/netscreen-remote-vpn-client/4505-3540_7-30340681.html">review on CNET</a> show I am not alone in this opinion.</p>
<p style="text-align: justify;">I tried using the <a href="http://httpd.apache.org/docs/2.2/mod/mpm_winnt.html">Win32DisableAcceptEx</a> directive to try and stop these errors and hopefully resolve the Apache crashes. Apache runs in 32 bit mode, so hopefully the 64 bit server wouldn&#8217;t mind..In C:\ms4w\Apache\conf\httpd.conf  add the following line, and restart the Apache service:</p>
<pre style="text-align: justify;"><code>Win32DisableAcceptEx</code>
</pre>
<h3>Final Outcome</h3>
<p style="text-align: justify;">Unfortunately although the Apache changes stopped the errors it didn&#8217;t stop the crashing. In the end I had to set up MapServer with IIS and the site has been working fine ever since. As a bonus I was also able to use the 64 bit versions of MapServer.</p>
<pre style="text-align: justify;"></pre>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/iK6_dTH4RsA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/mapserverwindowsapachecrash/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/mapserverwindowsapachecrash?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=mapserverwindowsapachecrash</feedburner:origLink></item>
		<item>
		<title>Setting Up Python on IIS7</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/1G04Su0vx7M/setting-up-python-on-iis7</link>
		<comments>http://geographika.co.uk/setting-up-python-on-iis7#comments</comments>
		<pubDate>Thu, 04 Feb 2010 07:30:18 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[64bit]]></category>
		<category><![CDATA[handlers]]></category>
		<category><![CDATA[IIS7]]></category>
		<category><![CDATA[ISAPI]]></category>
		<category><![CDATA[PyISAPIe]]></category>
		<category><![CDATA[WSGI]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=273</guid>
		<description><![CDATA[I had already configured Python to run through the Apache webserver on my development server, but after a few issues on the production server (Apache freezing / crashing) I wanted to test running Python scripts with IIS7. The principle aim was to run TileCache through IIS rather than requiring Apache. Why Not CGI? While IIS <a href='http://geographika.co.uk/setting-up-python-on-iis7'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/01/iis7.png"><img class="size-medium wp-image-279 alignleft" style="margin: 3px;" title="iis7" src="http://geographika.co.uk/wp-content/uploads/2010/01/iis7-300x215.png" alt="" width="142" height="100" /></a>I had already configured Python to run through <a href="http://geographika.co.uk/running-python-through-apache">the Apache webserver</a> on my development server, but after a few issues on the production server (Apache freezing / crashing) I wanted to test running Python scripts with IIS7. The principle aim was to run <a href="http://tilecache.org/">TileCache</a> through IIS rather than requiring Apache.</p>
<h3>Why Not CGI?</h3>
<p style="text-align: justify;">While IIS 7 has Fast-CGI installed (see this <a href="http://forums.iis.net/1103.aspx">IIS forum</a>), even better performance can be achieved using ISAPI. This answer from <a href="http://serverfault.com/questions/9121/how-to-explain-django-python-installation-to-python-newbie-running-a-shared-iis-s">ServerFault</a> has a good summary on why ISAPI should be preferred over than CGI. Not only  performance  should be considered &#8211; maintenance should also be taken into account. If a web master or hosting service  is familiar with IIS then they are also likely to be familiar with ISAPI.</p>
<p>From the <a href="http://sourceforge.net/apps/trac/pyisapie">PyISAPIe</a> site:</p>
<p style="text-align: justify;"><em>The reason ISAPI applications have the capability of being better than <a href="http://hoohoo.ncsa.uiuc.edu/cgi/intro.html">CGI</a> or <a href="http://www.fastcgi.com/">FastCGI</a> applications is mostly due to its tight integration with the web server environment. Instead of initializing an entire program from scratch (in this case, the Python interpreter) every time a request is made for a page, an ISAPI extension only has to provide a function that is called upon every request. For interpreting Python scripts on a per-request basis, this means that the interpreter can be initialized </em><em>once and used many times, creating a very noticeable performance gain.</em></p>
<h3 style="text-align: justify;"><span id="more-273"></span>Some Definitions&#8230;</h3>
<blockquote>
<p style="text-align: justify;"><a href="http://en.wikipedia.org/wiki/Web_Server_Gateway_Interface">WSGI </a>-The Web Server Gateway Interface defines a simple and universal interface between web servers and web applications or frameworks for the Python programming language.</p>
</blockquote>
<p style="text-align: justify;">My interpretation &#8211; WSGI glues together IIS and Python scripts, or any web server and Python application combination, in a standard way.</p>
<blockquote>
<p style="text-align: justify;"><a href="http://en.wikipedia.org/wiki/Internet_Server_Application_Programming_Interface">ISAPI</a> &#8211; The Internet Server Application Programming Interface (ISAPI) is an N-tier API of Internet Information Services (IIS), Microsoft&#8217;s collection of Windows-based web server services. The most prominent application of IIS and ISAPI is Microsoft&#8217;s web server.</p>
</blockquote>
<p style="text-align: justify;">My uninformed interpretation &#8211; ISAPI allows DLLs written in a variety of languages to be loaded into IIS to handle web requests. ASP.NET would therefore be an ISAPI extension,  set to handle requests which end in .aspx</p>
<h3>The Python ISAPI Extension</h3>
<p style="text-align: justify;">I initially tried <a href="http://code.google.com/p/isapi-wsgi/">isapi-wsgi</a>, but I didn&#8217;t have much luck setting it up (I gave up fairly quickly though). It also depended on <em>&#8220;Mark Hammond&#8217;s Python win32 isapi extension&#8221;</em> &#8211; and I was trying to keep the amount of packages installed and added to a minimum. I therefore chose to use <a href="http://sourceforge.net/apps/trac/pyisapie">PyISAPIe</a> which has no dependencies, and only requires a DLL and a folder containing a few .py files.</p>
<p style="text-align: justify;">Documentation and installation instructions are sparse, and assume good knowledge of Python, IIS, and web requests in general in which I was lacking. In retrospect they make perfect sense though! The following links seem to be about the sum knowledge of PyISAPIe on the web &#8211; the <a href="http://sourceforge.net/apps/trac/pyisapie">homepage</a>, the <a href="http://pyisapie.sourceforge.net/blog/?page_id=13">install guide</a>, <a href="http://pyisapie.sourceforge.net/blog/?page_id=14">getting started</a>, the <a href="http://groups.google.com/group/pyisapie?hl=en">news group</a>, and the <a href="http://pyisapie.sourceforge.net/blog/?page_id=15">API</a>. It struck me a few times while trying to set up Python and IIS that the numbers of people that doing this could be incredibly low. The last Microsoft article I found <a href="http://support.microsoft.com/kb/276494">relates to IIS 5</a>..</p>
<h3 style="text-align: justify;">Installation on IIS 7</h3>
<p style="text-align: justify;">1. First make sure IIS is actually installed (Server Manager &gt;&gt; Roles &gt;&gt; Add Web Server IIS). Ensure the ISAPI Extensions and ISAPI filters are both checked.</p>
<p style="text-align: justify;">2. Download the latest <a href="http://sourceforge.net/projects/pyisapie/files/pyisapie/">PyISAPIe extension</a>. Make sure you get the correct version for your version of <a href="http://www.python.org/download/">Python</a>. In this example I am using Python 2.5.4 and PyISAPIe 1.1.0-rc4-Py2.5</p>
<p style="text-align: justify;">3. Where to put the files took a while to resolve..in the end it becomes apparent they can be placed anywhere! I got confused by my understanding of packages and by thinking I could test the Python scripts outside of a browser / IIS.</p>
<p style="text-align: justify;">In the end I created a new folder in C:\Python25 named PyISAPIe. I then copied into this the pyISAPIe.dll and HTTP folder.</p>
<p style="text-align: center;"><a href="http://geographika.co.uk/wp-content/uploads/2010/01/pyisapie1.png"><img class="aligncenter size-medium wp-image-274" style="border: 1px solid black;" title="pyisapie1" src="http://geographika.co.uk/wp-content/uploads/2010/01/pyisapie1-300x89.png" alt="" width="300" height="89" /></a></p>
<p style="text-align: justify;">4. Next you&#8217;ll need to set up the handler in IIS. I wanted all files that ended with the .py extension to be handled by the PyISAPIe DLL, so I did the following:</p>
<ul>
<li>under sites add a new application (I used the name /apps)</li>
<li>select the site, and then select &#8220;Handler Mappings&#8221;</li>
<li>right-click and select &#8220;Add Script Map&#8221;</li>
<li>set the &#8220;Request path&#8221; to *.py</li>
<li>set the &#8220;Executable&#8221; to &#8220;C:\Python25\PyISAPIe\PyISAPIe.dll</li>
<li>give the handler a relevant name such as &#8220;PyISAPIe&#8221;</li>
<li>in the Request Restrictions section, I set my handler to run only when a request contains a .py file that exists on  the server. I set it handle all verbs (GET and POST), and gave it Script access.</li>
<li style="text-align: justify;">select the &#8220;View Ordered List&#8221; in the Actions panel to see in what order handlers will be applied to a request. Make sure your .py handler has a higher priority than the default StaticFile handler, or it won&#8217;t get a chance to handle anything. The StaticFile handler may also <em>appear</em> to be handling requests if your custom handler fails as by default PyISAPIe moves to the next handler on an error.</li>
</ul>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/01/pyisapie2.png"><img class="aligncenter size-medium wp-image-275" style="border: 1px solid black;" title="pyisapie2" src="http://geographika.co.uk/wp-content/uploads/2010/01/pyisapie2-273x300.png" alt="" width="273" height="300" /></a><strong> </strong></p>
<p style="text-align: justify;"><strong>Important!</strong> If you are using a64-bit machine, you will need to create a new application pool, and set &#8220;Enable 32-bit Applications&#8221; to true. This is false by default. I found this <a href="http://www.hanselman.com/blog/32bitnessAnd64bitnessAndMigratingDasBlogOnIIS7AndASPNETUnderVista64.aspx">blog post</a> fairly early on describing the issue but, as if by magic, the true setting for my application pool had at some point been set back to false, leading to hours of being confronted by the near useless message:</p>
<pre style="text-align: justify;">HTTP Error 404.4 - Not Found
The resource you are looking for does not have a handler associated with it.</pre>
<h3 style="text-align: justify;">Testing</h3>
<p>The <a href="http://pyisapie.sourceforge.net/blog/?page_id=14">Getting Started Guide</a> should be followed, but I have a few gotchas, learnt the hard way. First save a Python script into your web application folder with a name such as hello.py with the test code from the guide:</p>
<pre>from Http import *
def Request():
    Header("Content-type: text/html")
    Write("Hello, World!")</pre>
<p style="text-align: justify;">Note this script <em>cannot</em> be run from a Python editor, you will get warnings such as:</p>
<pre style="text-align: justify;">ImportError: No module named Http</pre>
<p style="text-align: justify;">Even if the HTTP module is in the PYTHONPATH, or site-packages folder you will still receive an error such as that below, as the DLL needs to be loaded through ISAPI.</p>
<pre style="text-align: justify;">ImportError: No module named PyISAPIe</pre>
<p style="text-align: justify;">Pointing to <span style="text-decoration: underline;">http://localhost/apps/hello.py</span> should bring up the output of your Python script. Things get more confusing when you want to debug a more complicated script, as it appears nothing you change in your script has any effect. This is because once the script is run it stays loaded in memory, so no alterations are taken into account. To disable this (for testing only &#8211; change it back when everything is working correctly) modify the C:\Python25\PyISAPIe\Http\Isapi.py file.</p>
<pre style="text-align: justify;">def Request():
 Script = Env.SCRIPT_NAME
 Key = Name = '__'+md5(Script).hexdigest().upper()
 Handler = Handlers.get(Key, None)
 # the following line will ensure the script is reloaded on each request
 Handler = None

 if not Handler:
 try:
 Handlers[Key] = imp.load_source(Key, Env.SCRIPT_TRANSLATED).Request
 except Exception, Val:
 # trigger a passthrough to the next ISAPI handler -
 # ONLY WORKS FOR WILDCARD APPLICATION MAPPINGS
 #return True
 # or just fail, preferable for an application map
 # show errors in the browser
 raise ImportError, "[Loading '%s'] %s" % (Env.SCRIPT_TRANSLATED, str(Val))

 return Handlers[Key]()</pre>
<p style="text-align: justify;">Note the changes you make to the <span style="text-decoration: underline;"><strong><em>Isapi.py file itself</em></strong> </span> requires IIS to be restarted to take effect. The above modifications only cause the scripts in your www/apps directory to be refreshed on each request.</p>
<p style="text-align: justify;">If you always return <em>true</em> on any exception in the Isapi.py file (rather than throwing the error) then you may be met with the following message:</p>
<pre style="text-align: justify;">Possible recursion detected!
You probably did a passthrough with PyISAPIe configured as an application map instead of a wildcard map.</pre>
<p style="text-align: justify;">I *think* this is because the first handler failed to return a proper response, and so it goes to the next handler for the application. Just failing should provide you with a better error message from Python.</p>
<p style="text-align: justify;">If I&#8217;ve missed out any key steps in this summary feel free to add comments below and I&#8217;ll integrate them into the post. Last but not least many thanks to the developer of PyISAPIe &#8211; Phillip Sitbon.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/1G04Su0vx7M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/setting-up-python-on-iis7/feed</wfw:commentRss>
		<slash:comments>16</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/setting-up-python-on-iis7?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=setting-up-python-on-iis7</feedburner:origLink></item>
		<item>
		<title>Minifying the Mapfish Client on Windows</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/leVG06K6nz8/minifying-the-mapfish-client-on-windows</link>
		<comments>http://geographika.co.uk/minifying-the-mapfish-client-on-windows#comments</comments>
		<pubDate>Thu, 28 Jan 2010 07:00:01 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[mapfish]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[client-side]]></category>
		<category><![CDATA[minify]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=200</guid>
		<description><![CDATA[This page has 72 external Javascript scripts. Try combining them into one. My YSlow Firefox plug-in was telling me that I had included too may JavaScript files, and that they should be combined into a single-file, and minified. The default setup of Mapfish has a single script include (mfbase\mapfish\MapFish.js), but this script  automatically loads around <a href='http://geographika.co.uk/minifying-the-mapfish-client-on-windows'>[...]</a>]]></description>
			<content:encoded><![CDATA[<h3 style="text-align: justify;">This page has 72 external Javascript scripts.  Try combining them into one.</h3>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/01/minify.jpg"><img class="alignleft size-medium wp-image-195" title="minify" src="http://geographika.co.uk/wp-content/uploads/2010/01/minify-153x300.jpg" alt="" width="126" height="248" /></a>My <a href="http://developer.yahoo.com/yslow/">YSlow</a> Firefox plug-in was telling me that I had included too may JavaScript files, and that they should be combined into a single-file, and <a href="http://en.wikipedia.org/wiki/Minification_%28programming%29">minified</a>. The default setup of Mapfish has a single script include (mfbase\mapfish\MapFish.js), but this script  automatically loads around 40 further scripts.</p>
<p style="text-align: justify;">I tried a couple of unsuccessful attempts at copying and pasting various Mapfish JS files into an <a href="http://refresh-sf.com/yui/">online JavaScript compressor</a>. However when referencing the minified file I kept getting &#8220;undefined&#8221; errors from various Mapfish plugins and OpenLayer objects.</p>
<p style="text-align: justify;">Initially I was looking to download a ready-made &#8220;compiled&#8221; MapFish file, but was unable to find a version online. I have uploaded a<a href="../downloads/MapFish.zip"> zipped version</a> so if you want the file without going through the steps below you can download a copy. Note that if you have made any modifications to the MapFish files then these will not be available, and there are no guarantees it will work.</p>
<p style="text-align: justify;">There are instructions on creating a single-file Mapfish client build <a href="http://www.mapfish.org/trac/mapfish/browser/framework/client/branches/1.2/build/README.txt">on the Mapfish site</a>. This process uses <a href="http://projects.opengeo.org/jstools/wiki/jsbuild">JSBuild</a> which is part of <a href="http://github.com/whitmo/jstools">JSTools</a> &#8211; <em>&#8220;a collection of python scripts for packaging and efficiently serving javascript.&#8221;</em><br />
Unfortunately these instructions require a Linux operating system, and I&#8217;m using Windows. I eventually managed to &#8220;translate&#8221; these into Windows commands, and have documented the steps below.</p>
<h3 style="text-align: justify;"><span id="more-200"></span>Step 1 &#8211; Install Python for Windows</h3>
<p style="text-align: justify;">First of all if Python is not installed on your system, then get the MSI installer from the <a href="http://www.python.org/download/">Python site</a>. I used <a href="http://www.python.org/download/releases/2.5.4/">version 2.5.4</a>, so I&#8217;m not sure if the steps below work with later versions. Once it has been installed all .py extensions should be associated with the python interpreter. To check this you can run the following commands in a Windows command line prompt:</p>
<pre style="text-align: justify;">assoc.py
ftype Python.File</pre>
<h3 style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/01/py_file.png"><img class="aligncenter size-medium wp-image-201" title="py_file" src="http://geographika.co.uk/wp-content/uploads/2010/01/py_file-300x110.png" alt="" width="300" height="110" /></a></h3>
<h3 style="text-align: justify;">Step 2 &#8211; Create a Virtual Python Environment</h3>
<p style="text-align: justify;">This step creates an isolated Python environment for JSTools.  Using this &#8220;virtual&#8221; environment avoids using wrong script versions and references. The Mapfish instructions for Linux were as follows:</p>
<pre>$ wget 'http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.3.2.tar.gz'
$ tar xvzf virtualenv-1.3.2.tar.gz
$ python virtualenv-1.3.2/virtualenv.py env
$ source env/bin/activate
</pre>
<p>These rougly translate into Window&#8217;s speak as:</p>
<ul>
<li>Download the VirtualEnv installer from<a href="http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.3.2.tar.gz"> http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.3.2.tar.gz</a> (wget is simply a Linux program that handles the downloading of files).</li>
<li>Unzip the downloaded file (for example using <a href="http://www.7-zip.org/">7-zip</a> for Windows)</li>
<li>Run the following command in the Windows command prompt. Change the first parameter to point to the location of virtualenv.py you just downloaded, and the second to a folder where you want to create your virtual Python environment.
<pre>D:\Tools\Mapfish\virtualenv-1.3.2\virtualenv.py D:\Tools\Mapfish\VirtualPythonEnv</pre>
</li>
<li><a href="http://geographika.co.uk/wp-content/uploads/2010/01/py_file2.png"><img class="size-full wp-image-202 aligncenter" style="margin-bottom: 5px;" title="py_file2" src="http://geographika.co.uk/wp-content/uploads/2010/01/py_file2.png" alt="" width="532" height="158" /></a>Finally run the activate.bat file which should have been created by the above steps in D:\Tools\Mapfish\VirtualPythonEnv\Scripts\activate.bat</li>
</ul>
<h3>Step 3 &#8211; Install the JSTools</h3>
<p style="text-align: justify;">Again from the Windows command line, change your current directory to the newly created Scripts folder in your virtual environment setup.</p>
<pre>cd D:\Tools\Mapfish\VirtualPythonEnv\Scripts\
</pre>
<p>Next run the following command (again from the Windows command line):</p>
<pre>easy_install.exe -i http://dev.camptocamp.com/packages/mapfish/all/index JSTools</pre>
<p><a href="http://geographika.co.uk/wp-content/uploads/2010/01/install_easyscript.png"><img class="aligncenter size-full wp-image-203" title="install_easyscript" src="http://geographika.co.uk/wp-content/uploads/2010/01/install_easyscript.png" alt="" width="562" height="258" /></a></p>
<p style="text-align: justify;">Trying to install the latest version of JSTools from http://github.com/whitmo/jstools/tarball/master caused errors (possibly due to Windows default download paths), but the rest of the steps worked fine with the JSTools available from the Mapfish (CamptoCamp) link used above.</p>
<h3 style="text-align: justify;">Step 4 &#8211; Go Forth and Minify</h3>
<p style="text-align: justify;">The final step is to create the minified JavaScript itself. The Mapfish client download contains a configuration file to tell JSBuild which files to include in the single file script. It was at this stage I realised it may have been possible to manually combine these files in the correct order and run the online compressor, but now everything else was in place it was as well to use JSBuild.</p>
<p style="text-align: justify;">First of all I modified the first few lines of the mfbase\openlayers\build\full.cfg file to point to the JavaScript files on my system. This may not have been necessary depending on where JSTools was run from, but this way worked!</p>
<pre style="text-align: justify;">[MapFish.js]
root =
 D:/Tools/Mapfish/mapfish-client-1.2/mfbase/openlayers/lib
 D:/Tools/Mapfish/mapfish-client-1.2/mfbase/mapfish
 D:/Tools/Mapfish/mapfish-client-1.2/mfbase/geoext/lib
first =
 OpenLayers/SingleFile.js
 OpenLayers.js
 ...rest of the file remains the same
</pre>
<p style="text-align: justify;">Next I ran the following command from Windows (making sure my current directory contained the jsbuild.exe). The -o parameter is the folder where you wish the single file to be created, and the second parameter points to the configuration file listing the JavaScript files.</p>
<pre>jsbuild -o D:\Tools\Mapfish\ D:\Tools\Mapfish\mapfish-client-1.2\build\full.cfg</pre>
<p><a href="http://geographika.co.uk/wp-content/uploads/2010/01/done.png"><img class="aligncenter size-full wp-image-204" title="done" src="http://geographika.co.uk/wp-content/uploads/2010/01/done.png" alt="" width="558" height="116" /></a></p>
<p style="text-align: justify;">A new MapFish.js was created!</p>
<p style="text-align: justify;">I was then able to modify the .cfg file further to add in and minify my own application JavaScript files.</p>
<h3>Step 5 &#8211; Test in Web Application</h3>
<p style="text-align: justify;">The previous reference to Mapfish could now be pointed to the newly created MapFish.js file:</p>
<pre style="text-align: justify;">&lt;script type="text/javascript" src="js/MapFish.js"&gt;&lt;/script&gt;
</pre>
<p style="text-align: justify;">Although the file is now ~1MB it is smaller than the individual files combined, and it requires less server requests which improves page loading times. Most web servers (including IIS and Apache, but <a href="http://support.microsoft.com/kb/308168">not IIS running on Windows XP</a>) allow gzip compression which will reduce this file to around 250KB.</p>
<p style="text-align: justify;">If you encounter any problems or steps I&#8217;ve missed then please let me know!</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/leVG06K6nz8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/minifying-the-mapfish-client-on-windows/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/minifying-the-mapfish-client-on-windows?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=minifying-the-mapfish-client-on-windows</feedburner:origLink></item>
		<item>
		<title>Automated WMS Reports</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/wUVFDbeD0NI/automated-wms-reports</link>
		<comments>http://geographika.co.uk/automated-wms-reports#comments</comments>
		<pubDate>Tue, 26 Jan 2010 19:11:57 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[wms]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[getcapabilities]]></category>
		<category><![CDATA[mapserver]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XSL]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=231</guid>
		<description><![CDATA[This post details how the WMS GetCapabilities request can be used to create an automated report listing all the map layers available from a WMS server. The final sample page can be seen here. The GetCapabilities Request Web Mapping Services (WMS) is an open standard that all major GIS vendors implement in their server software <a href='http://geographika.co.uk/automated-wms-reports'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">This post details how the WMS GetCapabilities request can be used to create an automated report listing all the map layers available from a WMS server. The final sample page can be <a href="http://geographika.co.uk/samples/GetCapabilities.html">seen here</a>.</p>
<p style="text-align: justify;"><a href="http://geographika.co.uk/samples/GetCapabilities.xml"><img class="aligncenter size-full wp-image-235" title="report" src="http://geographika.co.uk/wp-content/uploads/2010/01/report1.png" alt="" width="513" height="157" /></a></p>
<h3 style="text-align: justify;">The GetCapabilities Request</h3>
<p style="text-align: justify;"><a href="http://geographika.co.uk/samples/GetCapabilities.html"><img class="alignleft size-medium wp-image-232" style="margin: 2px;" title="report2" src="http://geographika.co.uk/wp-content/uploads/2010/01/report2-300x254.png" alt="" width="305" height="257" /></a><em></em></p>
<p style="text-align: justify;">Web Mapping Services (<a href="http://www.opengeospatial.org/standards/wms">WMS</a>) is an open standard that all major GIS vendors implement in their server software (for example see the <a href="http://webhelp.esri.com/arcims/9.2/general/mergedProjects/wms_connect/wms_connector/get_capabilities.htm">ESRI documentation</a>). As a result applications built on these services are able to easily switch from one software package to another &#8211; allowing separation of code that allows for easier maintenance and reuse.</p>
<p style="text-align: justify;">The GetCapabilities is one of three requests in the WMS specification. It <em>&#8220;returns service-level metadata, which is a description of the service&#8217;s information content and acceptable request parameters.&#8221; </em></p>
<p style="text-align: justify;">After<a href="http://geographika.co.uk/?p=225"> eventually being able to see</a> the results of a GetCapabilities request my aim was to generate a report listing the available map layers, and to check I had enetered all the required metadata. I had a look on the web to see if there were any stylesheets that would nicely format the data.</p>
<p style="text-align: justify;"><span id="more-231"></span>The <a href="http://www.easywms.com/easywms/?q=en/node/199">easywms.com site</a> has an example on how to build a WMS client from GetCapabilities using <a href="http://www.w3schools.com/xsl/">XSL</a> but I was unable to get the sample working with my GetCapabilities output. XSL is a stylesheet language for XML documents, in much the same way that CSS is used to format HTML. I&#8217;ve worked with XSL a little before so decided to write some code myself after not being able to find an existing example.</p>
<h3 style="text-align: justify;">Adding Metadata to the WMS Server</h3>
<p style="text-align: justify;">In order for the GetCapabilities request to return data, it has to be entered in the first place. Each WMS server will be configured in different ways. In this example I am using <a href="http://mapserver.org/">MapServer</a>. The documentation for the WMS Server can be <a href="http://mapserver.org/ogc/wms_server.html">found here</a>.</p>
<p style="text-align: justify;">WMS services are configured using MAP files. Metadata can bet set for both the overall map and for each LAYER object in the map.Further documentation can be found <a href="http://mapserver.org/ogc/wms_server.html#setup-a-mapfile-for-your-wms">here</a>. An example of layer metadata would look as follows:</p>
<pre>LAYER
   NAME 'MyLayerName'
   TYPE LINE
   METADATA
     'wms_title' 'My Layer Title'
   END
   ...
</pre>
<h3 style="text-align: justify;">Using the GetCapabilities Request</h3>
<p style="text-align: justify;">To test the MAP file is set up correctly as a WMS Service follow the steps <a href="http://mapserver.org/ogc/wms_server.html#validate-the-capabilities-metadata">here</a>. You can paste a URL such as the following:</p>
<pre>http://my.host.com/cgi-bin/mapserv?map=mywms.map&amp;SERVICE=WMS&amp;VERSION=1.1.1&amp;REQUEST=GetCapabilities
</pre>
<p style="text-align: justify;">The map=mywms.map parameter is specific to MapServer, but the rest of the parameters are part of the WMS standards. If your browser keeps trying to download the server response, try sending an incorrect WMS version as explained in <a href="http://geographika.co.uk/?p=225">my previous post</a>. The MapServer site has a <a href="http://www2.dmsolutions.ca/cgi-bin/mswms_gmap?SERVICE=WMS&amp;VERSION=1.0.3&amp;REQUEST=GetCapabilities">live example</a> of a WMS service you can use for comparison with your own.</p>
<h3 style="text-align: justify;">Formatting the GetCapabilities Response</h3>
<p style="text-align: justify;">The server responds to a valid GetCapabilities by sending back XML. This XML can be formatted in the broswer to produce a report using an XSL file. My <a href="http://geographika.co.uk/samples/GetCapabilities.html"> sample page</a> consists of the following components:</p>
<ul>
<li><a href="http://geographika.co.uk/samples/GetCapabilities.xsl">GetCapabilities.xsl </a>- an XSL file which transforms a GetCapabilities XML document into HTML</li>
<li><a href="http://geographika.co.uk/samples/GetCapabilities.js">GetCapabilities.js</a> &#8211; a JavaScript file which can be used to apply the XSL to the XML file. The XML can either be a static saved XML file, or a URL that returns XML. For security reasons, modern browsers do not allow access across domains, so this must be stored on the WMS server. The JavasScript was taken from the <a href="http://www.w3schools.com/XML/xml_parser.asp">W3 Schools</a> site.</li>
<li><a href="http://geographika.co.uk/samples/GetCapabilities.css">GetCapabilities.css</a> &#8211; a stylesheet that applies colours and layout to the HTML (with thanks to <a href="http://veerle.duoh.com/blog/comments/a_css_styled_table_version_2/">Verlees&#8217;s blog post</a>).</li>
<li><a href="http://geographika.co.uk/samples/GetCapabilities.html">GetCapabilities.html</a> &#8211; an HTML file that loads the JavaScript and displays the report.</li>
</ul>
<p style="text-align: justify;">The XSL stylesheet can also be applied directly to the XML by including the following lines at the top of the XML file:</p>
<pre style="text-align: justify;">&lt;?xml version="1.0" encoding="ISO-8859-1" standalone="no"?&gt;
&lt;?xml-stylesheet type="text/xsl" href="GetCapabilities.xsl"?&gt;
</pre>
<p style="text-align: justify;">However this is not an option if the XML is returned dynamically (apart from if you start modifying your WMS server code).</p>
<h3>Future Improvements</h3>
<p>The current XSL stylesheet is fairly basic, but does provide a quick way to list your layers, and to check that all the required WMS metadata items have been filled in. Possible additions to the XSL sheet include:</p>
<ul>
<li>highlighting required metdata parameters that are missing</li>
<li>collapsing legend images, or allow a trigger to load them (for large legends, and to improve loading speeds)</li>
<li>allowing a link to create a sample tile of the data, or adding this in automatically &#8211; it would be useful to check how features are rendered that services are running correctly</li>
<li>sorting of table columns</li>
<li>linking to metadata documents</li>
</ul>
<p>Any thoughts and feedback appreciated.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/wUVFDbeD0NI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/automated-wms-reports/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/automated-wms-reports?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=automated-wms-reports</feedburner:origLink></item>
		<item>
		<title>Web Mapping Services &amp; Security</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/A2pUcj2B2VY/web-mapping-services-security</link>
		<comments>http://geographika.co.uk/web-mapping-services-security#comments</comments>
		<pubDate>Wed, 20 Jan 2010 05:03:43 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[mapserver]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[wms]]></category>
		<category><![CDATA[wms mapserver security ogc]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=212</guid>
		<description><![CDATA[For the majority of public GIS systems I&#8217;ve worked on all the data in a database is available to users via the mapping interface. If someone wanted to hack in and &#8220;steal&#8221; data the only concern would be the bandwidth they took up. Security for these systems is fairly low down on the list of <a href='http://geographika.co.uk/web-mapping-services-security'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/01/bouncer.jpg"><img class="alignleft size-full wp-image-213" title="bouncer" src="http://geographika.co.uk/wp-content/uploads/2010/01/bouncer.jpg" alt="" width="247" height="349" /></a>For the majority of public GIS systems I&#8217;ve worked on all the data in a database is available to users via the mapping interface. If someone wanted to hack in and &#8220;steal&#8221; data the only concern would be the bandwidth they took up. Security for these systems is fairly low down on the list of priorities, if it&#8217;s on the list at all.</p>
<p style="text-align: justify;">GIS systems with organisational data are often only accessible (in theory) through an Intranet, so if the network is well protected then so isthe GIS.</p>
<p style="text-align: justify;">There have only been a few mapping systems I&#8217;ve worked on where there is a mix of public data and datasets with restrictive access in the same database. The location of rare bird species (people will <a href="http://news.bbc.co.uk/2/hi/uk_news/1545005.stm">go to some lengths</a> for a rare egg) and hallucinogenic <a href="http://www.combat-diaries.co.uk/diary30/magic%20mushrooms.jpg">mushrooms</a> in a <a href="http://www.biodiversityireland.ie/">Biodiversity GIS</a> being an example.</p>
<p style="text-align: justify;">I&#8217;m currenty designing a <a href="http://mapserver.org/">MapServer</a> system that will serve out <a href="http://en.wikipedia.org/wiki/Web_Map_Service">WMS</a> layers to the public, and a few which are limited to certain IP address ranges. WMS and security was something I had never previously investigated. The rest of this post outlines the current situation, and an attempt to restrict WMS access on my server.</p>
<p style="text-align: justify;"><span id="more-212"></span></p>
<h3 style="text-align: justify;">WMS and the HTTP Protocol</h3>
<p style="text-align: justify;">WMS servers interact with their clients via the <a href="http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol">HTTP protocol</a>, which uses plain text. For example a client (the user&#8217;s browser) would send a &#8220;GET&#8221; request (along with a number of parameters and headers) such as:</p>
<pre> GET mapserv.exe?map=/ms4w/apps/... HTTP/1.1
 Host: www.example.com
</pre>
<p style="text-align: justify;">The server would then send a number of response headers as plain text and, for a valid WMS request, hopefully an image.</p>
<p style="text-align: justify;"><em>&#8220;The rationale behind this is that text protocols allows you to see what&#8217;s going on on the network by just dumping everything that goes through. You don&#8217;t need a specialized analyzer as you need for TCP/IP. This makes it easier to debug and easier to maintain.&#8221; &#8211; </em><a title="http://stackoverflow.com/questions/393407/why-http-protocol-is-designed-in-plain-text-way" href="http://">PolyThinker</a></p>
<p style="text-align: justify;">Clearly anything sent between two computers in plain text is never going to be very secure. The <a href="http://www.opengeospatial.org/">OGC </a>announced via a <a href="http://www.opengeospatial.org/pressroom/pressreleases/1073">press release</a> last August, that they would begin an &#8220;Authentication Interoperability Experiment&#8221; on the  2nd of October, 2009. This experiment <em>&#8220;will test standard ways of transferring authentication information between OGC clients and OGC services using existing mechanisms such as <a href="http://en.wikipedia.org/wiki/HTTP_Authentication">HTTP Authentication</a>, <a href="http://en.wikipedia.org/wiki/Http_cookies">HTTP Cookies</a>, <a href="http://en.wikipedia.org/wiki/Transport_Layer_Security">SSL</a>/<a href="http://en.wikipedia.org/wiki/X.509">X509</a>, <a href="http://en.wikipedia.org/wiki/Security_Assertion_Markup_Language">SAML</a>, <a href="http://en.wikipedia.org/wiki/Shibboleth_%28Internet2%29">Shibboleth</a>, <a href="http://en.wikipedia.org/wiki/OpenID">OpenID </a>and <a href="http://en.wikipedia.org/wiki/WS-Security">WS-Security</a>.&#8221;</em></p>
<p style="text-align: justify;">The experiments participants include the <a href="https://www1.nga.mi">National Geospatial-Intelligence Agency</a>, and the <a href="http://www.thecarbonproject.com/">Carbon Project</a> and its observers include <a href="http://www.esri.com">ESRI</a>. Their presence hopefully would mean any resulting decision would be implemented in their software, and lead to the widespread acceptance of a standard. The experiment is led by Jeff Harrison of <a href="http://www.cubewerx.com/">www.cubewerx.com</a>, who&#8217;s website states:</p>
<p style="text-align: center;"><em>&#8220;Concerned about standards? So are we. In fact we literally wrote the book on many of them&#8221;</em></p>
<p style="text-align: justify;">There don&#8217;t seem to have been any updates since then, but a good place to keep up with any developments in WMS is through the OGC WMS <a href="http://lists.eogeo.org/mailman/listinfo/wms-dev">mailing list</a> &#8211; a <em>&#8220;discussion list for people implementing and deploying instances of the OGC Web Map Server Interface specification</em>&#8220;, and the experiments <a href="http://www.opengeospatial.org/projects/initiatives/authie">web page</a>.</p>
<h3 style="text-align: justify;">Securing MapServer in Apache</h3>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/01/feather.gif"><img class="alignleft size-full wp-image-214" title="feather" src="http://geographika.co.uk/wp-content/uploads/2010/01/feather.gif" alt="" width="167" height="47" /></a>In the meantime I was still looking for a way to limit access to my WMS services.  I&#8217;m using MapServer for Windows (<a href="http://www.maptools.org/ms4w/">ms4w</a>) which installs MapServer and Apache on a Windows machine. Apache (and IIS) can be used to limit access to certain files based on an IP address which is exactly what I require.</p>
<p style="text-align: justify;">Unfortunately MapServer runs through <a href="http://en.wikipedia.org/wiki/Common_Gateway_Interface">CGI</a> which means limiting access to certain .MAP files was impossible. MapServer uses the SYSTEM account in Windows which means it has the same access rights no matter what IP address is used to start the process.</p>
<p style="text-align: justify;">There are ways to run CGI processes as different users (<a href="http://httpd.apache.org/docs/1.3/suexec.html">suExec</a> seems to be frequently mentioned), but examples on the web all seem to use Linux, and I&#8217;d imagine there would need to be a pre-processing script checking IPs to decide which user account should start the MapServer process.</p>
<p style="text-align: justify;">In the end it seemed the simplest option was to have two instance of ms4w on two different servers (the advantages of several virtual servers on one physical server are becoming clearer and clearer). I could then limit access to the CGI program on the server with the more restricted Map files in the following way:</p>
<p style="text-align: justify;">Open C:\ms4w\Apache\conf\httpd.conf and search for the following text:</p>
<pre style="text-align: justify;">#
# Configure MS4W locations and directories
#
&lt;Location "/cgi-bin"&gt;
 Options None
 Order allow,deny
 Allow from all
&lt;/Location&gt;
</pre>
<p>The edit these settings to limit the access to the CGI folder to IP ranges, addresses, domains etc. For further details see the <a href="http://httpd.apache.org/docs/2.2/mod/core.html#directory">Apache documentation</a> and this <a href="http://www.cyberciti.biz/faq/apache-restrict-access-based-on-ip-address-to-selected-directories/">blog post</a>. In the example below only the computer with the IP 192.168.1.10 can access MapServer through CGI:</p>
<pre style="text-align: justify;">&lt;Location "/cgi-bin"&gt;
 Options None
 Order allow,deny
 Allow from 192.168.1.10
&lt;/Location&gt;</pre>
<p style="text-align: justify;">After every change you will need to restart the Apache service to activate your changes. The same settings can also be applied to FastCGI. To see which IPs are accessing your MapServer look in C:\ms4w\Apache\logs\access.log. If you have limited access then IPs without permission should receive a HTTP <a href="http://en.wikipedia.org/wiki/HTTP_403">403 </a>error&gt; These are also recorded in the access.log file.</p>
<p style="text-align: justify;">Ideally I&#8217;d like to be able to set access to each MAP file or directory by IP range on the same MapServer, so if anyone has achieved this with ms4w please let me know!</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/A2pUcj2B2VY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/web-mapping-services-security/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/web-mapping-services-security?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=web-mapping-services-security</feedburner:origLink></item>
		<item>
		<title>Running Python through Apache</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/gjG-2M62DcQ/running-python-through-apache</link>
		<comments>http://geographika.co.uk/running-python-through-apache#comments</comments>
		<pubDate>Mon, 18 Jan 2010 18:26:26 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[mapserver]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[gdal]]></category>
		<category><![CDATA[mod_python]]></category>
		<category><![CDATA[tilecache]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=245</guid>
		<description><![CDATA[I&#8217;m trying (and having) to start using Python more and more due to its ubiquity in the OpenSource GIS world. There are a number of add-ons and libraries for MapServer that require Python to function properly and/or quickly. It is also widely used for scripting both MapServer objects and for raster manipulation using GDAL. I <a href='http://geographika.co.uk/running-python-through-apache'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">I&#8217;m trying (and having) to start using Python more and more due to its ubiquity in the OpenSource GIS world. There are a number of add-ons and libraries for <a href="http://mapserver.org/">MapServer</a> that require Python to function properly and/or quickly. It is also widely used for scripting both <a href="http://mapserver.org/mapscript/python.html">MapServer objects</a> and for raster manipulation <a href="http://pypi.python.org/pypi/GDAL/">using GDAL</a>. I initially set up Python under Apache to run the <a href="http://tilecache.org">Tilecache</a> tile server.</p>
<p style="text-align: justify;">According to the <a href="http://www.modpython.org/">ModPython</a> site &#8211; <em>&#8220;Python will run many times faster than traditional CGI and will have access to advanced features such as ability to retain database connections.&#8221;</em></p>
<p style="text-align: justify;"><em><a href="http://geographika.co.uk/wp-content/uploads/2010/01/mp_long.gif"><img class="aligncenter size-medium wp-image-247" title="mp_long" src="http://geographika.co.uk/wp-content/uploads/2010/01/mp_long-300x76.gif" alt="" width="300" height="76" /></a></em>Mod_python is an <a href="http://httpd.apache.org/">Apache</a> module that embeds the  <a href="http://www.python.org/">Python</a> interpreter within the server, and can be downloaded from <a href="http://httpd.apache.org/modules/python-download.cgi">their site</a>. There are versions for both Unix and Windows, which makes it ideal for <a href="http://www.maptools.org/ms4w/index.phtml?page=home.html">MapServer for Windows</a> (MS4W). Ironically after saying that using Python for web applications is many times faster than CGI, the ModPython download page uses CGI..</p>
<p style="text-align: justify;"><span id="more-245"></span>There are a number of <a href="http://mir2.ovh.net/ftp.apache.org/dist/httpd/modpython/win/3.3.1/">Windows versions available</a>, depending on your version of the Apache server. Make sure you get the right one &#8211; at the time of writing I am using MS4W v2.3.1, which includes Apache HTTP Server version 2.2.11. Your version of Python also makes a difference &#8211; I&#8217;m using 2.5.4 so I downloaded <a href="http://mir2.ovh.net/ftp.apache.org/dist/httpd/modpython/win/3.3.1/mod_python-3.3.1.win32-py2.5-Apache2.2.exe">mod_python-3.3.1.win32-py2.5-Apache2.2.exe</a>. My reason for not yet having upgraded to Python 2.6 or 3 was because all the TileCache documentation refers to <a href="http://tilecache.org/docs/README">Python 2.5</a>.</p>
<p style="text-align: justify;">The Mod_python installer allows you to choose your Python and Apache directories which in a standard MS4W installation would be C:\Python25 and C:\ms4w\Apache respectively.</p>
<p style="text-align: justify;">For the rest of the configuration steps <a href="http://www.modpython.org/live/current/doc-html/inst-testing.html">follow the instructions here</a>. If you are using MapServer for Windows then a brief summary of these steps is as follows:</p>
<p style="text-align: left;">1. Open your C:\ms4w\Apache\conf\httpd.conf and add the lines below. A C:\ms4w\Apache\modules\mod_python.so file should have been created during the installation of Mod_python.</p>
<pre>    LoadModule python_module modules/mod_python.so
    &lt;Directory "C:/ms4w/Apache/htdocs/test"&gt;
        AddHandler mod_python .py
        PythonHandler mptest
        PythonDebug On
    &lt;/Directory&gt;
</pre>
<p style="text-align: justify;">2. Add the following code to a mptest.py file in a C:\ms4w\Apache\htdocs\test folder (check the spaces/tabs for the script are correct using the Python editor IDLE):</p>
<pre style="text-align: justify;">from mod_python import apache

def handler(req):
 req.content_type = 'text/plain'
 req.write("Hello World!")
 return apache.OK</pre>
<p style="text-align: justify;">3. Restart your Apache server service to apply the changes to the configuration. You can do this through the GUI or using:</p>
<pre style="text-align: justify;">C:\ms4w\Apache\bin\httpd.exe -k start -n "ApacheMS4WWebServer"</pre>
<p style="text-align: justify;">4. Go to <a href="http://localhost/test/mptest.py">http://localhost/test/mptest.py</a> in your browser (assuming a default HTTP port of 80) and you should see the familiar &#8220;Hello World&#8221; message. If not..see the <a href="http://www.modpython.org/live/current/doc-html/inst-trouble.html">troubleshooting page</a>. Note that with this configuration <em>all</em> links ending in .py will be handled with by the same mptest.py script. So if you are editing your Python script and wondering why nothing changes (..said from experience), check your httpd.conf.</p>
<p style="text-align: justify;">You should also be able to see a summary of your system at <a href="http://localhost/mpinfo">http://localhost/mpinfo</a>. Setting up TileServer is a blog post in itself and I hope to document that soon.</p>
<p style="text-align: justify;">Finally, if in a fit of frustration with non-running Python scripts you uninstall everything mentioning the name Python from your machine, you are likely to find the error message below in your Apache log files:</p>
<pre>[Mon Jan 18 12:28:02 2010] [error] make_obcallback: could not import mod_python.apache.\n
ImportError: No module named mod_python.apache
[Mon Jan 18 12:28:02 2010] [error] make_obcallback: Python path being used "['...
[Mon Jan 18 12:28:02 2010] [error] [client 172.30.99.54] python_handler: Can't get/create interpreter.
</pre>
<p>A reinstall of the Windows Set Up package should fix this.</p>
<p style="text-align: center;"><a href="../wp-content/uploads/2010/01/python_mod.png"><img class="aligncenter" title="python_mod" src="../wp-content/uploads/2010/01/python_mod.png" alt="" width="172" height="47" /></a></p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/gjG-2M62DcQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/running-python-through-apache/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/running-python-through-apache?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=running-python-through-apache</feedburner:origLink></item>
		<item>
		<title>WMS GetCapabilities</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/tM_0olkrCSs/wms-get-capabilities</link>
		<comments>http://geographika.co.uk/wms-get-capabilities#comments</comments>
		<pubDate>Sat, 16 Jan 2010 13:38:55 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[mapserver]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[wms]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[getcapabilities]]></category>
		<category><![CDATA[headers]]></category>
		<category><![CDATA[http]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=225</guid>
		<description><![CDATA[Yes, I&#8217;d like to see the map layers and capabilities available from my MapServer MAP file, and no I don&#8217;t want to download mapserv.exe.. Messing with Headers I had the same problem with both Firefox and Internet Explorer 7 each time I issues a request such as: http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/my.map&#38;SERVICE=WMS&#38;VERSION=1.1.1&#38;REQUEST=GetCapabilities The browser tried to download mapserv.exe. The <a href='http://geographika.co.uk/wms-get-capabilities'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Yes, I&#8217;d like to see the map layers and capabilities available from my <a href="http://mapserver.org/">MapServer</a> MAP file, and no I don&#8217;t want to download mapserv.exe..</p>
<h3 style="text-align: justify;">Messing with Headers</h3>
<p style="text-align: justify;">I had the same problem with both Firefox and Internet Explorer 7 each time I issues a request such as:</p>
<pre>http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/my.map&amp;SERVICE=WMS&amp;VERSION=1.1.1&amp;REQUEST=GetCapabilities</pre>
<p style="text-align: justify;">The browser tried to download mapserv.exe. The &#8220;exe&#8221; did actually contain the GetCapabilities XML, but it is very annoying to have to manually open it in another program each time.</p>
<p style="text-align: justify;">This is a <a href="http://mapserver.org/faq.html#when-i-do-a-getcapabilities-why-does-my-browser-want-to-download-mapserv-exe-mapserv">FAQ on the MapServer site</a> which suggested that a program needs to be manually associated with the <a href="http://en.wikipedia.org/wiki/MIME">MIME</a> type returned by the requests &#8211; application/vnd.ogc.wms_xml.</p>
<p style="text-align: justify;"><span id="more-225"></span>In FireFox I went about associating an application with the MIME type application/vnd.ogc.wms_xml, following the  steps outlined <a href="http://support.mozilla.com/en-US/kb/Options+window+-+Applications+panel?style_mode=inproduct">here</a>. After a restart of FireFox nothing had changed.</p>
<p style="text-align: center;"><a href="../wp-content/uploads/2010/01/getcapabilites.png"><img class="aligncenter" title="getcapabilites" src="../wp-content/uploads/2010/01/getcapabilites-300x148.png" alt="" width="300" height="148" /></a></p>
<p style="text-align: justify;">
<p style="text-align: justify;">I used <a href="http://getfirebug.com/">FireBug</a> to check that the request was returning the correct MIME type. As shown in the image below the server was correctly returning the correct Content-Type.</p>
<p style="text-align: center;"><a href="../wp-content/uploads/2010/01/getcapabilites_response.png"><img class="aligncenter" title="getcapabilites_response" src="../wp-content/uploads/2010/01/getcapabilites_response-300x145.png" alt="" width="300" height="145" /></a></p>
<p style="text-align: justify;">I then checked the request parameters sent from my browser to the server. These included:</p>
<pre style="text-align: justify;">Accept    text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language    en-US,en;q=0.7...
Accept-Encoding    gzip,deflate</pre>
<p style="text-align: justify;">I then thought the reason for trying to download the content was due to my browser not &#8220;accepting&#8221; the application/vnd.ogc.wms_xml type. I used another<a href="https://addons.mozilla.org/en-US/firefox/addon/967"> FireFox Add-In</a> to modify my request headers to accept the content type (and &#8220;chunked&#8221; encoding just for good measure..).</p>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/01/mod_headers.png"><img class="aligncenter size-medium wp-image-224" title="mod_headers" src="http://geographika.co.uk/wp-content/uploads/2010/01/mod_headers-300x57.png" alt="" width="300" height="57" /></a></p>
<p style="text-align: justify;">The headers sent with my request now looked as follows:</p>
<pre style="text-align: justify;">Accept    application/vnd.ogc.wms_xml,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language    en-US,en;q=0.7,chrome://global/locale/intl.properties;q=0.3
Accept-Encoding    chunked,gzip,deflate</pre>
<h3 style="text-align: justify;">A Hackish Solution</h3>
<p style="text-align: justify;">All good &#8220;fun&#8221; but I was still met with the same dialog box to download the content. FireBug still reported the response data as <em>&#8220;The resource from this URL is not text.&#8221; </em></p>
<p style="text-align: justify;"><em> </em>This <a href="http://lists.osgeo.org/pipermail/mapserver-users/2007-April/023264.html">post</a> hints that the content type defined in the WMS specs was a mistake, and that for the new WMS specifications the content type will be set to text/html by default. It also suggested that adding a &amp;EXECPTIONS=text/html parameter to the request string could override the content type, but this (I believe) is only where an exceptions actually occur s on the server.</p>
<p style="text-align: justify;">I stumbled across a solution by accident. While entering a request string I put an incorrect version number in the VERSION parameter:</p>
<pre>http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/my.map&amp;SERVICE=WMS&amp;VERSION=1.0.3&amp;REQUEST=GetCapabilities</pre>
<p style="text-align: justify;">The response came back in an <code>text/xml</code> format that was displayed in the browser! Whilst not very satisfactory, it was nicer than having to manually open up fake .exe files. If anyone can shed any light on why this is happening please let me know.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/tM_0olkrCSs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/wms-get-capabilities/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/wms-get-capabilities?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=wms-get-capabilities</feedburner:origLink></item>
		<item>
		<title>Mapfish JavaScript Toolbox</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/uYDv-VWPG48/mapfish-javascript-toolbox</link>
		<comments>http://geographika.co.uk/mapfish-javascript-toolbox#comments</comments>
		<pubDate>Thu, 14 Jan 2010 10:16:44 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[mapfish]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=194</guid>
		<description><![CDATA[Mapfish is an open-source web mapping framework built using the Pylons Python web framework for &#8220;creating web services that allow querying and editing of geographic objects.&#8221; However the server-side functionality of the system I am currently working on is already handled by SQL Server 2008 Spatial and MapServer. What interested me more was that Mapfish <a href='http://geographika.co.uk/mapfish-javascript-toolbox'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2010/01/mapfish_white.png"><img class="alignleft size-thumbnail wp-image-196" title="mapfish_white" src="http://geographika.co.uk/wp-content/uploads/2010/01/mapfish_white-150x96.png" alt="" width="150" height="96" /></a>Mapfish is an open-source web mapping framework built using the <a href="http://pylonshq.com/">Pylons</a> Python web framework for <em>&#8220;creating web services that allow querying and editing of geographic objects.&#8221;</em> However the server-side functionality of the system I am currently working on is already handled by SQL Server 2008 Spatial and MapServer. What interested me more was that Mapfish <em>&#8220;provides a complete RIA-oriented (Rich Internet Application) JavaScript toolbox.&#8221;</em></p>
<p style="text-align: justify;">A couple of examples of the front-end interface can be found at the <a href="http://www.inspire-geoportal.eu/index.cfm/pageid/341">EU Inspire Geoportal</a>, and the <a href="http://mamu.littleearth.ca/">Marbled Murrelet Mashup</a>. The Mapfish client combines three frameworks into one <a href="http://openlayers.org/">OpenLayers</a>, <a href="http://geoext.org/">GeoExt</a>, and <a href="http://www.extjs.com/">ExtJS</a>.</p>
<p style="text-align: justify;">The client JavaScript is available via downloaded from <a href="http://www.mapfish.org/downloads/">http://www.mapfish.org/downloads/</a>. At the time of writing <a href="http://www.mapfish.org/downloads/mapfish-client-1.2.tar.gz">mapfish-client-1.2.tar.gz</a> was the most recent version. The files can be unzipped using the open-source program <a href="http://www.7-zip.org/">7-zip</a> that handles both gzip and &#8220;tar ball&#8221; zip files. Once unzipped there are a number of samples that can be run and edited locally (look for the examples/map/index.html page). This alone is a huge step forward in creating a basic online mapping system that rivals proprietary offerings.</p>
<p style="text-align: justify;">Further details on using the toolkit can be found at the <a href="http://www.mapfish.org/doc/tutorials/introduction/introduction.html?highlight=demo#mapfish-client">Mapfish tutorial</a> and <a href="http://www.source3.com/mgiswiki/tiki-index.php?page=Customizing+the+sample+map">this blog tutorial</a>. I&#8217;ll also be writing some more technical posts, specifically around using Mapfish with Windows, as most of the current documentation assumes people are running Linux.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/uYDv-VWPG48" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/mapfish-javascript-toolbox/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/mapfish-javascript-toolbox?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=mapfish-javascript-toolbox</feedburner:origLink></item>
		<item>
		<title>Map Server Expression Errors</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/Bx45vPQPEYA/map-server-expression-errors</link>
		<comments>http://geographika.co.uk/map-server-expression-errors#comments</comments>
		<pubDate>Thu, 07 Jan 2010 19:18:12 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[bugs]]></category>
		<category><![CDATA[mapserver]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=188</guid>
		<description><![CDATA[Errors&#8230; After turning on logging to diagnose an issue with MapServer I found a more worrying error, that was causing the log file to fill up at a rate of about 2MB a minute! I was reusing a legend for five or six datasets, and it was causing the following debug notes: [Thu Jan 07 <a href='http://geographika.co.uk/map-server-expression-errors'>[...]</a>]]></description>
			<content:encoded><![CDATA[<h3><img class="alignleft size-full wp-image-186" title="Db_null" src="http://geographika.co.uk/wp-content/uploads/2010/01/Db_null.png" alt="" width="128" height="128" />Errors&#8230;</h3>
<p style="text-align: justify;">After turning on logging to diagnose an issue with MapServer I found a more worrying error, that was causing the log file to fill up at a rate of about 2MB a minute! I was reusing a legend for five or six datasets, and it was causing the following debug notes:</p>
<pre>[Thu Jan 07 15:28:21 2010].629000 msyyparse():
Expression parser error. syntax error

[Thu Jan 07 15:28:21 2010].629000 msEvalExpression:
Expression parser error.
Failed to parse expression:  ( &gt;= 2.251) AND ( &lt;= 2.5)</pre>
<h3 style="text-align: justify;">Map Server Logging</h3>
<p style="text-align: justify;">To turn on logging in MapServer <span id="more-188"></span>enter the following lines near the top of the .MAP file. The <a href="http://mapserver.org/mapfile/map.html?highlight=debug">DEBUG </a>value ranges from 0 (only actual errors are logged), to 5 which logs everything (diagnostics, errors, and debug notes). The second line requires the path to a logfile (any path and filename can be used).</p>
<pre style="text-align: justify;">DEBUG 5
CONFIG "MS_ERRORFILE" "C:/ms4w/apps/myapp/tmp/ms.log"</pre>
<h3 style="text-align: justify;">Problem Solved</h3>
<p style="text-align: justify;">I am using the SQL Server plug-in so initially I thought it could be related to this. I also tried changing the field name used in the expressions in case MEAN was a reserved word. Several sites also suggested the field may need to be in UPPERCASE, but I think this relates only to shapefiles.</p>
<p style="text-align: justify;">MapServer was still generating full images, so data was being read and symbolised. I eventually found the <a href="http://n2.nabble.com/problem-with-expression-null-values-in-table-td1999490.html">following post</a> which pointed to the problem..nulls. I should have spotted this sooner as the debug output was  clear in retrospect. The expression parser was replacing my field name with empty values. So the expression <strong>EXPRESSION ( ([MEAN] &gt;= 2.251) AND ([MEAN] &lt;= 2.5) ) </strong>became<strong> (  &gt;= 2.251) AND ( &lt;= 2.5) </strong>wherever the [MEAN] field contained a NULL. All these features turned out to be <a href="http://www.cise.ufl.edu/~mssz/GIS/sliver.gif">slivers</a> and could be deleted from the database, allowing my debug files to be readable again. If the features were required I would either have had to create a view of the table in SQL Server and point my LAYER to read from this, or replace the NULL values with a 0 if this was appropriate.</p>
<p style="text-align: justify;">The <a href="http://n2.nabble.com/problem-with-expression-null-values-in-table-td1999490.html">post mentioned above</a> suggests that in the case of shapefiles NULLS are automatically replaced with 0 for numeric fields, and by &#8221; for strings. I think I&#8217;d prefer errors than automated assumptions about the data, but maybe a more obvious message in the log files would be useful.</p>
<p style="text-align: justify;">As for the image &#8211; apparently the The Greek lowercase <a title="Omega" href="http://en.wikipedia.org/wiki/Omega">omega (ω)</a> character is used to represent Null in <a title="Database theory" href="http://en.wikipedia.org/wiki/Database_theory">database theory</a>. You live and learn..</p>
<h3 style="text-align: justify;">Update</h3>
<p>Rather than delete null features from the database, you can ignore them completely when displaying your layer using the <a href="http://mapserver.org/mapfile/layer.html#layer">FILTER </a>keyword &#8211; <em>&#8220;this parameter allows for data specific attribute filtering that is done at the same time spatial filtering is done, but before any CLASS expressions are evaluated.&#8221;</em></p>
<p>For a SQL Server 2008 dataset to exclude nulls use a statement such as:</p>
<p>FILTER &#8220;[FieldName] IS NOT NULL&#8221;</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/Bx45vPQPEYA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/map-server-expression-errors/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/map-server-expression-errors?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=map-server-expression-errors</feedburner:origLink></item>
		<item>
		<title>Copying Spatial Data between SQL Server Databases</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/67-tTqO9TXU/copying-spatial-data-between-sql-server-databases</link>
		<comments>http://geographika.co.uk/copying-spatial-data-between-sql-server-databases#comments</comments>
		<pubDate>Mon, 04 Jan 2010 14:01:22 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[geodatabases]]></category>
		<category><![CDATA[sql server 2008]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=177</guid>
		<description><![CDATA[Aim - to copy a table containing geometry fields between two database servers. The task was made slightly trickier as the two servers are on two different domains. I wanted to use SQL rather than FME, or a SQL Server wizard, as it would be easier to script the process for the several tables I <a href='http://geographika.co.uk/copying-spatial-data-between-sql-server-databases'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><strong>Aim </strong>- to copy a table containing geometry fields between two database servers.<a href="http://geographika.co.uk/wp-content/uploads/2010/01/filetransfer.jpg"><img class="alignright size-medium wp-image-178" title="filetransfer" src="http://geographika.co.uk/wp-content/uploads/2010/01/filetransfer-300x174.jpg" alt="filetransfer" width="300" height="174" /></a> The task was made slightly trickier as the two servers are on two different domains.</p>
<p style="text-align: justify;">I wanted to use SQL rather than FME, or a SQL Server wizard, as it would be easier to script the process for the several tables I had to copy.</p>
<p style="text-align: justify;">The first task was to set up <a href="http://msdn.microsoft.com/en-us/library/ms188279.aspx">linked servers</a>. I used the following SQL (when logged in to my destination server, and using SQL Server Management Studio) to add the source server:</p>
<pre>EXEC sp_addLinkedServer 'MY_SOURCE_SERVER_NAME'</pre>
<p><span id="more-177"></span>I then needed to allow log-in access to the source server. The SQL below assumes there is a <em>sa </em>user with a password of <em>sa </em>on the source server:</p>
<pre>sp_addlinkedsrvlogin @rmtsrvname = 'MY_SOURCE_SERVER_NAME'
 ,  @useself =  'FALSE'
 ,  @locallogin =  null
 ,  @rmtuser =  'sa'  
 ,  @rmtpassword =  'sa'</pre>
<p style="text-align: justify;">I thought I was then ready to run a &#8220;SELECT INTO&#8221; query to copy records from the source table into a new table in the destination database. However I was met by the following error:</p>
<pre style="text-align: justify;">Msg 7325, Level 16, State 1, Line 1
Objects exposing columns with CLR types are not allowed in distributed queries.
Please use a pass-through query to access remote object '"MY_SOURCE_SERVER_NAME"."schema_name"."TableName"'.</pre>
<p style="text-align: justify;">It appeared that the geometry columns containing the SQL Server spatial types were causing the problem.  After reading up on pass-through queries  <a href="http://technet.microsoft.com/en-us/library/ms188427.aspx">OPENQUERY</a> seemed to be the solution.  I tried the following SQL:</p>
<pre style="text-align: left;">SELECT * INTO newschema.MyNewTableName
FROM OPENQUERY([MY_SOURCE_SERVER_NAME],
'SELECT * from [source_database_name].[schema_name].[TableName]');

<a href="http://geographika.co.uk/wp-content/uploads/2010/01/sql_success.png"><img class="aligncenter size-full wp-image-179" style="border: 1px solid black;" title="sql_success" src="http://geographika.co.uk/wp-content/uploads/2010/01/sql_success.png" alt="sql_success" width="184" height="79" /></a> <img src='http://geographika.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </pre>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/67-tTqO9TXU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/copying-spatial-data-between-sql-server-databases/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/copying-spatial-data-between-sql-server-databases?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=copying-spatial-data-between-sql-server-databases</feedburner:origLink></item>
		<item>
		<title>MapServer and SQL Server 2008 Plug-in</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/FI8fWvBPfMA/mapserver-and-sql-server-2008-plug-in</link>
		<comments>http://geographika.co.uk/mapserver-and-sql-server-2008-plug-in#comments</comments>
		<pubDate>Fri, 18 Dec 2009 10:52:09 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[geodatabases]]></category>
		<category><![CDATA[mapserver]]></category>
		<category><![CDATA[sql server 2008]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=170</guid>
		<description><![CDATA[The SQL Server 2008 plugin for MapServer is a &#8220;native driver modeled on the PostGIS driver to support SQL Server 2008’s newly added spatial capabilities.&#8221; It works fine for displaying data as WMS layers in OpenLayers however I ran into all sorts of problems when trying to use the GetFeatureInfo WMS query. With MapServer 5.2.1  <a href='http://geographika.co.uk/mapserver-and-sql-server-2008-plug-in'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">The <a href="http://mapserver.org/development/rfc/ms-rfc-38.html#usage-details">SQL Server 2008 plugin for MapServer </a>is a<em> &#8220;native driver modeled on the PostGIS driver to </em><a href="http://geographika.co.uk/wp-content/uploads/2009/12/mapserver.png"><img class="alignright size-full wp-image-172" style="border: 1px solid black; margin: 4px;" title="mapserver" src="http://geographika.co.uk/wp-content/uploads/2009/12/mapserver.png" alt="mapserver" width="268" height="70" /></a><em>support SQL Server </em><em>2008’s newly added spatial capabilities.&#8221; </em>It works fine for displaying data as WMS layers in <a href="http://openlayers.org/">OpenLayer</a><a href="http://openlayers.org/">s</a> however I ran into all sorts of problems when trying to use the GetFeatureInfo WMS query.</p>
<p style="text-align: justify;">With MapServer 5.2.1  (installed using MapServer for Windows &#8211; <a href="http://maptools.org/ms4w/index.phtml?page=downloads.html">MS4W v2.3.1</a>) no error message was returned, however neither was any data . I initially thought this was due to the <a href="http://trac.osgeo.org/mapserver/ticket/3082">following bug</a> in the plugin, which was <a href="http://n2.nabble.com/ms-sql-2008-spatial-still-problems-td1973412.html">reported to have been fixed for MapServer 5.4</a>.</p>
<p style="text-align: justify;"><span id="more-170"></span></p>
<p style="text-align: justify;">So I tried downloading MS4W v3.0 Beta 7, which included MapServer 5.4, and upgraded my installation. The WMS queries still failed but at least this time I got an error message:</p>
<pre style="text-align: justify;">msMSSQL2008LayerGetShape(): Query error. Error executing MSSQL2008 SQL statement:
SELECT convert(varchar(20), FID) from SEI_MyTable WHERE
GEOM.STIntersects(Geometry::STGeomFromText(&amp;#39;POLYGON((343410.447904052 262585.540545139,
343410.447904052 262585.540545139,343410.447904052 262585.540545139,343410.447904052
262585.540545139,343410.447904052 262585.540545139))&amp;#39;,0)) = 1

-[Microsoft][ODBC SQL Server Driver][SQL Server]A .NET Framework error occurred during execution of user-defined routine or aggregate &amp;quot;geometry&amp;quot;:
System.FormatException: 24305: The Polygon input is not valid because the ring does not have enough distinct points. Each ring of a polygon must contain at least three distinct points.
System.FormatException:
 at Microsoft.SqlServer.Types.Validator.Execute(Transition transition)
 at Microsoft.SqlServer.Types.ForwardingGeoDataSink.EndFigure()
 at Microsoft.SqlServer.Types.OpenGisWktReader.ParseLineStringText()
 at Microsoft.SqlServer.Types.OpenGisWktReader.ParsePolygonText()
 at Microsoft.SqlServer.Types.OpenGisWktReader.ParseTaggedText(OpenGisType type)
 at Microsoft.SqlServer.Types.OpenGisWktReader.Read(OpenGisType type, Int32 srid)
 at Microsoft.SqlServer.Types.SqlGeometry.GeometryFromText(OpenGisType type, SqlChars text, Int32 srid)</pre>
<p style="text-align: justify;">It appears that no matter what values I passed into my bounding box parameter, a spatial query was made using a bounding box / polygon consisting of 4 identical points, hence the error from SQL Server. I tried a bounding box set to the full extent of my data but still no luck &#8211; the bbox values made no different at all.</p>
<pre>http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/sei/test.map&amp;service=WMS&amp;
version=1.1.1&amp;request=GetFeatureInfo&amp;layers=test&amp;query_layers=test&amp;styles=,
&amp;bbox=0,0,500000,500000&amp;srs=EPSG%3A29902&amp;feature_count=10&amp;x=710&amp;y=132&amp;height=253&amp;
width=991&amp;info_format=text%2Fhtml</pre>
<p style="text-align: justify;"><a href="http://vbkto.dyndns.org:1280/sdk/Default.aspx">This useful site</a> automatically compiles the most recent MapServer versions into binaries available or download, however the most recent versions of the plug-in still fail.</p>
<p style="text-align: justify;">I found <a href="http://www.mail-archive.com/mapserver-users@lists.osgeo.org/msg09024.html">a post that had a similar issue</a> using CGI scripts rather than WMS calls. <a href="http://www.mail-archive.com/mapserver-users@lists.osgeo.org/msg08395.html">A suggestion</a> was to use the <a href="http://mapserver.org/mapfile/layer.html#tolerance">TOLERANCE</a> parameter for a layer, to increase the bounding box size, however this makes no difference to a WMS GetFeatureInfo query.</p>
<p style="text-align: justify;">The MapServer 5.4 sourcecode for the plugin can be <a href="http://trac.osgeo.org/mapserver/browser/branches/branch-5-4/mapserver/mapmssql2008.c?rev=9245">seen here</a>, however it is in C..and I can&#8217;t seem to find where the rectangle object is passed in or created. It appears <span>Tamas Szekeres has taken over updates to this plugin so I&#8217;ll try and contact him to make him aware of this issue. I&#8217;m not sure how many people actually use SQL Server 2008 and MapServer, but there is <a href="http://www.mail-archive.com/mapserver-users@lists.osgeo.org/msg04552.html">at least one other person</a>!</span></p>
<p style="text-align: justify;"><span><strong>Update (March 2010): </strong>It appears this issue has now been fixed for<a href="http://szekerest.blogspot.com/2010/03/changes-in-mapserver-mssql2008-driver.html"> version 5.6 by Tamas Szekeres</a>. </span></p>
<blockquote>
<p style="text-align: justify;">- Changed the query shape to POINT instead of POLYGON when the area of  the query shape is zero (causing a failure at the server).</p>
</blockquote>
<p style="text-align: justify;">More details on the issue can be found in the <a href="http://n2.nabble.com/Getfeatureinfo-and-MSsql-2008-server-td4631781.html">MapServer-dev mailing list</a>.</p>
<blockquote>
<p style="text-align: justify;">
</blockquote>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/FI8fWvBPfMA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/mapserver-and-sql-server-2008-plug-in/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/mapserver-and-sql-server-2008-plug-in?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=mapserver-and-sql-server-2008-plug-in</feedburner:origLink></item>
		<item>
		<title>SQL Server Spatial SQL</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/UdlL4npBtdg/sql-server-spatial-sql</link>
		<comments>http://geographika.co.uk/sql-server-spatial-sql#comments</comments>
		<pubDate>Fri, 18 Dec 2009 10:05:15 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[geodatabases]]></category>
		<category><![CDATA[sql server 2008]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=163</guid>
		<description><![CDATA[I&#8217;ve been working more and more with the SQL Server 2008 spatial queries. For standard queries I now rarely use the graphic design tools available in SQL Server Management Studio &#8211; SQL scripts are far quicker, and easier to reuse. For spatial queries I don&#8217;t think there even is a GUI. Anyway the following SQL <a href='http://geographika.co.uk/sql-server-spatial-sql'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">I&#8217;ve been working more and more with the SQL Server 2008 spatial queries. For standard queries I now rarely use the<a href="../wp-content/uploads/2009/12/sql_server_2008.png"><img class="alignright" title="sql_server_2008" src="../wp-content/uploads/2009/12/sql_server_2008-300x188.png" alt="sql_server_2008" width="150" height="94" /></a> graphic design tools available in SQL Server Management Studio &#8211; SQL scripts are far quicker, and easier to reuse. For spatial queries I don&#8217;t think there even is a GUI. Anyway the following SQL snippets may be of use to someone. I have only been using the GEOMETRY type, so these may not be relevant to the GEOGRAPHY type, for a distinction see this <a href="http://msdn.microsoft.com/en-us/library/bb964711.aspx">Microsoft document</a>.</p>
<h3><span id="more-163"></span>Geometry and Projections</h3>
<p>Make <a href="http://msdn.microsoft.com/en-us/library/bb933835.aspx" target="_blank">valid geometry</a> &#8211; this can often fix &#8216;invisible&#8217; datasets in desktop GIS packages such as CadCorp.</p>
<pre style="text-align: justify;">UPDATE MyTable SET GeomFieldName = GeomFieldName.MakeValid()</pre>
<p style="text-align: justify;">Set the <a href="http://www.spatialreference.org/">spatial reference</a> for all features in a table (<a href="http://msdn.microsoft.com/en-us/library/bb933851.aspx">STSrid</a>), this is the equivalent of using a .prj file with a shapefile. You <em>could</em> set a different reference for individual features, although why you&#8217;d want to do that I&#8217;ve no idea. Note that this does not reproject your data, but it is used to tell client applications what projection the data is in. In <a href="http://mapserver.org/">MapServer</a> I found the SRID has to be set correctly for <a href="http://en.wikipedia.org/wiki/Web_Map_Service">WMS</a> layers to appear in OpenLayers.  Conversely in CadCorp&#8217;s <a href="http://www.cadcorp.com/products_geographical_information_systems/geognosis.htm">GeognoSIS </a>I had to set these values to 0 for data to display correctly. Change the code according to the projection of your data.</p>
<pre>UPDATE MyTable SET GeomFieldName.STSrid = 3785 --change this value to your EPSG code</pre>
<h3 style="text-align: justify;">Feature Extents</h3>
<p style="text-align: justify;">The next SQL code gets the extents of each feature, and saves them into new fields. These fields are &#8220;calculated&#8221; so if the features are modified then the extents will be updated, yet they are also saved to disk rather than calculated dynamically for each query so they are as fast to display as other fields.</p>
<pre>ALTER TABLE MyTable
ADD MinX AS (CONVERT(int,GeomFieldName.STEnvelope().STPointN((1)).STX,0)) PERSISTED
ALTER TABLE MyTable
ADD MinY AS (CONVERT(int,GeomFieldName.STEnvelope().STPointN((1)).STY,0)) PERSISTED
ALTER TABLE MyTable
ADD MaxX AS (CONVERT(int,GeomFieldName.STEnvelope().STPointN((3)).STX,0)) PERSISTED
ALTER TABLE MyTable
ADD MaxY AS (CONVERT(int,GeomFieldName.STEnvelope().STPointN((3)).STY,0)) PERSISTED</pre>
<p>Then to get the full extent of your data you can use (although there are alternatives):</p>
<pre>SELECT Min(MinX)AS MinX, Min(MinY) AS MinY,
MAX(MaxX) AS MaxX, MAX(MaxY) AS MaxY
FROM MyTable</pre>
<h3 style="text-align: justify;">Spatial Indexes</h3>
<p style="text-align: justify;">As mentioned in a <a href="http://geographika.co.uk/?p=149">previous post</a> spatial indexes can greatly improve display and query speeds. To create an index in SQL use the following syntax. You should set the bounding box to the extent of your data, which can be calculated using the query above (and included in the SQL script).</p>
<pre>CREATE SPATIAL INDEX MyIndexName ON MyTable(GeomFieldName) USING  GEOMETRY_GRID
WITH (
BOUNDING_BOX =(-1493907.5664457313, 6128509.51667404, -578861.3521250226, 7703103.135644257),
GRIDS =(LEVEL_1 = MEDIUM,LEVEL_2 = MEDIUM,LEVEL_3 = MEDIUM,LEVEL_4 = MEDIUM),
CELLS_PER_OBJECT = 16, PAD_INDEX  = OFF, SORT_IN_TEMPDB = OFF,
DROP_EXISTING = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)</pre>
<h3>Spatial Queries</h3>
<p>Sometimes SQL Server doesn&#8217;t seem to use spatial indexes automatically. You can force a spatial query to use an index using the WITH(INDEX(IndexName) statement similar to below which finds all geometry in a table at a point specified by an X and Y (in a Web Mercator projection &#8211; <a href="http://www.spatialreference.org/ref/epsg/3785/">EPSG:3785</a>)</p>
<pre>SELECT *
FROM MyTable
WITH (INDEX (MyIndexName))
WHERE (geometry::Point(@x,@y,3785).STWithin(MyGeomField) = 1)</pre>
<p style="text-align: justify;">I have found that sometimes it is quicker when querying by points <em>not </em>to use a spatial index, so it is worth experimenting.</p>
<p style="text-align: justify;">To find all features within a user defined bounding box you can create a stored procedure similar to the following:</p>
<pre style="text-align: justify;">CREATE PROCEDURE [SearchByBounds]
 @minx nvarchar(max),
 @miny nvarchar(max),
 @maxx nvarchar(max),
 @maxy nvarchar(max)
AS
BEGIN
 SET NOCOUNT ON;
 declare @g as geometry;
 declare @wkt as nvarchar(max);
 set @wkt = 'POLYGON ((' + @minx + ' ' + @miny + ',' +
 @minx + ' ' + @maxy + ',' +  @maxx + ' ' + @maxy + ',' + @maxx +
 ' ' + @miny + ',' + @minx + ' ' + @miny +  '))';
 set @g = geometry::STGeomFromText(@wkt, 3785);
 --print @wkt
 SELECT *
 FROM MyTable WITH (INDEX (MySpatialIndex))
 WHERE GeomFieldName.STIntersects(@g) = 1
END</pre>
<p>I haven&#8217;t found too many tutorials or blogs on the spatial features in SQL Server 2008. The best resources I&#8217;ve found are:</p>
<ul>
<li><a href="http://www.jasonfollas.com/blog/archive/2008/03/14/sql-server-2008-spatial-data-part-1.aspx">Jason Follas&#8217;s Introduction to SQL Server Spatial</a></li>
<li><a href="http://blogs.msdn.com/isaac/archive/2009/05/28/sql-server-spatial-indexing.aspx">Issac&#8217;s posts on Spatial Indexing</a></li>
<li><a href="http://www.sqlskills.com/blogs/Bobb/">Bob Beauchemin&#8217;s SQL Server Spatial Blog</a></li>
<li>Alastair Aitchison&#8217;s book <a href="http://www.amazon.com/gp/product/1430218290?ie=UTF8&amp;tag=geographika-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=1430218290">Beginning Spatial with SQL Server 2008</a><img style="border:none !important; margin:0px !important;" src="http://www.assoc-amazon.com/e/ir?t=geographika-20&amp;l=as2&amp;o=1&amp;a=1430218290" border="0" alt="" width="1" height="1" /></li>
<li><a href="http://social.msdn.microsoft.com/Forums/en/sqlspatial/threads">MSDN&#8217;s SQL Server Spatial Forums</a></li>
</ul>
<p>Feel free to post more links below.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/UdlL4npBtdg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/sql-server-spatial-sql/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/sql-server-spatial-sql?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=sql-server-spatial-sql</feedburner:origLink></item>
		<item>
		<title>3 MapServer &amp; SQL Server 2008 Performance Tips</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/CQv1EbuspH8/mapserver-sql-server-2008-tips</link>
		<comments>http://geographika.co.uk/mapserver-sql-server-2008-tips#comments</comments>
		<pubDate>Sat, 12 Dec 2009 14:20:54 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[mapserver]]></category>
		<category><![CDATA[sql server 2008]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[wms]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=149</guid>
		<description><![CDATA[A current project I&#8217;ve been developing uses a combination of SQL Server 2008 and MapServer (for Windows) to serve many WMS layers. As much as it irks developers, web users only care about two things &#8211; how nice the site looks, and how fast it is. Whether the correct information is displayed comes a poor <a href='http://geographika.co.uk/mapserver-sql-server-2008-tips'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">A current project I&#8217;ve been developing uses a combination of SQL Server 2008 and MapServer (for Windows) to <a href="http://geographika.co.uk/wp-content/uploads/2009/12/242px-Teeshanrd.jpg"><img class="alignright size-full wp-image-150" style="border: 1px solid black; margin: 5px;" title="Townland Sign" src="http://geographika.co.uk/wp-content/uploads/2009/12/242px-Teeshanrd.jpg" alt="Townland Sign" width="173" height="157" /></a>serve many WMS layers. As much as it irks developers, web users only care about two things &#8211; how nice the site looks, and how fast it is. Whether the correct information is displayed comes a poor third..</p>
<p style="text-align: justify;">I&#8217;ve found a number of tweaks that have dramatically improved the WMS creation speed. In these examples I&#8217;m using a table in SQL Server 2008 with 50773 features (<a href="http://en.wikipedia.org/wiki/Townland" target="_blank">Irish Townlands</a> if you&#8217;re asking).</p>
<p style="text-align: justify;"><span id="more-149"></span>To test speeds I use the program <a href="http://mapserver.org/utilities/shp2img.html">shp2img</a> program, which can be found in the C:\ms4w\tools\mapserv folder. This is useful for not only checking if there are errors in your MAP file, but also for checking the speeds of individual layers. I use STATUS OFF for all layers, and then pass in the layer name with the following command (in the MS4W-Shell &#8211; a DOS window with environment variables set to various MapServer folders.</p>
<pre>shp2img -all_debug 5 -m C:\ms4w\apps\sei\test.map -o -l "Townlands" test.png</pre>
<h3>Reproject Your Data in the Database</h3>
<p style="text-align: justify;">A nice feature of MapServer is that it can reproject your data on-the-fly. However this comes at a performance cost. The original data is projected in the <a href="http://spatialreference.org/ref/epsg/29902/" target="_blank">Irish National Grid</a>, but the web viewer is based around OpenLayers and background mapping from Google, which is projected in <a href="http://spatialreference.org/ref/epsg/3785/">EPSG:3785</a> (or EPSG:900913 / EPSG:google &#8211; I prefer the vendor free projection myself).</p>
<p style="text-align: justify;">The &#8220;web Mercator&#8221; projection can be added to MapServer by pasting the following lines into the C:\ms4w\proj\nad\epsg file.</p>
<pre style="text-align: justify;">## Google Projection
&lt;900913&gt; +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs
## Google Projection - new code
&lt;3785&gt; +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs</pre>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2009/12/tbl.png"><img class="alignright size-medium wp-image-151" title="Townland Table" src="http://geographika.co.uk/wp-content/uploads/2009/12/tbl-300x158.png" alt="Townland Table" width="230" height="121" /></a><a href="http://www.safe.com/">FME </a>was then used to reproject the geometry in SQL Server. A nice feature of using the database as opposed to shapefiles is that two or more geometry fields can be stored in the same table, so different projections can be used for different WMS services or applications. In my MAP file my layer definition is now as follows:</p>
<pre style="text-align: justify;"> CONNECTIONTYPE PLUGIN
 PLUGIN "C:\ms4w\Apache\specialplugins\msplugin_mssql2008.dll"
 CONNECTION "server=****;uid=****;pwd=****;database=****;Integrated Security=false"
 DATA "GEOM3785 from Townland"</pre>
<p>Reprojected time to create layer: <strong>46.06</strong> seconds</p>
<p><span style="color: #000000;">Unprojected time to create layer (all features): <strong>13.469</strong> seconds</span></p>
<h3>Use Fast CGI</h3>
<blockquote><p><a href="http://mapserver.org/optimization/fastcgi.html" target="_blank">Fast CGI</a> is a protocol for keeping cgi-bin style web applications running as a daemon to take advantage of preserving memory caches, and amortizing other high start-up costs (like heavy database connections) over many requests.</p></blockquote>
<p>Fast CGI can be set up by following the instructions in C:\ms4w\README_INSTALL.html#f-fastcgi</p>
<p>I don&#8217;t think differences can be measure using shp2img, so I tested using<a href="http://getfirebug.com/net.html" target="_blank"> FireBug&#8217;s Net Tab</a>. The following line was added in to the LAYER definition in the MAP file:</p>
<pre>PROCESSING "CLOSE_CONNECTION=DEFER"</pre>
<p>Without FastCGI: <strong>9.23</strong> seconds</p>
<p>With FastCGI: <strong>8.46</strong> seconds</p>
<p style="text-align: justify;">How accurate these results are I&#8217;m not really sure. I guess that improvements in speed will become more noticeable when many layers are loaded in that all use the same database connection at the same time. However even on a single layer the FastCGI was almost a second quicker on every test run.</p>
<h3>Use Spatial Indexes</h3>
<p style="text-align: justify;">Using a spatial index when querying all layers would have no effect, so to see what difference it made on speed I needed to limit the results to a selected area. I decided to select all Townlands which intersected the county of Carlow. This  returns 1708 records. The following command was used to simulate this in shp2img:</p>
<pre style="text-align: justify;">shp2img -all_debug 5 -m C:\ms4w\apps\sei\wind.map -o -e -791171 6884314 -724041 6967856 -l "Townlands" test.png</pre>
<p>To select data using a spatial index the following line is used in the MAP file:</p>
<pre style="text-align: justify;">DATA "GEOM3785 from Townland WITH(INDEX(Townland3785_sidx)) USING UNIQUE FID USING SRID=3785"</pre>
<p style="text-align: justify;">I initially believed that spatially indexes had to be specified explicitly in the MAP file, and to test speeds without an index you could just remove the (WITH(INDEX&#8230;) statement. However speeds remained very similar. Disabling the spatial index in SQL Server (an option when right clicking on the index) revealed very different speeds. To re-enable the index, simply rebuild it. I&#8217;d leave the (WITH(INDEX&#8230;) statement in just to make sure it is used.</p>
<p>Not using a spatial index: <strong>3.806</strong> seconds</p>
<p>Using a spatial index: <strong>0.875</strong> seconds</p>
<p>Any feedback, or more tips much appreciated! There is also an <a href="http://mapserver.org/optimization/index.html" target="_blank">official page on optimisation</a> here. Happy MapServing..</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/CQv1EbuspH8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/mapserver-sql-server-2008-tips/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/mapserver-sql-server-2008-tips?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=mapserver-sql-server-2008-tips</feedburner:origLink></item>
		<item>
		<title>Baking Donuts…</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/B3t95vNnChc/baking-donuts</link>
		<comments>http://geographika.co.uk/baking-donuts#comments</comments>
		<pubDate>Tue, 20 Oct 2009 18:11:54 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[fme]]></category>
		<category><![CDATA[general]]></category>
		<category><![CDATA[donuts]]></category>
		<category><![CDATA[polygons]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=146</guid>
		<description><![CDATA[Nice to see FME developers have a sense of humour!]]></description>
			<content:encoded><![CDATA[<p>Nice to see <a href="http://www.safe.com/">FME</a> developers have a sense of humour!</p>
<p><a href="http://geographika.co.uk/wp-content/uploads/2009/10/FME_Donuts.png"><img class="alignright size-full wp-image-147" title="FME_Donuts" src="http://geographika.co.uk/wp-content/uploads/2009/10/FME_Donuts.png" alt="FME_Donuts" width="490" height="215" /></a></p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/B3t95vNnChc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/baking-donuts/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/baking-donuts?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=baking-donuts</feedburner:origLink></item>
		<item>
		<title>Quantum GIS and MapServer</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/N0S1qkeyBmo/quantum-gis-and-mapserver</link>
		<comments>http://geographika.co.uk/quantum-gis-and-mapserver#comments</comments>
		<pubDate>Mon, 12 Oct 2009 14:02:36 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[mapserver]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[desktop]]></category>
		<category><![CDATA[gis]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[qgis]]></category>
		<category><![CDATA[quantum gis]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=137</guid>
		<description><![CDATA[One of the main barriers I had to using MapServer as a web GIS server was that layers had to be symbolised in a text editor, using a MAPFILE. It was cumbersome to keep editing and refreshing a browser, there was no easy way to check for errors, and you have to learn the syntax <a href='http://geographika.co.uk/quantum-gis-and-mapserver'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">One of the main barriers I had to using <a href="http://mapserver.org/">MapServer</a> as a web GIS server was that layers had to be symbolised i<img class="alignright size-full wp-image-141" title="qgis" src="http://geographika.co.uk/wp-content/uploads/2009/10/qgis.png" alt="qgis" width="60" height="60" />n a text editor, using a MAPFILE. It was cumbersome to keep editing and refreshing a browser, there was no easy way to check for errors, and you have to learn the syntax and keywords.</p>
<p style="text-align: justify;">Whilst this is ok for smaller projects where I could make these myself, larger projects require non-programmers to gather data, symbolise it, and handle the map layouts and creation.</p>
<p style="text-align: justify;">I&#8217;ve just discovered that another of the <a href="http://www.osgeo.org/">OSGeo</a>&#8216;s projects, <a href="http://www.qgis.org/">Quantum GIS</a> (often abbreviated to QGIS) has a tool that can take a map project created and symbolised in the desktop application, and export it to a MAPFILE which can be read by MapServer. This seems to be the missing link in a  complete<a href="http://kelsocartography.com/blog/?p=1098"> Open Source GIS stack</a>.</p>
<p style="text-align: justify;"><span id="more-137"></span></p>
<p style="text-align: justify;">I had a few problems finding where this tool was installed. By default the Python files should be in the C:\OSGeo4W\apps\qgis\python\plugins\mapserver_export directory, however this directory did not exist after running through a default installation without paying attention.</p>
<p style="text-align: justify;">OSGeo have a <a href="http://trac.osgeo.org/osgeo4w/">custom installer</a> that you can use to install all their software including MapServer, QuantumGIS, and <a href="http://www.osgeo.org/grass">GRASS</a>. To install Quantum GIS follow the notes on this <a href="http://wiki.qgis.org/qgiswiki/OsGeo4wSetup">wiki page</a>. Clearly you need to select QGIS, but the MapServer Export tool also requires <strong>python-qgis</strong>. I think I missed this the first time round, however you can always rerun the installer to add new packages and libraries.</p>
<div id="attachment_138" class="wp-caption aligncenter" style="width: 310px"><a href="http://geographika.co.uk/wp-content/uploads/2009/10/osgeo4w1.png"><img class="size-medium wp-image-138" title="osgeo4w1" src="http://geographika.co.uk/wp-content/uploads/2009/10/osgeo4w1-300x196.png" alt="The OSGeo Installer" width="300" height="196" /></a><p class="wp-caption-text">The OSGeo Installer</p></div>
<p style="text-align: justify;">Once you have the Python for QGIS library installed open QGIS, and go to Plugins &gt;&gt; Fetch Python Plugins. The MapServer Export plug-in should be installed. Now go to Plug-Ins &gt;&gt; Manage Plugins and check the MapServer Export box as below.</p>
<p style="text-align: justify;"><a href="http://geographika.co.uk/wp-content/uploads/2009/10/osgeo4w2.png"><img class="aligncenter size-medium wp-image-139" title="osgeo4w2" src="http://geographika.co.uk/wp-content/uploads/2009/10/osgeo4w2-300x216.png" alt="osgeo4w2" width="300" height="216" /></a></p>
<p>You should now see a new MapServer Export menu item on the Plugins menu.</p>
<h3>Further Details</h3>
<p>There is a good introduction to using QGIS at <a href="http://spatialhorizons.com/category/qgis/">http://spatialhorizons.com/category/qgis/</a></p>
<p>You can also install a standalone version of MapServer Export &#8211; <a href="http://spatialserver.net/qgis2ms/">http://spatialserver.net/qgis2ms/</a>.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/N0S1qkeyBmo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/quantum-gis-and-mapserver/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/quantum-gis-and-mapserver?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=quantum-gis-and-mapserver</feedburner:origLink></item>
		<item>
		<title>FME: Setting a Raster Output Name Dynamically</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/h5oOvAfzk_c/fme-setting-a-raster-output-name-dynamically</link>
		<comments>http://geographika.co.uk/fme-setting-a-raster-output-name-dynamically#comments</comments>
		<pubDate>Sat, 10 Oct 2009 12:17:25 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[fme]]></category>
		<category><![CDATA[Data Processing]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=126</guid>
		<description><![CDATA[I have started to use FME more and more for data imports and data processing. I like automating any workflow as much as possible, and FME is great for this. For one part of a project had a number of similar raster processes that could be defined in a single workspace, as long as parameters <a href='http://geographika.co.uk/fme-setting-a-raster-output-name-dynamically'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">I have started to use <a href="http://www.safe.com/" target="_blank">FME</a> more and more for data imports and data processing. I like automating any workflow as much as possible, and FME is great for this. For one part of a project had a number of similar raster processes that could be defined in a single workspace, as long as parameters could be used.</p>
<p style="text-align: justify;">The system documentation is normally both detailed and clear, and FME also has very good <a href="http://www.safe.com/fmeusercentral/index.php">support and community web sites</a>.  However in this case it took a lot of documentation reading and trial and error to work out how to change the ouput filename of a model. This may be obvious to experienced users of FME, but it had me stumped for a while.</p>
<p><img class="aligncenter size-full wp-image-128" title="raster_naming2" src="http://geographika.co.uk/wp-content/uploads/2009/10/raster_naming21.png" alt="raster_naming2" width="473" height="142" /><span id="more-126"></span></p>
<p>The steps involved are simple in retrospect, and are as follows:</p>
<p>Create your raster model as normal, but add an additional <strong>AttributeSetter </strong>transformer, as shown in the screenshot above.</p>
<p>Next create a new <strong>Published Parameter</strong> that will be used to pass in the output raster filename. The source dataset and destination folder can also be set to be published parameters to provide full flexibility.</p>
<p><img class="aligncenter size-full wp-image-129" title="raster_naming3" src="http://geographika.co.uk/wp-content/uploads/2009/10/raster_naming3.png" alt="raster_naming3" width="326" height="65" /></p>
<p>Next right click on the newly created published parameter and check the AttributeSetter value item. This creates the link between the parameter and the value for the attribute.</p>
<p><img class="aligncenter size-full wp-image-131" title="raster_naming4" src="http://geographika.co.uk/wp-content/uploads/2009/10/raster_naming4.png" alt="raster_naming4" width="290" height="83" /></p>
<p>If you look at the AttributeSetter&#8217;s properties they should now look similar to below.</p>
<p><img class="aligncenter size-full wp-image-133" title="raster_naming5" src="http://geographika.co.uk/wp-content/uploads/2009/10/raster_naming5.png" alt="raster_naming5" width="365" height="157" /></p>
<p style="text-align: justify;">Finally look at the properties for your output raster dataset. Make sure the &#8220;Fanout By Attribute&#8221; is checked and the attribute is set to fme_basename. This sets the output filename to be the same as the fme_basename attribute value, which is now set via an input parameter.</p>
<p><img class="aligncenter size-medium wp-image-130" title="raster_naming1" src="http://geographika.co.uk/wp-content/uploads/2009/10/raster_naming1-300x261.png" alt="raster_naming1" width="300" height="261" /></p>
<p style="text-align: justify;">The model is now ready to run from the command line or through a batch process, for one or many raster transformations. The output filename parameter does not require a .tif extension.</p>
<pre>    fme.exe raster_sample.fmw
          --SourceDataset_ARCVIEWGRID C:\Grids
          --DestDataset_GEOTIFF C:\Rasters
          --OutputFileName MyOutputRaster</pre>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/h5oOvAfzk_c" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/fme-setting-a-raster-output-name-dynamically/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/fme-setting-a-raster-output-name-dynamically?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=fme-setting-a-raster-output-name-dynamically</feedburner:origLink></item>
		<item>
		<title>GIS and Licensing for Developers</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/OX9S7SUAXlQ/gis-and-licensing-for-developers</link>
		<comments>http://geographika.co.uk/gis-and-licensing-for-developers#comments</comments>
		<pubDate>Tue, 06 Oct 2009 18:10:08 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=117</guid>
		<description><![CDATA[GIS consultants and organisations that use GIS have different needs. Consultants tend to use lots of different software, for short amounts of time, whereas organisations make daily use of software from a single vendor. ESRI have followed Microsoft&#8217;s approach of a Developers&#8217; Network (MSDN). This allows the whole ESRI stack to be used for &#8220;development, <a href='http://geographika.co.uk/gis-and-licensing-for-developers'>[...]</a>]]></description>
			<content:encoded><![CDATA[<dl id="attachment_119" class="wp-caption alignright" style="width: 150px;">
<dt class="wp-caption-dt"><a href="http://edn.esri.com/"><img class="size-full wp-image-119 alignright" title="ednglobetrans" src="http://geographika.co.uk/wp-content/uploads/2009/10/ednglobetrans.gif" alt="EDN" width="140" height="59" /></a></dt>
</dl>
<p style="text-align: justify;">GIS consultants and organisations that use GIS have different needs. Consultants tend to use lots of different software, for short amounts of time, whereas organisations make daily use of software from a single vendor. ESRI have followed Microsoft&#8217;s approach of a <a href="http://msdn.microsoft.com/en-gb/subscriptions/dd364988.aspx" target="_blank">Developers&#8217; Network</a> (MSDN). This allows the whole ESRI stack to be used for &#8220;<em>development, testing, and demonstration</em>&#8221; at a reduced price. $1500 dollars gets you an <a href="http://www.esri.com/software/arcgis/edn/what-you-get.html" target="_blank">ESRI Developer Network subscription</a>, rising to $2000 if you also want the desktop applications (ArcMap, ArcCatalog etc.).</p>
<p style="text-align: justify;"><span id="more-117"></span>Getting as many GIS consultants trained in developing for ESRI products will result in more ESRI products being used by the consultant&#8217;s clients. However as ESRI also provide <a href="http://www.esri.com/services/index.html">consultancy services</a> independent consultants are often direct competitors. This can mean getting a EDN license may not be as simple as signing up on the website.</p>
<p style="text-align: justify;">Smaller players in the GIS market may see a consultancy as a chance to sell a few licenses, especially if the consultants have to develop for top-end products such as web servers. While the client often pays for this license during development, once the system is deployed there is no easy way to provide maintenance on it without continuing to pay for a separate license. I see this as very short-sighted in the long term &#8211; the barriers to trying out new software for developers should be removed, rather than added.</p>
<p style="text-align: justify;">All this is against a backdrop of web mapping (<a href="http://www.spatiallyadjusted.com/2009/04/12/licensing-on-the-geoweb/" target="_blank">aka the geoweb</a>) APIs from Google and Microsoft which are provided for free, along with fast, free, background mapping. The introduction of spatial functions into SQL Server 2008 Express has meant that consultants with MSDN development can be carried out at no cost.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/OX9S7SUAXlQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/gis-and-licensing-for-developers/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/gis-and-licensing-for-developers?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=gis-and-licensing-for-developers</feedburner:origLink></item>
		<item>
		<title>Free Commercial GIS!</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/EJIWWID3_Jw/free-commercial-gis</link>
		<comments>http://geographika.co.uk/free-commercial-gis#comments</comments>
		<pubDate>Wed, 30 Sep 2009 10:00:19 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[general]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=112</guid>
		<description><![CDATA[Most of the major GIS software vendors now have a free introductory &#8220;viewer&#8221; available for download. These normally contain standard navigation and selection tools, and allow you to view datasets but not change them. They are very useful if a company is about to invest in a GIS and are unsure what software to use. <a href='http://geographika.co.uk/free-commercial-gis'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Most of the major GIS software vendors now have a free introductory &#8220;viewer&#8221; available for download. These normally contain standard navigation and selection tools, and allow you to view datasets but not change them.</p>
<p style="text-align: justify;">They are very useful if a company is about to invest in a GIS and are unsure what software to use. Point their employees to the following links, create a few datasets relevant to their organisation, and let them get a feel for each and find out their preferences. Clearly it will be the management who will make the investment so there will be a trade-off between cost and how much their employees like a particular product.</p>
<p style="text-align: justify;">Of course you could always just recommend whichever one you feel most comfortable developing in..<img class="aligncenter size-full wp-image-113" title="devil" src="http://geographika.co.uk/wp-content/uploads/2009/09/devil.jpg" alt="devil" width="48" height="48" /></p>
<p>&#8220;GeoMedia Viewer is an easy to use, FREE GIS software application for desktop viewing and distribution of geospatial data&#8221;</p>
<p style="text-align: justify;"><a href="https://support.intergraph.com/Product/GeoMediaViewer.asp" target="_blank">https://support.intergraph.com/Product/GeoMediaViewer.asp</a><br />
<span id="more-112"></span><br />
&#8220;ArcExplorer is a freely available lightweight GIS data viewer that lets you perform a variety of basic GIS functions. With ArcExplorer, you can display, query, and retrieve data. It can be used as a stand-alone application with local data sets or as a client for Internet data and map servers.&#8221;</p>
<p><a href="http://www.esri.com/software/arcexplorer/" target="_blank">http://www.esri.com/software/arcexplorer/</a></p>
<p style="text-align: justify;">&#8220;Map Reader provides users of Cadcorp SIS with a powerful free tool to effortlessly view, query and print map data. The strength of Map Reader lies in its ability to view over 160 formats..&#8221; (requires registration)</p>
<p><a href="http://www.cadcorp.com/products_geographical_information_systems/map_reader.htm" target="_blank">http://www.cadcorp.com/products_geographical_information_systems/map_reader.htm</a></p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/EJIWWID3_Jw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/free-commercial-gis/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/free-commercial-gis?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=free-commercial-gis</feedburner:origLink></item>
		<item>
		<title>7 Reasons for ESRI not to Drop VBA</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/DwkaKEsMAlo/7-reasons-for-esri-not-to-drop-vba</link>
		<comments>http://geographika.co.uk/7-reasons-for-esri-not-to-drop-vba#comments</comments>
		<pubDate>Sun, 27 Sep 2009 11:44:17 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[esri]]></category>
		<category><![CDATA[opinion]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[vba]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=106</guid>
		<description><![CDATA[I recently learned from James Fee&#8217;s blog that ArcGIS 9.4 will be the last version that supports VBA. I can see why this is being dropped &#8211; Microsoft no longer promotes or updates VBA. Microsoft now promote &#8220;Visual Studio Tools for Office&#8221; as its replacement for VBA in MS Office products, however VBA is still <a href='http://geographika.co.uk/7-reasons-for-esri-not-to-drop-vba'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>I recently learned from <a href="http://www.spatiallyadjusted.com/2009/09/14/depreciation-plans-for-arcgis-9-3-1-with-a-little-whats-coming-in-9-4/#comments" target="_blank">James Fee&#8217;s blog</a> that ArcGIS 9.4 will be the last version that supports VBA. I can see why this is being dropped &#8211; Microsoft no longer promotes or updates VBA. Microsoft now promote &#8220;Visual Studio Tools for Office&#8221; as its replacement for VBA in MS Office products, however VBA is still in Office 2007, and looks to be kept in <a href="http://www.theregister.co.uk/2008/01/21/vba_office_victory/" target="_blank">for at least the next version</a>. Is ESRI acting too prematurely? I can think of 7 good reasons why VBA should be kept.</p>
<p><img class="aligncenter size-full wp-image-107" title="vba" src="http://geographika.co.uk/wp-content/uploads/2009/09/vba.png" alt="vba" width="220" height="83" /></p>
<p>1. VBA is great for prototyping. There is no need to open up Visual Studio, create a custom tool, implement all its interfaces and constructors etc. before you can even get round to writing the code for the OnClick event of a button.<br />
<span id="more-106"></span><br />
2. The code is saved in the MXD. Prototypes can be easily zipped up and sent to a client for testing without the need to run set up packages, use the add/remove programs tool, and change config files. This allows projects to be developed using an <a href="http://en.wikipedia.org/wiki/Agile_software_development" target="_blank">agile approach</a>.</p>
<p>3. It is the easiest entry point for GIS professionals into programming. People with no programming background can use an application they are already familiar with, cut and paste a few samples from the help file and they are away.It is also an entry point into the weird, wonderful, and worringly huge world of ArcObjects.</p>
<p>4. It is all well and good to use Python for geoprocessing, but many tasks require ArcMap&#8217;s user interface, and the ability to visualise the data &#8211; and maybe even interact with it..!</p>
<p>5. There is a wealth of samples, tools, and scripts available on the web that will now be useless, or require conversion. No more copying, pasting, and running to get a task done quickly. VBA for many people is part of the daily use of ArcMap &#8211; basic subs can be bashed out in a few minutes to complete a one-off task and then forgotten about.</p>
<p>6. VBA skills can be transferred to other applications such as Excel, Word, and Access. For many GIS users these are the only other programs they use for daily tasks, so being able to automate them, or modify a recorded VBA macro can greatly increase productivity.</p>
<p>7. It is another nail in the coffin of the VB.Net versus C# argument &#8211; if no-one has used VBA then there is no reason to recommend coding in VB.Net due to familiar syntax..however that is just a personal view in an ongoing struggle to avoid having to write all future projects in C# to fit with &#8220;company standards.&#8221;</p>
<p>In my opinion the ideal solution would be to continue to allow code to be written and saved in the MXD, but replace VBA/VB6 with VB.Net. Why not even go further and allow macros to be recorded in ArcMap?</p>
<p>Still at least we&#8217;ll all now be safe from those VBA viruses going around in MXD files..</p>
<p><strong>Update</strong></p>
<p>One item I missed in the original post is that VBA is used for field calculations in ArcMap. I&#8217;m sure most GIS users have a few complex operations saved somewhere, all of which look to become redundant. It will be interesting to see whether Python will take its place.</p>
<p><img class="aligncenter size-full wp-image-124" title="vba_calc" src="http://geographika.co.uk/wp-content/uploads/2009/09/vba_calc.png" alt="vba_calc" width="386" height="185" /></p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/DwkaKEsMAlo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/7-reasons-for-esri-not-to-drop-vba/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/7-reasons-for-esri-not-to-drop-vba?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=7-reasons-for-esri-not-to-drop-vba</feedburner:origLink></item>
		<item>
		<title>Developing with CadCorp</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/dOy3XoOSh_I/developing-with-cadcorp</link>
		<comments>http://geographika.co.uk/developing-with-cadcorp#comments</comments>
		<pubDate>Sun, 27 Sep 2009 01:55:05 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[cadcorp]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=93</guid>
		<description><![CDATA[I&#8217;ve recently completed my first custom tool for CadCorp&#8217;s Map Modeller. CadCorp is most used in the UK, and it is apparently also big in Japan. The main benefit is that it reads many different spatial data formats directly, it can connect to SQL Server and Oracle without middleware (i.e. an SDE type application), and <a href='http://geographika.co.uk/developing-with-cadcorp'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">I&#8217;ve recently completed my first custom tool for <a href="http://www.cadcorp.com/products_geographical_information_systems/map_modeller.htm" target="_blank">CadCorp&#8217;s Map Modeller</a>. CadCorp is most used in the UK, and it is apparently also big in Japan. The main benefit is that it reads many different spatial data formats directly, it can connect to SQL Server and Oracle without middleware (i.e. an SDE type application), and it is a leader in the open standards espoused by the <a title="http://www.opengeospatial.org/" href="http://" target="_blank">Open Geospatial Consortium</a>.</p>
<p style="text-align: center;"><img class="size-full wp-image-95 aligncenter" title="cadcorp" src="http://geographika.co.uk/wp-content/uploads/2009/09/cadcorp1.jpg" alt="cadcorp" width="187" height="50" /></p>
<p style="text-align: justify;">In terms of development the main issue is that there appear to be very few people developing tools around CadCorp&#8217;s products apart from CadCorp themselves. This means that the only code samples are in the help system installed with the tool, and a PDF file. Straying outside these samples I found involves a lot of trial and error. There is a forum on the CadCorp site &#8211; annoyingly registration is required to read the posts, and there are very few programming related posts. The CadCorp staff do however get back to you on any questions you pose.</p>
<p><span id="more-93"></span></p>
<p style="text-align: justify;">Visual Studio and .NET languages can be used to create custom DLLs that integrate with the application. Prior to version 7 (the latest CadCorp release) custom code was run in a separate memory process, and Windows messaging used to pass messages between the custom tool and the CadCorp application. Fortunately this has changed so the DLL can run in the same memory space. The code below shows how to add two new menu items using VB.Net.</p>
<pre><span id="spBody"><span style="font-size: x-small;">Public Sub AddMenus()
  Dim mainMenu As New SisMenuItem("Custom Tool")
  Dim menuB As New SisMenuItem("B", New SisClickHandler(AddressOf b))
  mainMenu.MenuItems.Add(menuB)
  Dim menuB As New SisMenuItem("A", New SisClickHandler(AddressOf a))
  mainMenu.MenuItems.Add(menuA)
End Sub
</span></span></pre>
<p>Strangely the two menu items would be listed on a new menu item <em>alphabetically</em>. Apparently this is by design, and hidden ASCII characters can be used to order the menus..</p>
<p>Each custom menu item has an associated sub procedure that is called when clicked. The example above expects two subs a and b. Each would look similar to:</p>
<pre>Private Sub a(ByVal sender As Object, ByVal args As SisClickArgs)
  Dim mm As MapManager = args.MapManager
End Sub</pre>
<p style="text-align: justify;">The reference to the CadCorp application is passed in as an argument by default. One of my main gripes with development with CadCorp is that the programming model appears to be a based partly on objects, and partly on passing arcane strings into a huge &#8220;application&#8221; object. As these are strings they are not picked up be intellisense in Visual Studio and have to be found in the manual. I&#8217;m not sure why this is the case, as a simple wrapper could be created to avoid this. Maybe it is in development..</p>
<p style="text-align: justify;">To illustrate my point here is a function to loop through all the layers (aka overlays), and find a layer with a particular name:</p>
<pre style="text-align: justify;">Public Function FindOverlayByName(ByVal mm As MapManager, ByVal sLayerName As String) As Integer
 Dim lNumOverlays As Integer = mm.GetInt(SIS_OT_WINDOW, 0, "_nOverlay&amp;")
 Dim iOverlayPos As Integer = -1
 'loop through all overlays checking if the name matches
 For lCount = 0 To lNumOverlays - 1
   Dim sName As String = mm.GetStr(SIS_OT_OVERLAY, lCount, "_name$")
   If sName = sLayerName Then
     iOverlayPos = lCount
     Return iOverlayPos
   End If
 Next lCount
 Return iOverlayPos
End Function</pre>
<p style="text-align: justify;">The line to notice is mm.GetStr(SIS_OT_OVERLAY, lCount, &#8220;_name$&#8221;). There are many cases of passing and setting properties using the GetStr / SetStr approach, each one with a different third parameter.</p>
<p style="text-align: justify;">Collections of objects have to be stored in lists, and can only be referred to by a string name. This makes code inflexible and hard to maintain. For example the code below finds the extent of all features in an overlay:</p>
<pre style="text-align: justify;">mm.CreateListFromOverlay(iLayerPos, "AllItems")
If mm.GetListSize("AllItems") &gt; 0 Then
 myExtent = mm.GetListExtent("AllItems")
 mm.SplitExtent(x1, y1, z1, x2, y2, z2, myExtent)
End If</pre>
<p>The &#8220;AllItems&#8221; string is used to keep track of all the features in an overlay. Any string can be used (I chose &#8220;AllItems&#8221; for readability, and this could be saved in a variable, but it still seems starnge to the object-orientated world of .Net.</p>
<p style="text-align: justify;">The tool is now installed and being used by ~15 users, and has a backend Oracle geodatabase, and seems to be going well. Next I&#8217;ll be trying out CadCorp&#8217;s web server <a href="http://www.cadcorp.com/products_geographical_information_systems/geognosis.htm" target="_blank">GeognoSIS</a>.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/dOy3XoOSh_I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/developing-with-cadcorp/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/developing-with-cadcorp?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=developing-with-cadcorp</feedburner:origLink></item>
		<item>
		<title>Visio Data Modelling and VBA</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/Lell_f7p5Ag/visio-data-modelling-and-vba</link>
		<comments>http://geographika.co.uk/visio-data-modelling-and-vba#comments</comments>
		<pubDate>Fri, 25 Sep 2009 01:52:32 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[geodatabases]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[IVMEEntity VisioModelingEngine  shape visio entity vba uml]]></category>

		<guid isPermaLink="false">http://geographika.co.uk/?p=78</guid>
		<description><![CDATA[I use Visio for a number of tasks. For creating geodatabase models in ArcGIS, for system architecture diagrams, and for data flow models. It may not be the easiest program to use, but the alternatives are often too simplistic, or worse. I wanted to generate a nice diagram of a SQL Server database I had <a href='http://geographika.co.uk/visio-data-modelling-and-vba'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>I use Visio for a number of tasks. For creating geodatabase models in ArcGIS, for system architecture diagrams, and for data flow models. It may not be the easiest program to use, but the alternatives are often too simplistic, or worse.</p>
<p>I wanted to generate a nice diagram of a SQL Server database I had created, and automatically create hyperlinks that would pop up an Ajax box with sample records directly from the database. In order to do this each hyperlink had to have a variable based on the table/entity name.  However it soon became apparent that there is no easy way to access the entity name in VBA from its associated shape object. The solution to this is the <strong>VisioModelingEngine </strong>library which provides access to the UML, but does <em>not </em>provide access to the shapes.<br />
<span id="more-78"></span></p>
<p>There appears to be very little documentation on using the classes in this library. I found a couple of examples at <a href="http://www.eggheadcafe.com/forumarchives/visiodeveloperVisualBasica/Jul2005/post23423796.asp" target="_blank">http://www.eggheadcafe.com/forumarchives/visiodeveloperVisualBasica/Jul2005/post23423796.asp</a> and <a href="http://www.eggheadcafe.com/software/aspnet/32121825/forward-engineer-visio-er.aspx" target="_blank">http://www.eggheadcafe.com/software/aspnet/32121825/forward-engineer-visio-er.aspx</a></p>
<p>My eventual workaround involves temporarily changing the first attribute in an entity to the entity name, searching through the shape&#8217;s text for this name, recording the ID and then changing it back. The idea was based on <a href="http://www.eggheadcafe.com/conversation.aspx?messageid=32580685&amp;threadid=32580682" target="_blank">this post</a> which hinted that was what they did, but then frustratingly didn&#8217;t post their solution.</p>
<p>Anyway the main use of the code is to associate a Visio entity (IVMEEntity) with its shape.</p>
<p><a href="http://geographika.co.uk/wp-content/uploads/visio_modelling.htm" target="_blank">The full VBA code can be seen by clicking this link</a>.</p>
<p>A good source of VBA scripts for Visio can be found at <a href="http://visualsignals.typepad.co.uk/vislog/">http://visualsignals.typepad.co.uk/vislog/</a> this provided me with the code for looping through shapes on a page.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/Lell_f7p5Ag" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/visio-data-modelling-and-vba/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/visio-data-modelling-and-vba?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=visio-data-modelling-and-vba</feedburner:origLink></item>
		<item>
		<title>Getting a Feature Layer by Name</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/ScBwl5uEWwg/getting-a-feature-layer-by-name</link>
		<comments>http://geographika.co.uk/getting-a-feature-layer-by-name#comments</comments>
		<pubDate>Wed, 03 Jun 2009 09:43:33 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[arcobjects]]></category>
		<category><![CDATA[esri]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://geographika.wordpress.com/?p=58</guid>
		<description><![CDATA[An often required function is to get a specific layer from a current map document. The code below is for VB.NET and requires a map document and uses the alias name of the feature class. The first function returns all IGeoFeature layers in a map &#8211; these are layers based on vector geographic data. The <a href='http://geographika.co.uk/getting-a-feature-layer-by-name'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;margin:0;">An often required function is to get a specific layer from a current map document. The code below is for VB.NET and requires a map document and uses the alias name of the feature class. The first function returns all <a href="http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esriCarto/IGeoFeatureLayer.htm" target="_blank">IGeoFeature</a> layers in a map &#8211; these are layers based on vector geographic data. The second loops through these layers and compares the layer names.</p>
<p><span id="more-58"></span></p>
<pre>Public Function GetFeatureLayers(ByRef pMap As IMap) As IEnumLayer

Dim pUID As New UIDClass
pUID.Value = "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}" 'IGeoFeatureLayer GUID

If pMap.LayerCount &gt; 0 Then
GetFeatureLayers = pMap.Layers(pUID, True)
Else
Return Nothing
End If

End Function

Public Function GetFeatureLayerByAliasName(ByRef pMap As IMap, _
ByVal strLayerModelName As String) As IFeatureLayer

Dim pLayerEnum As IEnumLayer
Dim pFLayer As IFeatureLayer

pLayerEnum = GetFeatureLayers(pMap)
If pLayerEnum Is Nothing Then
Return Nothing
End If

pFLayer = DirectCast(pLayerEnum.Next, IFeatureLayer)

Do Until pFLayer Is Nothing
If pFLayer.Valid Then
If strLayerModelName = pFLayer.FeatureClass.AliasName Then
Return pFLayer
End If
End If
pFLayer = DirectCast(pLayerEnum.Next, IFeatureLayer)
Loop

'the layer was not found
Return Nothing

End Function</pre>
<p style="margin:0;">
<p style="text-align:justify;margin:0;">Rather than using the layer name visible in the table of contents which is easly changed by a user, I use the .AliasName of the feature class. This is automatically set to the name of the layer when added to a map. A user is much less likely to change this. There is however another name that is 100% certain not to change, it does however require an additional step when adding the layer shown below:</p>
<pre>Dim pModelInfo As IModelInfo
pModelInfo = CType(pFLayer.FeatureClass, IModelInfo)
pModelInfo.ModelName = “AnyValueYouLike”</pre>
<p style="text-align:justify;margin:0;">The code to find this layer is similar to the FindFeatureLayer, but relies on the <a href="http://edndoc.esri.com/arcobjects/9.1/ComponentHelp/esriGeoDatabase/IModelInfo.htm" target="_blank">IModelInfo</a> interface. As stated in the documentation -<em> &#8220;Object classes and fields in a geodatabase can have between one and three names..</em><em>The third name is the model name which is a tool for developers of custom objects to use to guarantee the names of objects independent of the true name or alias name.&#8221;</em></p>
<p style="text-align:justify;margin:0;">This property could be used in conjunction with a GUID to ensure you return the layer you are looking for.</p>
<p style="margin:0;">
<pre>Public Function GetFeatureLayerByModelName(ByRef pMap As IMap, _
ByVal strLayerModelName As String) As IFeatureLayer

Dim pLayerEnum As IEnumLayer
Dim pFLayer As IFeatureLayer
Dim pModelInfo As IModelInfo

pLayerEnum = GetFeatureLayers(pMap)
If pLayerEnum Is Nothing Then
Return Nothing
End If

pFLayer = DirectCast(pLayerEnum.Next, IFeatureLayer)

Do Until pFLayer Is Nothing
If pFLayer.Valid Then
pModelInfo = DirectCast(pFLayer.FeatureClass, IModelInfo)
If strLayerModelName = pModelInfo.ModelName Then
Return pFLayer
End If
End If
pFLayer = DirectCast(pLayerEnum.Next, IFeatureLayer)
Loop

'the layer was not found
Return Nothing
End Function</pre>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/ScBwl5uEWwg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/getting-a-feature-layer-by-name/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/getting-a-feature-layer-by-name?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=getting-a-feature-layer-by-name</feedburner:origLink></item>
		<item>
		<title>Geomedia WebMap v5.2</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/4IXFnIZskIs/geomedia-webmap-v52</link>
		<comments>http://geographika.co.uk/geomedia-webmap-v52#comments</comments>
		<pubDate>Fri, 20 Feb 2009 20:05:18 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[geomedia]]></category>
		<category><![CDATA[opinion]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://geographika.wordpress.com/?p=53</guid>
		<description><![CDATA[I&#8217;ve recently been working again with Intergraph&#8217;s Geomedia WebMap 5.2. Development can be done in .NET, which seemed very advanced a few years ago when ESRI&#8217;s flagship product was ArcIMS.. However it seems that line features can only be rendered as solid lines (no dots or dashes)..a very strange oversight, especially when it appears the <a href='http://geographika.co.uk/geomedia-webmap-v52'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently been working again with Intergraph&#8217;s Geomedia WebMap 5.2. Development can be done in .NET, which seemed very advanced a few years ago when ESRI&#8217;s flagship product was ArcIMS..</p>
<p>However it seems that line features can only be rendered as solid lines (no dots or dashes)..a very strange oversight, especially when it appears the outlines of polygons <em>can</em> have linear styling!</p>
<p>I&#8217;m going to be installing version 6 soon to see if it has been resolved, and see if there are any new features.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/4IXFnIZskIs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/geomedia-webmap-v52/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/geomedia-webmap-v52?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=geomedia-webmap-v52</feedburner:origLink></item>
		<item>
		<title>Hiding Geodatabase Tables</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/0gMJtO2rGq4/hiding-geodatabase-tables</link>
		<comments>http://geographika.co.uk/hiding-geodatabase-tables#comments</comments>
		<pubDate>Thu, 03 Apr 2008 10:27:44 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[arcobjects]]></category>

		<guid isPermaLink="false">http://geographika.wordpress.com/?p=48</guid>
		<description><![CDATA[The following VBA function hides all on the geodatabase tables added by ESRI into an Access database. Useful if you spatially enable your users database, and they wonder what all those GDB_ tables are for.. To unhide just change the Trues to False in the code snippet below, or add a parameter to the sub. <a href='http://geographika.co.uk/hiding-geodatabase-tables'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>The following VBA function hides all on the geodatabase tables added by ESRI into an Access database. Useful if you spatially enable your users database, and they wonder what all those GDB_ tables are for..</p>
<div style="text-align:center;"><img src="http://geographika.files.wordpress.com/2008/04/gdb_tables.png" alt="GDB Tables" /></div>
<p>To unhide just change the Trues to False in the code snippet below, or add a parameter to the sub.<br />
<span id="more-48"></span><br />
<code>Public Sub HideGeoDatabaseTables()</code><code> </code></p>
<p><code>Dim strTableName As String</code><code> </code><code>For i = 0 To CurrentDb.TableDefs.Count - 1<br />
If CurrentDb.TableDefs(i).Name Like "GDB_*" Then<br />
strTableName = CurrentDb.TableDefs(i).Name<br />
Access.SetHiddenAttribute acTable, strTableName, True<br />
End If<br />
Next</code><code>Access.SetHiddenAttribute acTable, "SelectedObjects", True<br />
Access.SetHiddenAttribute acTable, "Selections", True</code></p>
<p><code>End Sub</code></p>
<p>To view hidden objects in Microsoft Access, go to Options and check the &#8220;Hidden Objects&#8221; box.</p>
<div style="text-align:center;"><img src="http://geographika.files.wordpress.com/2008/04/access_options.png" alt="Access Options" /></div>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/0gMJtO2rGq4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/hiding-geodatabase-tables/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/hiding-geodatabase-tables?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=hiding-geodatabase-tables</feedburner:origLink></item>
		<item>
		<title>Could not use ''; file already in use."</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/7BC-7ws37Nk/could-not-use-file-already-in-use</link>
		<comments>http://geographika.co.uk/could-not-use-file-already-in-use#comments</comments>
		<pubDate>Sat, 19 Jan 2008 22:10:40 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[bugs]]></category>
		<category><![CDATA[2147467259]]></category>
		<category><![CDATA[ldb]]></category>
		<category><![CDATA[OleDbException]]></category>

		<guid isPermaLink="false">http://geographika.wordpress.com/2008/01/19/could-not-use-file-already-in-use/</guid>
		<description><![CDATA[System.Data.OleDb.OleDbException occurred   ErrorCode=-2147467259   Message=&#8221;Could not use &#8221;; file already in use.&#8221;   Source=&#8221;Microsoft JET Database Engine&#8221; Access, lock files, and Visual Source Safe &#8211; an accident waiting to happen! I got the above error, after my code had been fine for weeks. Googling turned up permissions on the folder with the Access database, and <a href='http://geographika.co.uk/could-not-use-file-already-in-use'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>System.Data.OleDb.OleDbException occurred<br />
  ErrorCode=-2147467259<br />
  Message=&#8221;Could not use &#8221;; file already in use.&#8221;<br />
  Source=&#8221;Microsoft JET Database Engine&#8221;</p>
<p>Access, lock files, and Visual Source Safe &#8211; an accident waiting to happen! I got the above error, after my code had been fine for weeks. Googling turned up permissions on the folder with the Access database, and closing secondary applications. The solution in the end turned out to be that the .ldb file had come under source control. Removing it from this, and deleting the fle resolved the issue.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/7BC-7ws37Nk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/could-not-use-file-already-in-use/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/could-not-use-file-already-in-use?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=could-not-use-file-already-in-use</feedburner:origLink></item>
		<item>
		<title>Convert C# to VB.Net</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/o6mSAzVAEk8/convert-c-to-vbnet</link>
		<comments>http://geographika.co.uk/convert-c-to-vbnet#comments</comments>
		<pubDate>Sun, 02 Sep 2007 21:45:40 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[arcobjects]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://geographika.wordpress.com/2007/09/02/convert-c-to-vbnet/</guid>
		<description><![CDATA[It can be frustrating when a code sample that seems to do exactly what you want is written in C#, and your application is in VB.Net. http://www.kamalpatel.net/ConvertCSharp2VB.aspx solves this problem by converting the C# code directly into its VB.Net equivalent &#8211; all online and for free for code up to 6.15KB in size, and for larger amounts of code a <a href='http://geographika.co.uk/convert-c-to-vbnet'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>It can be frustrating when a code sample that seems to do exactly what you want is written in C#, and your application is in VB.Net. <a href="http://www.kamalpatel.net/ConvertCSharp2VB.aspx">http://www.kamalpatel.net/ConvertCSharp2VB.aspx</a> solves this problem by converting the C# code directly into its VB.Net equivalent &#8211; all online and for free for code up to 6.15KB in size, and for larger amounts of code a tool can be downloaded for free.</p>
<p>It does the majority of the conversion well but I ran into a few minor problems where line breaks were not taken into account.</p>
<p>This tool will be even more useful when the ESRI samples, the majority of which are only available in VB6, are updated to .NET&#8230;</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/o6mSAzVAEk8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/convert-c-to-vbnet/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/convert-c-to-vbnet?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=convert-c-to-vbnet</feedburner:origLink></item>
		<item>
		<title>Lorem Ipsum</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/yHnqu3yQEzU/lorem-ipsum</link>
		<comments>http://geographika.co.uk/lorem-ipsum#comments</comments>
		<pubDate>Fri, 17 Aug 2007 15:28:53 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://geographika.wordpress.com/2007/08/17/lorem-ipsum/</guid>
		<description><![CDATA[I recently added some Lorem Ipsum text to fill in some space on a prototype ASP.NET website I made recently, which lead to a few questions from the client (a person not a machine) such as &#8220;what language is all this text in?!&#8221; A handy generator and a history of Lorem Ipsum can be found here. However <a href='http://geographika.co.uk/lorem-ipsum'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://geographika.files.wordpress.com/2007/08/lorem.gif" title="Lorem Ipsum"></a><a href="http://geographika.files.wordpress.com/2007/08/mutley1.jpg" title="mutley1.jpg"></a>I recently added some Lorem Ipsum text to fill in some space on a prototype ASP.NET website I made recently, which lead to a few questions from the client (a person not a machine) such as &#8220;what language is all this text in?!&#8221; A handy generator and a history of Lorem Ipsum can be found <a href="http://www.lipsum.com/">here</a>.</p>
<p>However far more amusingly is the generator at <a href="http://www.malevole.com/mv/misc/text/">http://www.malevole.com/mv/misc/text/</a>. There are some real classics in there&#8230;</p>
<p style="text-align:center;"><img src="http://geographika.files.wordpress.com/2007/08/mutley2.jpg" alt="Mutley" /></p>
<p><em>&#8220;Mutley, you snickering, floppy eared hound. When courage is needed, you&#8217;re never around. Those medals you wear on your moth-eaten chest should be there for bungling at which you are best. So, stop that pigeon, stop that pigeon, stop that pigeon, stop that pigeon, stop that pigeon, stop that pigeon, stop that pigeon. Howwww! Nab him, jab him, tab him, grab him, stop that pigeon now.&#8221;</em><br />
<a href="http://geographika.files.wordpress.com/2007/08/mutley.jpg" title="Mutley"></a></p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/yHnqu3yQEzU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/lorem-ipsum/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/lorem-ipsum?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=lorem-ipsum</feedburner:origLink></item>
		<item>
		<title>Operation must use an Updateable Query</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/56HQd2Q5GGg/operation-must-use-an-updateable-query</link>
		<comments>http://geographika.co.uk/operation-must-use-an-updateable-query#comments</comments>
		<pubDate>Tue, 14 Aug 2007 17:47:34 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[bugs]]></category>

		<guid isPermaLink="false">http://geographika.wordpress.com/2007/08/14/operation-must-use-an-updateable-query/</guid>
		<description><![CDATA[I know I see this error about once a year and can never remember the cause, so I&#8217;m writing it down this time! In my case it has always been related to SQL queries and Access databases. Check the following if your SQL command produces this error when executed: The database is not read only <a href='http://geographika.co.uk/operation-must-use-an-updateable-query'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>I know I see this error about once a year and can never remember the cause, so I&#8217;m writing it down this time!</p>
<p>In my case it has always been related to SQL queries and Access databases. Check the following if your SQL command produces this error when executed:</p>
<ol>
<li>The database is not read only &#8211; Visual Source Safe can often be a culprit in setting this property..</li>
<li>The SQL query may contain fields that are reserve words (e.g. DATE, TOP etc.). These should all be renamed in the database (I normally add an underscore at the end).</li>
<li>Go through a long and tedious process of which Windows user is running the SQL (ASPNET, IUSR_COMPUTERNAME etc.) and check thy have write permissions to the folder containing the database, and the database file itself. Remember Access needs to create those pesky .ldb lock files..</li>
</ol>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/56HQd2Q5GGg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/operation-must-use-an-updateable-query/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/operation-must-use-an-updateable-query?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=operation-must-use-an-updateable-query</feedburner:origLink></item>
		<item>
		<title>Podcasts and Python</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/i-nBgyotqSs/podcasts-and-python</link>
		<comments>http://geographika.co.uk/podcasts-and-python#comments</comments>
		<pubDate>Mon, 13 Aug 2007 17:45:06 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://geographika.wordpress.com/2007/08/13/podcasts-and-python/</guid>
		<description><![CDATA[I&#8217;ve been listening recently to &#8220;.NET Rocks!&#8221; twice weekly .NET development podcasts. It is very easy to listen to, mainly due to the personalities of the presenters, and it gives a good overview of .NET develpment and related technologies. Software development as a whole is often discussed &#8211; test driven development, agile programming, management, spaghetti <a href='http://geographika.co.uk/podcasts-and-python'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been listening recently to &#8220;.NET Rocks!&#8221; twice weekly .NET development podcasts. It is very easy to listen to, mainly due to the personalities of the presenters, and it gives a good overview of .NET develpment and related technologies. Software development as a whole is often discussed &#8211; test driven development, agile programming, management, spaghetti code&#8230;</p>
<p>A full <a href="http://www.dotnetrocks.com/archives.aspx">archive </a>of previous episodes is available for download (for free), and I found an epsiode that gives a good introduction to Python &#8211; it can be downloaded <a href="http://www.dotnetrocks.com/default.aspx?showNum=203">here</a>. I&#8217;m still not convinced of the use of Python and ArcObjects as explaining how to run scripts with parameters to GIS users, or creating custom toolboxes, takes as much time as creating a nice UI in Visual Studio. In the show one of the presenters asks &#8220;<em>but don&#8217;t you miss the Visual Studio environment and intellisense</em>?&#8221;, which I couldn&#8217;t agree more with. However there is also mention of IronPython, which I knew had something to do with .NET, but it can also apparently be used within the Visual Studio environment which could make life a whole lot easier.</p>
<p>I&#8217;m off to download <a href="http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython">IronPython </a>now&#8230;</p>
<p><a href="http://geographika.files.wordpress.com/2007/08/pyopengllogo.jpg" title="Python"><img src="http://geographika.files.wordpress.com/2007/08/pyopengllogo.jpg" alt="Python" /></a></p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/i-nBgyotqSs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/podcasts-and-python/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/podcasts-and-python?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=podcasts-and-python</feedburner:origLink></item>
		<item>
		<title>An End to Database Locks!</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/ZFNe1FtP0xQ/an-end-to-database-locks</link>
		<comments>http://geographika.co.uk/an-end-to-database-locks#comments</comments>
		<pubDate>Sat, 11 Aug 2007 12:23:53 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[arcobjects]]></category>

		<guid isPermaLink="false">http://geographika.wordpress.com/2007/08/11/an-end-to-database-locks/</guid>
		<description><![CDATA[Writing ArcObjects code and using an Access personal geodatabase will result sooner or later in an error along the lines of &#8220;Cannot aquire a schema lock because of an existing lock.&#8221; Spending hours going through code, making sure objects are disposed of and that all connections closed often makes very little difference. It becomes apparent <a href='http://geographika.co.uk/an-end-to-database-locks'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p><a href="wp-content/uploads/2007/08/locked.png" title="Locked!"></p>
<p style="text-align:center;"><img src="wp-content/uploads/2007/08/locked.png" alt="Locked!" /></p>
<p></a></p>
<p>Writing ArcObjects code and using an Access personal geodatabase will result sooner or later in an error along the lines of &#8220;Cannot aquire a schema lock because of an existing lock.&#8221; Spending hours going through code, making sure objects are disposed of and that all connections closed often makes very little difference. It becomes apparent some of the problems lie deeper than customised code when the same errors occur when using ArcMap or ArcCatalog without any modifications.</p>
<p>I have been using <a target="_blank" href="http://ccollomb.free.fr/unlocker/" title="Unlocker">Unlocker</a>, a freeware program, to solve these issues when developing with ArcObjects (or just using ArcMap..). Once installed a simple right click on an ldb or mdb file can remove any file locks, and your code is free to run again. It works with any Windows file or folder so is a useful program to have around even without geodatabases.</p>
<p>More reviews and an alternative download site can be found <a href="http://www.download.com/Unlocker/3640-2248_4-10637577.html" title="Download.Com">here</a>.</p>
<p><a href="http://geographika.files.wordpress.com/2007/08/locked_2.png" title="Unlocker"></p>
<p style="text-align:center;"><img src="http://geographika.files.wordpress.com/2007/08/locked_2.png" alt="Unlocker" /></p>
<p></a></p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/ZFNe1FtP0xQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/an-end-to-database-locks/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/an-end-to-database-locks?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=an-end-to-database-locks</feedburner:origLink></item>
		<item>
		<title>Starting With Python</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/foGE17xg7YE/starting-with-python</link>
		<comments>http://geographika.co.uk/starting-with-python#comments</comments>
		<pubDate>Mon, 09 Jul 2007 14:03:46 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://geographika.wordpress.com/2007/07/09/starting-with-python/</guid>
		<description><![CDATA[I have been writing a few geoprocessing scripts with Python recently, and have now even started to write scripts with more than one function.. I know I should sit down and read all the basics of a language first before using it, but where is the fun in that? I had written my main script, <a href='http://geographika.co.uk/starting-with-python'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>I have been writing a few geoprocessing scripts with Python recently, and have now even started to write scripts with more than one function..</p>
<p>I know I should sit down and read all the basics of a language first before using it, but where is the fun in that? I had written my main script, which called a couple of functions declared in the same .py file. I kept running into the following error:</p>
<p><em>&#8220;NameError: name &#8216;getMyFileTimes&#8217; is not defined&#8221;</em></p>
<p>After looking a few times at how to declare functions, I realised eventually that they have to be declared <strong>before </strong>calling them. E.g.</p>
<p><font face="Courier New">def hello <font color="#000000">(</font><font color="#000000">what</font><font color="#000000">)</font><font color="#000000">:</font><br />
<font color="#ffffff">     </font><font color="#000000">text = </font><font color="#2a00ff">&#8220;Hello, &#8221; </font><font color="#000000">+ what + </font><font color="#2a00ff">&#8220;!&#8221;</font><br />
<font color="#ffffff">     </font><font color="#000000">print text</font><br />
<font color="#ffffff"> </font><br />
<font color="#000000">hello </font><font color="#000000">(</font><font color="#2a00ff">&#8220;World&#8221;</font><font color="#000000">)</font></font></p>
<p>I guess I am still getting used to writing in a scripting language in what amounts to little more than notepad, and it makes sense that if it is not compiled and read line by line then the function would not be &#8220;seen.&#8221; Still I miss my autosensing, and Visual Studio debugging tools a lot&#8230;</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/foGE17xg7YE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/starting-with-python/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/starting-with-python?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=starting-with-python</feedburner:origLink></item>
		<item>
		<title>MS Access and Application.ExportXML</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/IlwdbcXPWLs/ms-access-and-applicationexportxml</link>
		<comments>http://geographika.co.uk/ms-access-and-applicationexportxml#comments</comments>
		<pubDate>Sat, 23 Jun 2007 19:07:02 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[bugs]]></category>

		<guid isPermaLink="false">http://geographika.wordpress.com/2007/06/23/ms-access-and-applicationexportxml/</guid>
		<description><![CDATA[Just spent a few hours bieng frustated by the error message &#8220;reserved error 2950&#8243; when trying to export a query from MS Access 2002. Turns out the problem was with one of the field names being &#8220;Size&#8221;, once renamed everything ran without problems. I guess this could apply to all reserved words.]]></description>
			<content:encoded><![CDATA[<p>Just spent a few hours bieng frustated by the error message &#8220;reserved error 2950&#8243; when trying to export a query from MS Access 2002.</p>
<p>Turns out the problem was with one of the field names being &#8220;Size&#8221;, once renamed everything ran without problems. I guess this could apply to all reserved words.</p>
<img src="http://feeds.feedburner.com/~r/geographika_feed/~4/IlwdbcXPWLs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geographika.co.uk/ms-access-and-applicationexportxml/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geographika.co.uk/ms-access-and-applicationexportxml?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=ms-access-and-applicationexportxml</feedburner:origLink></item>
		<item>
		<title>Adding Coordinates to a Map Layout</title>
		<link>http://feedproxy.google.com/~r/geographika_feed/~3/KBInNAiz46o/adding-coordinates-to-a-map-layout</link>
		<comments>http://geographika.co.uk/adding-coordinates-to-a-map-layout#comments</comments>
		<pubDate>Thu, 17 May 2007 15:44:57 +0000</pubDate>
		<dc:creator>geographika</dc:creator>
				<category><![CDATA[arcobjects]]></category>
		<category><![CDATA[esri]]></category>

		<guid isPermaLink="false">http://geographika.wordpress.com/2007/05/17/adding-coordinates-to-a-map-layout/</guid>
		<description><![CDATA[A recent request by an ArcMap was user was how to add the current coordinates of the dataframe to the map layout in ArcMap. I messed around with grids and labelling for a while before resorting to a VBA script. The code below should copied and pasted into the VBA Editor in ArcMap, and run when <a href='http://geographika.co.uk/adding-coordinates-to-a-map-layout'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>A recent request by an ArcMap was user was how to add the current coordinates of the dataframe to the map layout in ArcMap. I messed around with grids and labelling for a while before resorting to a VBA script.</p>
<p style="text-align:center;"><img src="http://geographika.files.wordpress.com/2007/05/map_text.png" alt="Coordinate Text" /></p>
<p>The code below should copied and pasted into the VBA Editor in ArcMap, and run when the current view is a page layout. The number of decimal places and distances of the text labels from the grid can be changed easily by modifying the relevant variable.</p>
<p style="margin:0;"><span style="color:#2b91af;">    1</span> <span style="color:blue;">Public</span> <span style="color:blue;">Sub</span> AddCornerText()</p>
<p style="margin:0;"><span style="color:#2b91af;">    2</span> </p>
<p style="margin:0;"><span style="color:#2b91af;">    3</span> <span style="color:blue;">Dim</span> pMxDoc <span style="color:blue;">As</span> IMxDocument</p>
<p style="margin:0;"><span style="color:#2b91af;">    4</span> <span style="color:blue;">Dim</span> pActiveView <span style="color:blue;">As</span> IActiveView</p>
<p style="margin:0;"><span style="color:#2b91af;">    5</span> <span style="color:blue;">Dim</span> pLayoutExtent <span style="color:blue;">As</span> IEnvelope</p>
<p style="margin:0;"><span style="color:#2b91af;">    6</span> <span style="color:blue;">Dim</span> strText <span style="color:blue;">As</span> <span style="color:blue;">String</span></p>
<p style="margin:0;"><span style="color:#2b91af;">    7</span> <span style="color:blue;">Dim</span> pMapFrame <span style="color:blue;">As</span> IFrameElement</p>
<p style="margin:0;"><span style="color:#2b91af;">    8</span> <span style="color:blue;">Dim</span> pGraphic <span style="color:blue;">As</span> IElement</p>
<p style="margin:0;"><span style="color:#2b91af;">    9</span> <span style="color:blue;">Dim</span> dblOffset <span style="color:blue;">As</span> <span style="color:blue;">Double</span></p>
<p style="margin:0;"><span style="color:#2b91af;">   10</span> <span style="color:blue;">Dim</span> lngRound <span style="color:blue;">As</span> <span style="color:blue;">Long</span></p>
<p style="margin:0;"><span style="color:#2b91af;">   11</span> </p>
<p style="margin:0;"><span style="color:#2b91af;">   12</span> <span style="color:green;">&#8216;this is the offset used so the text does not overlap the map</span></p>
<p style="margin:0;"><span style="color:#2b91af;">   13</span> <span style="color:green;">&#8216;modify according to needs</span></p>
<p style="margin:0;"><span style="color:#2b91af;">   14</span> dblOffset = 0.2</p>
<p style="margin:0;"><span style="color:#2b91af;">   15</span> </p>
<p style="margin:0;"><span style="color:#2b91af;">   16</span> <span style="color:green;">&#8216;this is the number of decimal places used for each coordinate value</span></p>
<p style="margin:0;"><span style="color:#2b91af;">   17</span> lngRound = 0</p>
<p style="margin:0;"><span style="color:#2b91af;">   18</span> </p>
<p style="margin:0;"><span style="color:#2b91af;">   19</span> <span style="color:blue;">Set</span> pMxDoc = ThisDocument</p>
<p style="margin:0;"><span style="color:#2b91af;">   20</span> <span style="color:blue;">Set</span> pActiveView = pMxDoc.FocusMap</p>
<p style="margin:0;"><span style="color:#2b91af;">   21</span> </p>
<p style="margin:0;"><span style="color:#2b91af;">   22</span> <span style="color:green;">&#8216;find the map data frame in the layout</span></p>
<p style="margin:0;"><span style="color:#2b91af;">   23</span> </p>
<p style="margin:0;"><span style="color:#2b91af;">   24</span> <span style="color:blue;">Set</span> pMapFrame = pMxDoc.ActiveView.GraphicsContainer.FindFrame(pMxDoc.ActiveView.FocusMap)</p>
<p style="margin:0;"><span style="color:#2b91af;">   25</span> <span style="color:blue;">Set</span> pGraphic = pMapFrame</p>
<p style="margin:0;"><span style="color:#2b91af;">   26</span> <span style="color:blue;">Set</span> pLayoutExtent = pGraphic.Geometry.Envelope</p>
<p style="margin:0;"><span style="color:#2b91af;">   27</span> </p>
<p style="margin:0;"><span style="color:#2b91af;">   28</span> <span style="color:green;">&#8216;create the bottom left point and text</span></p>
<p style="margin:0;"><span style="color:#2b91af;">   29</span> strText = Round(pActiveView.Extent.XMin, lngRound) &amp; _</p>
<p style="margin:0;"><span style="color:#2b91af;">   30</span> <span style="color:#a31515;">&#8220;:&#8221;</span> &amp; Round(pActiveView.Extent.YMin, lngRound)</p>
<p style="margin:0;"><span style="color:#2b91af;">   31</span> AddPoint pLayoutExtent.XMin &#8211; dblOffset, pLayoutExtent.YMin &#8211; dblOffset, strText</p>
<p style="margin:0;"><span style="color:#2b91af;">   32</span> </p>
<p style="margin:0;"><span style="color:#2b91af;">   33</span> <span style="color:green;">&#8216;create the top left point and text</span></p>
<p style="margin:0;"><span style="color:#2b91af;">   34</span> strText = Round(pActiveView.Extent.XMin, lngRound) &amp; _</p>
<p style="margin:0;"><span style="color:#2b91af;">   35</span> <span style="color:#a31515;">&#8220;:&#8221;</span> &amp; Round(pActiveView.Extent.YMax, lngRound)</p>
<p style="margin:0;"><span style="color:#2b91af;">   36</span> AddPoint pLayoutExtent.XMin &#8211; dblOffset, pLayoutExtent.YMax + dblOffset, strText</p>
<p style="margin:0;"><span style="color:#2b91af;">   37</span> </p>
<p style="margin:0;"><span style="color:#2b91af;">   38</span> <span style="color:green;">&#8216;create the bottom right point and text</span></p>
<p style="margin:0;"><span style="color:#2b91af;">   39</span> strText = Round(pActiveView.Extent.XMax, lngRound) &amp; _</p>
<p style="margin:0;"><span style="color:#2b91af;">   40</span> <span style="color:#a31515;">&#8220;:&#8221;</span> &amp; Round(pActiveView.Extent.YMin, lngRound)</p>
<p style="margin:0;"><span style="color:#2b91af;">   41</span> AddPoint pLayoutExtent.XMax + dblOffset, pLayoutExtent.YMin &#8211; dblOffset, strText</p>
<p style="margin:0;"><span style="color:#2b91af;">   42</span> </p>
<p style="margin:0;"><span style="color:#2b91af;">   43</span> <span style="color:green;">&#8216;create the top right point and text</span></p>
<p style="margin:0;"><span style="color:#2b91af;">   44</span> strText = Round(pActiveView.Extent.XMax, lngRound) &amp; _</p>
<p style="margin:0;"><span style="color:#2b91af;">   45</span> <span style="color:#a31515;">&#8220;:&#8221;</span> &amp; Round(pActiveView.Extent.YMax, lngRound)</p>
<p style="margin:0;"><span style="color:#2b91af;">   46</span> AddPoint pLayoutExtent.XMax + dblOffset, pLayoutExtent.YMax + dblOffset, strText</p>
<p style="margin:0;"><span style="color:#2b91af;">   47</span> </p>
<p style="margin:0;"><span style="color:#2b91af;">   48</span> </p>
<p style="margin:0;"><span style="color:#2b91af;">   49</span> pMxDoc.ActiveView.Refresh</p>
<p style="margin:0;"><span style="color:#2b91af;">   50</span> </p>
<p style="margin:0;"><span style="color:#2b91af;">   51</span> <span style="color:blue;">End</span> <span style="color:blue;">Sub</span></p>
<p style="margin:0;"><span style="color:#2b91af;">   52</span> </p>
<p style="margin:0;"><span style="color:#2b91af;">   53</span> <span style="color:blue;">Private</span> <span style="color:blue;">Sub</span> AddPoint(dblX <span style="color:blue;">As</span> <span style="color:blue;">Double</span>, dblY <span style="color:blue;">As</span> <span style="color:blue;">Double</span>, strText <span style="color:blue;">As</span> <span style="color:blue;">String</span>)</p>
<p style="margin:0;"><span style="color:#2b91af;">   54</span> </p>
<p style="margin:0;"><span style="color:#2b91af;">   55</span> <span style="color:blue;">Dim</span> pMxDoc <span style="color:blue;">As</span> IMxDocument</p>
<p style="margin:0;"><span style="color:#2b91af;">   56</span> <span style="color:blue;">Dim</span> pPoint <span style="color:blue;">As</span> IPoint</p>
<p style="margin:0;"><span style="color:#2b91af;">   57</span> <span style="color:blue;">Dim</span> pTextElement <span style="color:blue;">As</span> ITextElement</p>
<p style="margin:0;"><span style="color:#2b91af;">   58</span> <span style="color:blue;">Dim</span> pPageLayout <span style="color:blue;">As</span> IPageLayout</p>
<p style="margin:0;"><span style="color:#2b91af;">   59</span> <span style="color:blue;">Dim</span> pElement <span style="color:blue;">As</span> IElement</p>
<p style="margin:0;"><span style="color:#2b91af;">   60</span> <span style="color:blue;">Dim</span> pGContainer <span style="color:blue;">As</span> IGraphicsContainer</p>
<p style="margin:0;"><span style="color:#2b91af;">   61</span> </p>
<p style="margin:0;"><span style="color:#2b91af;">   62</span> <span style="color:blue;">Set</span> pMxDoc = ThisDocument</p>
<p style="margin:0;"><span style="color:#2b91af;">   63</span> </p>
<p style="margin:0;"><span style="color:#2b91af;">   64</span> <span style="color:green;">&#8216;create the location for the text</span></p>
<p style="margin:0;"><span style="color:#2b91af;">   65</span> </p>
<p style="margin:0;"><span style="color:#2b91af;">   66</span> <span style="color:blue;">Set</span> pPoint = <span style="color:blue;">New</span> Point</p>
<p style="margin:0;"><span style="color:#2b91af;">   67</span> pPoint.X = dblX</p>
<p style="margin:0;"><span style="color:#2b91af;">   68</span> pPoint.Y = dblY</p>
<p style="margin:0;"><span style="color:#2b91af;">   69</span> </p>
<p style="margin:0;"><span style="color:#2b91af;">   70</span> <span style="color:green;">&#8216;create the text element</span></p>
<p style="margin:0;"><span style="color:#2b91af;">   71</span> </p>
<p style="margin:0;"><span style="color:#2b91af;">   72</span> <span style="color:blue;">Set</span> pTextElement = <span style="color:blue;">New</span> TextElement</p>
<p style="margin:0;"><span style="color:#2b91af;">   73</span> pTextElement.Text = strText</p>
<p style="margin:0;"><span style="color:#2b91af;">   74</span> </p>
<p style="margin:0;"><span style="color:#2b91af;">   75</span> <span style="color:green;">&#8216;add the element to the layout</span></p>
<p style="margin:0;"><span style="color:#2b91af;">   76</span> </p>
<p style="margin:0;"><span style="color:#2b91af;">   77</span> <span style="color:blue;">Set</span> pPageLayout = pMxDoc.PageLayout</p>
<p style="margin:0;"><span style="color:#2b91af;">   78</span> <span style="color:blue;">Set</span> pElement = pTextElement</p>
<p style="margin:0;"><span style="color:#2b91af;">   79</span> pElement.Geometry = pPoint</p>
<p style="margin:0;"><span style="color:#2b91af;">   80</span> <span style="color:blue;">Set</span> pGContainer = pPageLayout</p>
<p style="margin:0;"><span style="color:#2b91af;">   81</span> pGContainer.AddElement pElement, 0</p>
<p style="margin:0;"><span style="color:#2b91af;">   82</span> </p>
<p style="margin:0;"><span style="color:#2b91af;"> 
