<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>BritishIdeas &#187; Mapping</title>
	<atom:link href="http://www.britishideas.com/category/mapping/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.britishideas.com</link>
	<description>Interesting Tech Projects</description>
	<lastBuildDate>Sun, 23 Oct 2011 20:05:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>50,000 Point GPS Track in Silverlight</title>
		<link>http://www.britishideas.com/2011/03/01/50000-point-gps-track-in-silverlight/</link>
		<comments>http://www.britishideas.com/2011/03/01/50000-point-gps-track-in-silverlight/#comments</comments>
		<pubDate>Tue, 01 Mar 2011 23:45:14 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Mapping]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[moonlight]]></category>
		<category><![CDATA[OpenStreetMap]]></category>
		<category><![CDATA[silverlight]]></category>

		<guid isPermaLink="false">http://www.britishideas.com/?p=342</guid>
		<description><![CDATA[About six months ago I posted a video showing a GPS track with 7,000 points in a slippy map control called DeepEarth. If you watch the video you can see that the track lags behind the map a little and I think I was at the limit of what was usable.

Yesterday I wrote about my]]></description>
			<content:encoded><![CDATA[<p>About six months ago I posted a video showing a GPS track with 7,000 points in a slippy map control called DeepEarth. If you watch the video you can see that the track lags behind the map a little and I think I was at the limit of what was usable.</p>
<p><object width="500" height="306"><param name="movie" value="http://www.youtube.com/e/22MOWEAzmoY"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/e/22MOWEAzmoY" type="application/x-shockwave-flash" width="500" height="306" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://www.britishideas.com/2011/02/28/50000-map-markers-in-silverlight/" target="_blank">Yesterday I wrote about my new C# based slippy map control</a> for Silverlight and Moonlight that can display 50,000 map markers and I wanted to see what it&#8217;s performance was like for a GPS track. I created a random track with 50,000 points in it to simulate a track from a GPS unit. Here is the result.<span id="more-342"></span></p>
<p><object width="500" height="400"><param name="movie" value="http://www.youtube.com/e/c15mpw_2zt0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/e/c15mpw_2zt0" type="application/x-shockwave-flash" width="500" height="400" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>Both videos were made on the same cheap Core 2 Duo laptop while running off the battery. As you can see there is no lag while panning and only a small delay when zooming in and out.</p>
<p>For anyone interested here is how I generated the test track.</p>
<pre class="brush: csharp;">
Random Rand = new Random();
Line Track = new Line();
LonLat Point = new LonLat((Rand.NextDouble() * 0.1) - 1.0, (Rand.NextDouble() * 0.1) + 53.0);
for (int i = 0; i &lt; 50000; i++)
{
    Point = new LonLat(Point.Longitude + ((Rand.NextDouble() - 0.5) * 0.001),
        Point.Latitude + ((Rand.NextDouble() - 0.5) * 0.001));
    Track.Points.Add(Point);
}
LineLayer TrackLayer = new LineLayer(&quot;Tracks&quot;, Colors.Orange, 3.0, 0.75);
TrackLayer.Lines.Add(Track);
SlippyMap.AddLayer(TrackLayer);
</pre>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d342').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark to:</em></strong></a>
<br />
<div class="d342" style="overflow:hidden">
<br />
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d342').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d342').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://www.britishideas.com/2011/03/01/50000-point-gps-track-in-silverlight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>50,000 Map Markers in Silverlight</title>
		<link>http://www.britishideas.com/2011/02/28/50000-map-markers-in-silverlight/</link>
		<comments>http://www.britishideas.com/2011/02/28/50000-map-markers-in-silverlight/#comments</comments>
		<pubDate>Mon, 28 Feb 2011 23:16:01 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Mapping]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[moonlight]]></category>
		<category><![CDATA[OpenStreetMap]]></category>
		<category><![CDATA[silverlight]]></category>

		<guid isPermaLink="false">http://www.britishideas.com/?p=331</guid>
		<description><![CDATA[There are a range of pan and zoom map controls (sometimes called slippy maps) available for C#/.NET and Silverlight/Moonlight. All the ones I&#8217;ve seen have something in common &#8211; they are bloated. The authors attempt to address the needs of as many users as possible and the result is large downloads and far too many]]></description>
			<content:encoded><![CDATA[<p>There are a range of pan and zoom map controls (sometimes called slippy maps) available for C#/.NET and Silverlight/Moonlight. All the ones I&#8217;ve seen have something in common &#8211; they are bloated. The authors attempt to address the needs of as many users as possible and the result is large downloads and far too many features. The forums and mailing lists are full of people asking how to achieve basic functionality because they are lost in the vast realm of classes.</p>
<p>Of course, it is possible to remove what you don&#8217;t need but that requires understanding the code and after all that effort you are left with code that might not have the right license for your needs. The solution? Time to cringe &#8211; reinventing the wheel.</p>
<p>Fortunately it&#8217;s not much of a wheel, assuming your requirements are simple as mine are. C# and good development tools (Visual Studio and MonoDevelop) makes it easy to quickly develop a lightweight and flexible slippy map that can be used in Windows, Mac OS X and Linux (using Moonlight).<span id="more-331"></span></p>
<p>My first attempt at displaying markers worked ok but suffered from poor performance, however I found a few ways to optimize the rendering. As a test I decided to see how far I could push my luck.</p>
<pre class="brush: csharp;">
Random Rand = new Random();
PerformanceMarkerLayer TestLayer = new PerformanceMarkerLayer(&quot;Test&quot;);
for (int i = 0; i &lt; 50000; i++)
{
    TestLayer.Markers.Add(new Marker(new LonLat(Rand.NextDouble() - 1.0,
    Rand.NextDouble() + 53.0)));
}
SlippyMap.AddLayer(TestLayer);
</pre>
<p>This creates a map with 50,000 individually clickable markers. Panning is fluid and zooming has a delay of about six seconds. This is on a cheap Core 2 Duo laptop running off the battery. Interestingly increasing the number of markers to 80,000 does not slow down the panning at all but does increase the zoom delay by 1/3, so it appears that the zoom delay has a linear relationship with the number of markers but the panning does not.</p>
<p><object width="500" height="400"><param name="movie" value="http://www.youtube.com/e/Vb32KtgsU2E"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/e/Vb32KtgsU2E" type="application/x-shockwave-flash" width="500" height="400" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>I can already think of several ways of reducing the zoom delay but as I don&#8217;t plan on creating maps with this many markers in the near future I will likely leave it for now &#8211; too many other things to do.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d331').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark to:</em></strong></a>
<br />
<div class="d331" style="overflow:hidden">
<br />
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d331').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d331').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://www.britishideas.com/2011/02/28/50000-map-markers-in-silverlight/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Poster Map of East Yorkshire</title>
		<link>http://www.britishideas.com/2011/01/19/poster-map-of-east-yorkshire/</link>
		<comments>http://www.britishideas.com/2011/01/19/poster-map-of-east-yorkshire/#comments</comments>
		<pubDate>Wed, 19 Jan 2011 23:35:03 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Mapping]]></category>
		<category><![CDATA[maperitive]]></category>
		<category><![CDATA[OpenStreetMap]]></category>
		<category><![CDATA[poster]]></category>

		<guid isPermaLink="false">http://www.britishideas.com/?p=327</guid>
		<description><![CDATA[Using data from the OpenStreetMap project (taken a couple of days ago) along with some utilities such as Maperitive and custom software, I have generated a 39 inch x 31 inch poster of the East Riding of Yorkshire. This map includes hillshading and contour lines and individual streets can be seen.
Some assembly is required. Print]]></description>
			<content:encoded><![CDATA[<p>Using data from the <a href="http://www.openstreetmap.org" target="_blank">OpenStreetMap</a> project (taken a couple of days ago) along with some utilities such as <a href="http://www.maperitive.net" target="_blank">Maperitive</a> and custom software, I have generated a <a href="/wp-content/uploads/2011/01/EastYorkshire.pdf">39 inch x 31 inch poster of the East Riding of Yorkshire</a>. This map includes hillshading and contour lines and individual streets can be seen.</p>
<p>Some assembly is required. Print it out on A4 paper, cut out the sheets and then glue them together. <a href="/wp-content/uploads/2011/01/EastYorkshire.pdf">Download it here</a>.</p>
<p>Here is a sample:</p>
<p><a href="http://www.britishideas.com/wp-content/uploads/2011/01/mapsample.jpg"><img class="aligncenter size-medium wp-image-328" title="Map Sample" src="http://www.britishideas.com/wp-content/uploads/2011/01/mapsample-300x176.jpg" alt="" width="300" height="176" /></a></p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d327').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark to:</em></strong></a>
<br />
<div class="d327" style="overflow:hidden">
<br />
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d327').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d327').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://www.britishideas.com/2011/01/19/poster-map-of-east-yorkshire/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>So You Want to be a Cartographer?</title>
		<link>http://www.britishideas.com/2011/01/16/so-you-want-to-be-a-cartographer/</link>
		<comments>http://www.britishideas.com/2011/01/16/so-you-want-to-be-a-cartographer/#comments</comments>
		<pubDate>Sun, 16 Jan 2011 22:21:49 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Mapping]]></category>
		<category><![CDATA[JOSM]]></category>
		<category><![CDATA[maperitive]]></category>
		<category><![CDATA[OpenStreetMap]]></category>
		<category><![CDATA[rendering]]></category>

		<guid isPermaLink="false">http://www.britishideas.com/?p=293</guid>
		<description><![CDATA[Love maps? Want to make your own? Now it&#8217;s easy thanks to a set of free software.
Previously I wrote about the OpenStreetMap project, which allows anyone to edit a map of the world. People can add points, lines and areas and &#8220;tag&#8221; them to show what they are. Once the data is uploaded a new]]></description>
			<content:encoded><![CDATA[<p>Love maps? Want to make your own? Now it&#8217;s easy thanks to a set of free software.</p>
<p>Previously I wrote about the <a href="http://www.openstreetmap.org" target="_blank">OpenStreetMap</a> project, which allows anyone to edit a map of the world. People can add points, lines and areas and &#8220;tag&#8221; them to show what they are. Once the data is uploaded a new version of the map is generated for everyone to see.</p>
<p>For example I could create a point on the map and tag it with &#8220;railway=station&#8221; to indicate that it is a train station. I could draw a line and tag it with &#8220;highway=residential&#8221; to mark the line as a residential road. I could also draw an enclosed area and tag it with &#8220;landuse=forest&#8221; to show that the area is a forest. There are many different tags that can be used to represent all kinds of things that appear on maps.</p>
<p>This article is in the form of a tutorial to get you quickly started creating your own maps. I will introduce the software involved and show how to use it step by step. The result of the tutorial is a map of the <a href="http://www.nymr.co.uk/" target="_blank">North Yorkshire Moors Railway</a>, which is a steam train service on a historic train line in England and is featured in the Harry Potter films.</p>
<p><span id="more-293"></span></p>
<p><strong>Get the Data</strong></p>
<p>To quickly get started we will use some map data from the OpenStreetMap project. This data has a <a href="http://www.openstreetmap.org/copyright" target="_blank">license</a> which you must follow, however you can create your own map data from scratch, either by using a GPS/hiking SatNav unit to perform surveys or even create maps of imaginary places or recreate historical maps.</p>
<p>The first piece of software is the map editor, called <a href="http://josm.openstreetmap.de/josm-latest.jar">JOSM</a>. This is downloaded to your PC and you can run it by double-clicking on the file. You must have <a href="http://www.java.com/en/download/manual.jsp" target="_blank">Java</a> installed on your PC if you don&#8217;t already.</p>
<p><a href="http://www.britishideas.com/wp-content/uploads/2011/01/josmnew.png"><img class="aligncenter size-medium wp-image-299" title="JOSM" src="http://www.britishideas.com/wp-content/uploads/2011/01/josmnew-300x188.png" alt="" width="300" height="188" /></a></p>
<p>To download data in JOSM go to the File menu and choose Download from OSM&#8230; a window showing a map will appear. You can scroll around by dragging and zoom in and out using the mouse wheel.</p>
<p>Find the town of Pickering in the north of England and drag a box from Pickering to Whitby, being sure to include both towns as shown in the image. Then click on Download.</p>
<p><a href="http://www.britishideas.com/wp-content/uploads/2011/01/josmselectbox.png"><img class="aligncenter size-medium wp-image-295" title="Select Map Area in JOSM" src="http://www.britishideas.com/wp-content/uploads/2011/01/josmselectbox-290x300.png" alt="" width="290" height="300" /></a></p>
<p>Once the data has downloaded it will show in JOSM as lots of multicoloured ponts, lines and areas.</p>
<p><a href="http://www.britishideas.com/wp-content/uploads/2011/01/josmdownloaded2.png"><img class="aligncenter size-medium wp-image-298" title="Downloaded Data in JOSM" src="http://www.britishideas.com/wp-content/uploads/2011/01/josmdownloaded2-300x188.png" alt="" width="300" height="188" /></a></p>
<p>At this point you could edit the map by clicking on items and then changing the tags, however that is outside the scope of this tutorial. For more information see the <a href="http://josm.openstreetmap.de/wiki/Help" target="_blank">JOSM documentation</a>. For now simply save the data without changing it by going to the File menu and choosing Save As&#8230; Save the file as nymr.osm in an empty folder.</p>
<p><strong>Render the Map</strong></p>
<p>The software we will use to render the map is called <a href="http://maperitive.net/download/" target="_blank">Maperitive</a>. Download the latest version (the one with the largest number), install it on your PC then start the application.</p>
<p><a href="http://www.britishideas.com/wp-content/uploads/2011/01/mapstart.jpg"><img class="aligncenter size-medium wp-image-306" title="Maperitive" src="http://www.britishideas.com/wp-content/uploads/2011/01/mapstart-300x217.jpg" alt="" width="300" height="217" /></a></p>
<p>The map shown is not from our data so the first thing we need to do is get rid of it. Click in the Command Prompt box at the bottom so it turns yellow. The command is &#8220;clear-map&#8221; however you can&#8217;t simply type it in as Maperitive tries to guess the command you want. This means that after every key press you need to stop typing and look at the yellow box to see what has happened. In practice for this command you will need to type &#8220;cl&#8221; followed by &#8220;m&#8221;. Press Enter and the map will dissappear.</p>
<p>Next we need to switch to the folder where you saved your copy of nymr.osm. Here is an example:</p>
<pre class="brush: plain;">change-dir C:\Users\Andy\Desktop\temp\NYMR</pre>
<p>Next load the data and set the edge of the map to match the data:</p>
<pre class="brush: plain;">load-source nymr.osm
bounds-use-source</pre>
<p><a href="http://www.britishideas.com/wp-content/uploads/2011/01/mapdataloaded.jpg"><img class="aligncenter size-medium wp-image-311" title="Data loaded in Maperitive" src="http://www.britishideas.com/wp-content/uploads/2011/01/mapdataloaded-300x217.jpg" alt="" width="300" height="217" /></a></p>
<p>Show is a rendering of your map along with a dotted line around the edge to show the boundary. When you save the map later nothing outside of the dotted line will be included.</p>
<p>The map works in the same was as JOSM. You can scroll around by clicking and dragging and zoom in and out using the mouse wheel. To reset the view to show the entire map go to the View menu and choose Zoom All.</p>
<p>One thing you will immediately notice is the large pink dashes on the map. They remind me of pictures of bacteria under a microscope but in our case they are trails that have been marked as private. The first thing we need to do is reduce the size of these to something a bit more appropriate for the map scale, and for that we need to discuss rules.</p>
<p><strong>Renderer Rules</strong></p>
<p>As mentioned before, the map is made up of points, lines and areas. Maperitive uses a set of rules to determine how these are shown on the map. For example a rule for residential roads says to draw it in white with a black border and at a specific width. In order to change how the map looks we have to change the rules. Maperitive uses a default set of rules and we need to change these for every map to focus on the things we want to show.</p>
<p>In Maperitive enter the command:</p>
<pre class="brush: plain;">edit-rules</pre>
<p>This will open a text editor showing the default rules. Save this file as rules.txt into the folder where you saved nymr.osm. Keep the text editor open.</p>
<p>Next we tell Maperitive to use our newly saved rules file:</p>
<pre class="brush: plain;">use-ruleset location=rules.txt as-alias=myrules
apply-ruleset</pre>
<p>The map should look the same, however every time we edit and save the rules file the map will automatically update to show the new version of the map.</p>
<p>Search for the following line:</p>
<pre class="brush: plain;">target : highway private</pre>
<p>and below it you will find the rules for showing private &#8220;highways&#8221;, which includes tracks:</p>
<pre class="brush: plain;">target : highway private
define
line-width : 4
line-style : dash
line-color : #F7D4D4
draw : line</pre>
<p>Change the line-width from 4 to 1 and save the file. The thick pink track lines on the map will be replaced with thin lines.</p>
<p>It is important to note that the indentation in the Maperitive rules file is important and must always be used with tabs. For example don&#8217;t use spaces as it won&#8217;t work.</p>
<p><strong>Customizing the Map</strong></p>
<p>The central area of the map shows the North Yorkshire Moors, which is a hilly region and could be made more interesting. We can do that by adding three additional layers to the map, all of which are available from the Tools menu in Maperitive.</p>
<p>First, add contour lines. These show the height of the land, and are added by going to the Tools menu and choosing Generate Relief Contours.</p>
<p>Next add hillshading. This is a trick to make the map look three dimensional by showing shadows on the south and eastern sides of raised land. To add this go to the Tools menu and choose of the Generate Hillshading items. You can do this multiple times for more emphasis if you want.</p>
<p>The last step is to change the color of the land to indicate the height, which is called hypsometric tinting. Adding this layer makes the map look like it comes from a beautiful atlas. Add it by choosing Generate Hypsometric Tinting from the Tools menu.</p>
<p><a href="http://www.britishideas.com/wp-content/uploads/2011/01/maplayered.jpg"><img class="aligncenter size-medium wp-image-317" title="Layered Map in Maperitive" src="http://www.britishideas.com/wp-content/uploads/2011/01/maplayered-300x217.jpg" alt="" width="300" height="217" /></a></p>
<p>If you look at the bottom of the Maperitive window you will see the current zoom level. The zoom level increases as you zoom into the map, with level 18 being the current maximum. In the rules the maximum and minimum zoom levels are often specified. This allows more features to be shown as you zoom into the map and less as you zoom out. Railway lines are one of the items that are not shown when zoomed out, so we need to change that.</p>
<p>Find the entry for</p>
<pre class="brush: plain;">target: railway</pre>
<p>and change the first two min-zoom entries from 13 to 8. Save the file. The map will now show the full-time commercial railway line from Whitby.</p>
<p><a href="http://www.britishideas.com/wp-content/uploads/2011/01/maplineadded.gif"><img class="aligncenter size-medium wp-image-318" title="Railway Line in Maperitive" src="http://www.britishideas.com/wp-content/uploads/2011/01/maplineadded-300x102.gif" alt="" width="300" height="102" /></a></p>
<p>Next we need to show the railway stations, which are currently not rendered at all. The rules file starts with:</p>
<pre class="brush: plain;">features
 points, areas</pre>
<p>below this are a set of target name descriptions. Add a new entry, making sure to indent it with tabs:</p>
<pre class="brush: plain;">railway station: railway=station</pre>
<p>Again find:</p>
<pre class="brush: plain;">target : railway</pre>
<p>and just above that line add a new rule, making sure to copy the indentation that is used for similar rules:</p>
<pre class="brush: plain;">target : railway station
 define
 min-zoom : 8
 shape : circle
 shape-size : 10
 line-color : gray
 line-width : 2
 fill-color : red
 fill-opacity : 1
 draw : shape</pre>
<p>Save the file and the map will now show red circles for the train stations.</p>
<p><a href="http://www.britishideas.com/wp-content/uploads/2011/01/mapstations.jpg"><img class="aligncenter size-medium wp-image-319" title="Railway Stations in Maperitive" src="http://www.britishideas.com/wp-content/uploads/2011/01/mapstations-270x300.jpg" alt="" width="270" height="300" /></a></p>
<p>Finally we need to add a target description for preserved railways and a rule on how they should be rendered. Below the &#8220;lines&#8221; heading of the &#8220;features&#8221; section at the start of the rules file add:</p>
<pre class="brush: plain;">preserved railway: railway=preserved</pre>
<p>then above the railway station rule add the rule (again with the correct indentation):</p>
<pre class="brush: plain;">target : preserved railway
 define
 min-zoom : 8
 line-color : black
 line-width : 3
 draw : line
 define
 min-zoom : 8
 line-style : dashlong
 line-color : white
 line-width : 3
 border-style : solid
 border-color : black
 border-width : 25%
 draw : line</pre>
<p>Save to render the North Yorkshire Moors Railway line.</p>
<p><a href="http://www.britishideas.com/wp-content/uploads/2011/01/mapfinal.jpg"><img class="aligncenter size-medium wp-image-320" title="Final Map in Maperitive" src="http://www.britishideas.com/wp-content/uploads/2011/01/mapfinal-300x213.jpg" alt="" width="300" height="213" /></a></p>
<p><strong>Export the Map</strong></p>
<p>To save the map as a bitmap enter the command:</p>
<pre class="brush: plain;">export-bitmap file=nymr.png scale=6</pre>
<p>Here is the final map (click to view):</p>
<p><a href="http://www.britishideas.com/wp-content/uploads/2011/01/nymr-web.jpg"><img class="aligncenter size-medium wp-image-322" title="Final Map" src="http://www.britishideas.com/wp-content/uploads/2011/01/nymr-web-176x300.jpg" alt="" width="176" height="300" /></a></p>
<p>Now you can edit it to add labels, borders, a compass rose, etc.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d293').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark to:</em></strong></a>
<br />
<div class="d293" style="overflow:hidden">
<br />
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d293').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d293').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://www.britishideas.com/2011/01/16/so-you-want-to-be-a-cartographer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimizing DeepEarth For GIS Mapping</title>
		<link>http://www.britishideas.com/2010/09/05/optimizing-deepearth-for-gis-mapping/</link>
		<comments>http://www.britishideas.com/2010/09/05/optimizing-deepearth-for-gis-mapping/#comments</comments>
		<pubDate>Mon, 06 Sep 2010 05:02:07 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Mapping]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[OpenStreetMap]]></category>
		<category><![CDATA[silverlight]]></category>

		<guid isPermaLink="false">http://www.britishideas.com/?p=281</guid>
		<description><![CDATA[DeepEarth is an interesting Silverlight project. It allows interactive tile-based maps to run in a browser with overlays of custom data, however it suffers from some performance problems.
Large GPS Track Logs
I had the need to display GPS tracks in DeepEarth. GPS tracks can contain thousands of points. DeepEarth has three update modes called ElementUpdate, PanOnlyUpdate]]></description>
			<content:encoded><![CDATA[<p><a href="http://deepearth.codeplex.com/" target="_blank">DeepEarth</a> is an interesting <a href="http://www.silverlight.net/" target="_blank">Silverlight</a> project. It allows interactive tile-based maps to run in a browser with overlays of custom data, however it suffers from some performance problems.</p>
<p><strong>Large GPS Track Logs</strong></p>
<p>I had the need to display GPS tracks in DeepEarth. GPS tracks can contain thousands of points. DeepEarth has three update modes called ElementUpdate, PanOnlyUpdate and TransformUpdate for showing features such as tracks:</p>
<ul>
<li>ElementUpdate recalculates the point positions on every map movement. This produces an accurate track display but gets slower as the number of points increases.</li>
<li>PanOnlyUpdate recalculates point positions during panning and hides features while zooming. Not too useful for me and didn&#8217;t seem to show anything anyway.</li>
<li>TransformUpdate draws the tracks to the map once then scales and pans the vector graphic in synchronization with the map. This makes it very fast. Sadly the scaling code is flawed. Lines disappear as you zoom in and sections of the tracks become distorted, almost looking like calligraphy.</li>
</ul>
<p>I wasted many evenings trying to get the scaling in TransformUpdate mode working before giving up. I then turned my attention back to the ElementUpdate mode to see where the bottleneck is.<span id="more-281"></span></p>
<p><strong>The LogicalToPixel Function</strong></p>
<p>LineStringControl objects represent the GPS tracks and they draw as lines using multiple points. When points are added to a LineStringControl they are transformed from longitude and latitude into logical coordinates. This is an intermediate coordinate system that can easily be converted into pixel coordinates later.</p>
<p>When the map is panned or zoomed the CoordTransform.LogicalToPixel function is called for every point in line. This function uses some simple mathematics to work out where the point should be on the map in terms of pixels. This is the bottleneck.</p>
<p>A single zoom or pan operation can result in this function being called several times. If a GPS track has 7,000 points that is a lot of calls. My testing showed that even the very first mathematical operation caused considerable slow down. Overall this function had several problems:</p>
<ul>
<li>Using 64-bit division</li>
<li>Creating three Point objects and then discarding two for each call</li>
<li>Using Math.Log and Math.Pow functions</li>
</ul>
<p><strong>Optimizing LogicalToPixel</strong></p>
<p>The first step was to separate out the mathematical operations into two groups:</p>
<ul>
<li>Those that can be executed once per movement of the map</li>
<li>Those that have to be executed once per point</li>
</ul>
<p>I split the function into two new functions, LogicalToPixelPrepare and LogicalToPixelPerform to allow the two groups to be called separately.</p>
<p>Next instead of creating two temporary Point objects and then throwing them away, two global (to the class) Point objects are created and continually reused. This eliminates any overhead of object creation.</p>
<p>Finally I saw that I could eliminate both Math.Log and Math.Pow, as they were not necessary.</p>
<p>The last step was to modify the GeometryLayer.UpdatePathData function to call LogicalToPixelPrepare once and then LogicalToPixelPerform for every point. This reduces the transformation code needed for every point down to four multiplications and two additions.</p>
<p><strong>Conclusion &amp; Download<br />
</strong></p>
<p>By finding the bottleneck and looking at way to optimize it, I was able to gain a significant speed increase for my 7,000 point test GPS track. I think the performance is close to that which could be obtained from the TransformUpdate mode, but without the scaling flaws found in that mode.</p>
<p><a href="http://www.britishideas.com/wp-content/uploads/2010/09/ElementUpdateOptimization.zip" target="_self">Download a patch</a> that can be applied to the <a href="http://deepearth.codeplex.com/SourceControl/list/changesets" target="_blank">Silverlight 4 branch</a> of DeepEarth (currently at revision 49789).</p>
<p><span class="youtube">
<object width="560" height="340">
<param name="movie" value="http://www.youtube.com/v/22MOWEAzmoY&amp;rel=1&amp;color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;showsearch=0&amp;hd=1" />
<param name="allowFullScreen" value="true" />
<embed wmode="transparent" src="http://www.youtube.com/v/22MOWEAzmoY&amp;rel=1&amp;color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;showsearch=0&amp;hd=1" type="application/x-shockwave-flash" allowfullscreen="true" width="560" height="340"></embed>
<param name="wmode" value="transparent" />
</object>
</span><p><a href="http://www.youtube.com/watch?v=22MOWEAzmoY&fmt=18">www.youtube.com/watch?v=22MOWEAzmoY</a></p></p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d281').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark to:</em></strong></a>
<br />
<div class="d281" style="overflow:hidden">
<br />
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d281').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d281').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://www.britishideas.com/2010/09/05/optimizing-deepearth-for-gis-mapping/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compiling OpenScales 1.1 with FlashDevelop 3</title>
		<link>http://www.britishideas.com/2010/02/07/compiling-openscales-1-1-with-flashdevelop-3/</link>
		<comments>http://www.britishideas.com/2010/02/07/compiling-openscales-1-1-with-flashdevelop-3/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 05:00:47 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Mapping]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[Mapnik]]></category>

		<guid isPermaLink="false">http://www.britishideas.com/?p=165</guid>
		<description><![CDATA[This article describes how to compile the OpenScales mapping library for Flash in FlashDevelop 3. OpenScales is an open source LGPL library for displaying interactive maps using Flex and Actionscript. It has many of the features of OpenLayers. FlashDevelop 3 is a free Flash development environment and can be used with the Flex SDK from]]></description>
			<content:encoded><![CDATA[<p>This article describes how to compile the <a href="http://www.openscales.org" target="_blank">OpenScales</a> mapping library for Flash in <a href="http://www.flashdevelop.org" target="_blank">FlashDevelop</a> 3. OpenScales is an open source LGPL library for displaying interactive maps using Flex and Actionscript. It has many of the features of <a href="http://www.openlayers.org" target="_blank">OpenLayers</a>. FlashDevelop 3 is a free Flash development environment and can be used with the Flex SDK from Adobe.</p>
<p>This article assumes you already have the Flex 3 SDK and FlashDevelop 3 installed and working. See my <a href="http://www.britishideas.com/2008/02/27/first-steps-with-flash-using-the-flex-3-sdk/" target="_blank">post from two years ago</a> for help.<span id="more-165"></span></p>
<p><strong>Compilation Options</strong></p>
<p>There are two ways OpenScales can be compiled. Firstly the source code can be included with your application code. This approach is good for debugging OpenScales and learning how it works. My understanding of the OpenScales <a href="http://openscales.org/userguide/license.html" target="_blank">LGPL license</a> is that this will make your application also licensed as LGPL (or a compatible license). However I&#8217;m not a lawyer so if that aspect is important to you then you will need to take a closer look.</p>
<p>The second way to compile OpenScales is as a library (SWC file). This library can then be linked with your application to produce the final Flash file.</p>
<p><strong>Compiling OpenScales Into a Library</strong></p>
<p>1. Download and install the <a href="http://sourceforge.net/projects/exportswc" target="_blank">ExportSWC plugin</a> for Flash Develop.</p>
<p>2. Create a new Flex 3 project with no package name.</p>
<p>3. Check out OpenScales using Subversion into the folder above the project folder. Note that if you use a different location the paths in the rest of this tutorial will need to be adjusted accordingly. I recommend <a href="http://tortoisesvn.tigris.org/" target="_blank">TortoiseSVN</a> if using Windows.</p>
<p>4. Go to Project -&gt; Properties -&gt; Compiler Options. Click on the Additional Compiler Options field and then the small &#8220;&#8230;&#8221; button.</p>
<p>5. Enter:</p>
<pre class="brush: plain;">
-namespace http://openscales.org ..\OpenScales-1.1\src\openscales-fx\src\main\flex\META-INF\manifest.xml
</pre>
<p>Note the hyphen at the start of the line.</p>
<p>6. Click on the Classpaths tab and add the following Classpaths:</p>
<p><code>..\OpenScales-1.1\src\openscales-core\src\main\flex<br />
..\OpenScales-1.1\src\openscales-fx\src\main\flex<br />
..\OpenScales-1.1\src\openscales-proj4as\src\main\flex<br />
C:\Program Files\FlexSDK\frameworks\libs<br />
C:\Program Files\FlexSDK\frameworks\locale\en_US</code></p>
<p>then close the dialog window. Note if you copied the Flex 3 SDK to a different location then choose the correct location when adding the libs and locale classpaths.</p>
<p>7. Download <a href="http://gskinner.com/libraries/gtween" target="_blank">GTween</a>, extract the zip file and copy GTween_xx_xx.swc into the lib folder for the project.</p>
<p>8. In the Project tree view right click on the GTween SWC file and choose &#8220;Add To Library&#8221;. The name will turn blue.</p>
<p>9. In the Project tree expand &#8220;libs&#8221; and &#8220;locale&#8221;, right-click on each SWC file in turn and choose &#8220;Add To Library&#8221;. The names will turn blue.</p>
<p>10. Click on the Build SWC toolbar button to generate the SWC file.</p>
<p>You may get two warnings for the OverviewMap.mxml file, which causes the build to fail. I think this is a bug in FlashDevelop because warnings shouldn&#8217;t cause the build to fail, only errors should. However the warnings can be disabled in the compiler options. I don&#8217;t know for sure if the Overview Map control is usable because of this.</p>
<p>The generated SWC file will be in the bin subfolder. In FlashDevelop create a new Flex 3 project and copy the OpenScales SWC file into the lib folder, then add it to the library by right-clicking on the name in the Project tree and choosing &#8220;Add To Library&#8221;. OpenScales can now be used.</p>
<p><strong>Compiling Application Code With OpenScales Code</strong></p>
<p>1. Create a new Flex 3 project with a suitable package name.</p>
<p>2. Check out OpenScales using Subversion into the folder above the project folder. Note that if you use a different location the paths in the rest of this tutorial will need to be adjusted accordingly. I recommend <a href="http://tortoisesvn.tigris.org/" target="_blank">TortoiseSVN</a> if using Windows.</p>
<p>3. Go to Project -&gt; Properties -&gt; Compiler Options. Click on the Additional Compiler Options field and then the small &#8220;&#8230;&#8221; button.</p>
<p>4. Enter:</p>
<pre class="brush: plain;">
-namespace http://openscales.org ..\OpenScales-1.1\src\openscales-fx\src\main\flex\META-INF\manifest.xml
</pre>
<p>Note the hyphen at the start of the line.</p>
<p>5. Click on the Classpaths tab and add the following Classpaths:</p>
<p><code>..\OpenScales-1.1\src\openscales-core\src\main\flex<br />
..\OpenScales-1.1\src\openscales-fx\src\main\flex<br />
..\OpenScales-1.1\src\openscales-proj4as\src\main\flex<br />
</code></p>
<p>then close the dialog window.</p>
<p>6. Download <a href="http://gskinner.com/libraries/gtween" target="_blank">GTween</a>, extract the zip file and copy GTween_xx_xx.swc into the lib folder for the project.</p>
<p>7. In the Project tree view right click on the GTween SWC file and choose &#8220;Add To Library&#8221;. The name will turn blue.</p>
<p>Now you can add OpenScales controls to Main.mxml and build a Flex/ActionScript 3 project.</p>
<p>It is possible to add the GTween source code to the project instead of the SWC if needed.</p>
<p>You may get two warnings for the OverviewMap.mxml file, which causes the build to fail. I think this is a bug in FlashDevelop because warnings shouldn&#8217;t cause the build to fail, only errors should. However the warnings can be disabled in the compiler options. I don&#8217;t know for sure if the Overview Map control is usable because of this.</p>
<p>For completeness my MXML and ActionScript test code follows. Note that I avoided using MXML to create any controls, instead preferring to use ActionScript. This is just a personal preference.</p>
<p>Example Main.mxml file:</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
xmlns:os=&quot;http://openscales.org&quot; layout=&quot;horizontal&quot; horizontalAlign=&quot;left&quot;
backgroundColor=&quot;#FFFFFF&quot; backgroundGradientColors=&quot;[#FFFFFF, #FFFFFF]&quot;
paddingTop=&quot;0&quot; paddingLeft=&quot;0&quot; paddingRight=&quot;0&quot; paddingBottom=&quot;0&quot;
creationComplete=&quot;OSMap.main();&quot;&gt;
&lt;/mx:Application&gt;
</pre>
<p>Example OSMap.as file:</p>
<pre class="brush: as3;">
package com.britishideas
{
  import mx.controls.*;
  import mx.core.*;
  import mx.events.FlexEvent;
  import flash.events.*;
  import flash.utils.*;
  import flash.display.Sprite;
  import org.openscales.fx.FxMap;
  import org.openscales.core.Map;
  import org.openscales.core.layer.osm.Mapnik;
  import org.openscales.core.handler.mouse.DragHandler;
  import org.openscales.core.handler.mouse.WheelHandler;
  import org.openscales.core.control.PanZoomBar;

  public class OSMap
  {
    private static var map:FxMap;
    private static var mxmlApp:Application;
    private static var osmap:Map;

    public function OSMap()
    {
    }

    public static function main():void
    {
      mxmlApp = Application(Application.application);
      map = new FxMap();
      map.width = 840;
      map.height = 840;
      map.zoom = 10;
      mxmlApp.addChild(map);
      map.addEventListener(FlexEvent.CREATION_COMPLETE, MapCreated);
    }

    private static function MapCreated(e:FlexEvent):void
    {
      osmap = map.map;
      var MapnikLayer:Mapnik = new Mapnik(&quot;Mapnik&quot;, true);
      osmap.addLayer(MapnikLayer);
      var dragHandler:DragHandler = new DragHandler(osmap, true);
      var wheelHandler:WheelHandler = new WheelHandler(osmap, true);
      osmap.zoom = 10;
      osmap.addControl(new PanZoomBar());
    }
  }
}
</pre>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d165').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark to:</em></strong></a>
<br />
<div class="d165" style="overflow:hidden">
<br />
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d165').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d165').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://www.britishideas.com/2010/02/07/compiling-openscales-1-1-with-flashdevelop-3/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Map Scales and Printing with Mapnik</title>
		<link>http://www.britishideas.com/2009/09/22/map-scales-and-printing-with-mapnik/</link>
		<comments>http://www.britishideas.com/2009/09/22/map-scales-and-printing-with-mapnik/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 23:36:20 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Mapping]]></category>
		<category><![CDATA[Mapnik]]></category>
		<category><![CDATA[printing]]></category>

		<guid isPermaLink="false">http://www.britishideas.com/2009/09/22/map-scales-and-printing-with-mapnik/</guid>
		<description><![CDATA[Mapnik is a nice open source library for generating maps. The typical data source is OpenStreetMap style data stored in a PostgreSQL/PostGIS database. This post examines how to understand and control the map scale and generate maps suitable for printing.
Map Scales 
A map scale looks something like 1:1000. This means that for every 1 inch]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.mapnik.org" target="_blank">Mapnik</a> is a nice open source library for generating maps. The typical data source is <a href="http://www.openstreetmap.org" target="_blank">OpenStreetMap</a> style data stored in a PostgreSQL/PostGIS database. This post examines how to understand and control the map scale and generate maps suitable for printing.</p>
<p><strong>Map Scales </strong></p>
<p>A map scale looks something like 1:1000. This means that for every 1 inch on the map there are 1000 inches in the real world. The units don&#8217;t matter, for example it also means that 1 meter on the map is 1000 meters in the real world. The value 1000 shown in this example is called the Scale Denominator.</p>
<p>Maps (in the context of this discussion) are generated using pixels. This is true even if printing because ultimately the printer has to print the pixels onto the paper (assuming a raster output). At low resolutions the pixels will be easily seen. Not so at high resolutions.</p>
<p>It is therefore useful for us to know the size of a pixel in meters. If we know this then we can work out the map scale and set the map scale.<span id="more-132"></span></p>
<p><strong>Universal Transverse Mercator</strong></p>
<p>The world is round and not flat (no comments on this please!) and therefore we need a way of converting a section of it onto a flat piece of paper. The method of converting a curved section of the world to a flat representation is called the <a href="http://en.wikipedia.org/wiki/Map_projection" target="_blank">projection</a>. There are many different projections to choose from and software available to convert data using the different projections. <a href="http://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system" target="_blank">Universal Transverse Mercator</a> (UTM) is a useful projection because it&#8217;s units are in meters. Typical map data uses latitude and longitude in degrees, which are difficult to use in calculations. However meters are much easier to work with.</p>
<p>The first step therefore is to get the bounding box of your map in degrees and <a href="http://www.google.com/search?q=convert+lat+lon+to+utm" target="_blank">convert</a> it to meters in UTM. Mapnik can also do this for you using the <a href="http://svn.mapnik.org/tags/release-0.6.0/docs/api_docs/python/mapnik.Projection-class.html" target="_blank">projection class</a>.</p>
<p>A bounding box is defined by the two coordinates that locate two opposite corners of the rectangle which defines the area in the map. The UTM zone is not needed, and we will assume the map area fits within a single UTM zone.</p>
<p><strong>Maps For Screens</strong></p>
<p>We assume that a pixel on a screen is 0.28mm on each side. This may or may not be true in reality, but it&#8217;s called the &#8220;standardized rendering pixel size&#8221; and is defined in the <a href="http://www.opengeospatial.org/standards/sld" target="_blank">OpenGIS Styled Layer Descriptor (SLD) Implementation Specification</a>. This assumption is made because software typically doesn&#8217;t know the pixel size on a screen and it&#8217;s a reasonable assumption. If the actual pixel size is known then it should be used. 0.28mm = 0.00028 m</p>
<p>We know the width of the area we wish to draw in meters from the UTM bounding box. We will call this map_realwidth_m. We also know the width of the map in pixels, because we choose that based on our requirements for the map. For example if the map is to go on a web page then the maximum width is probably something like 800px. We will call that image_width_px. Therefore:</p>
<p>scale_denominator = map_realwidth_m / (image_width_px x 0.00028)</p>
<p>The scale denominator is simply the ratio of the real world area width to the map width.</p>
<p>To summarize, for a bounding box in UTM coordinates and a given map width in pixels you can now calculate the scale of the map. However by rearranging the formula a UTM bounding box width can be calculated from a specific map scale and image width in pixels. By choosing a coordinate for the center of the map or one corner the UTM bounding box can be fixed.</p>
<p>Here is an example.  The width of the UTM bounding box is 1600 meters. The image width is 800px. Therefore:</p>
<p>scale_denominator = 1600 / (800 x 0.00028) = 7143.<br />
Map scale is 1:7143.</p>
<p>For a map scale of 1:2000 and an image width of 800px, the UTM bounding box width will be:</p>
<p>map_realwidth_m = 2000 x (800 x 0.00028) = 448 meters</p>
<p><strong>Maps For Printing</strong></p>
<p>Generating maps for printing is the same as for a screen except the resolution is different. For example a pixel size of 0.00028m corresponds to a resolution of approximately 90.7 Pixels Per Inch (PPI). This is a relatively low resolution and will likely appear quite poor when printed. Printing has a much better resolution than a screen. For example printing an 8&#8243; x 10&#8243; map might need 300 PPI to get enough detail. Large posters might be printed at 150 PPI. Note that sometimes PPI is referred to as Dots Per Inch (DPI) although DPI is specifically related to printing whereas PPI is more generic.</p>
<p>The first step in creating a map for printing is to determine the PPI to use. This is defined by the size of the print and the printer. For the examples that follow we will use 300 PPI, but any value can be used.</p>
<p>Next we need to work out the pixel size for the resolution.</p>
<p>300 PPI = 1 / 300 inches per pixel. 1/300 x 25.4mm/inch = 0.0846mm = 0.000085 meters</p>
<p>Now we need to work out the width of the map in pixels. For 300 PPI and a width of 7.5 inches we get:</p>
<p>image_width_px = 300 x 7.5 = 2250px</p>
<p>We can now put these values into the map scale formula to calculate the scale from the UTM bounding box, or calculate the UTM bounding box width from the scale. For a UTM bounding box that is 1600 meters wide:</p>
<p>scale_denominator = 1600 / (2250 x 0.000085) = 8366<br />
Map scale is 1:8366</p>
<p><strong>XML Stylesheet</strong></p>
<p>The Mapnik XML stylesheet tells Mapnik what to draw for different map scales. The rules are enabled by specifying a maximum and minimum scale denominator.</p>
<p>When creating maps for printing it is important to remember that internally Mapnik is assuming the map is for the screen and therefore has a different scale denominator. To get the scale denominator which Mapnik thinks is being used:</p>
<p># zoom to bounding box then&#8230;<br />
internal_scale_denom = mymap.scale_denominator()</p>
<p>Use this value when constructing the rules for the XML stylesheet.</p>
<p><strong>Notes</strong></p>
<p>If you tell Mapnik to render a specific UTM bounding box to an image of a specific dimensions then it will expand the bounding box in one direction so it has the same proportions as the image to be created. This can change the width of the UTM bounding box and therefore the scale calculation. The solution is to base any scale calculations off the actual bounding box. Mapnik can give you the values by calling the envelope() function on the map object.</p>
<p>The scale is an approximation and might only be valid for the center of the map. The larger the area represented in the map the more distortion there will be and therefore less accuracy when using the scale.</p>
<p>OpenStreetMap uses zoom levels numbered one to 18. <a href="http://svn.openstreetmap.org/applications/rendering/mapnik/zoom-to-scale.txt" target="_blank">This file</a> shows the relationship between the zoom levels and the scale denominators.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d132').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark to:</em></strong></a>
<br />
<div class="d132" style="overflow:hidden">
<br />
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d132').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d132').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://www.britishideas.com/2009/09/22/map-scales-and-printing-with-mapnik/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>OpenStreetMap and Beaches of the Rich and Famous</title>
		<link>http://www.britishideas.com/2009/09/01/openstreetmap-and-beaches-of-the-rich-and-famous/</link>
		<comments>http://www.britishideas.com/2009/09/01/openstreetmap-and-beaches-of-the-rich-and-famous/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 05:33:34 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Mapping]]></category>
		<category><![CDATA[celebrity]]></category>
		<category><![CDATA[hidden locations]]></category>

		<guid isPermaLink="false">http://www.britishideas.com/2009/09/01/openstreetmap-and-beaches-of-the-rich-and-famous/</guid>
		<description><![CDATA[In Malibu, Calif. there have long been disputes between the rich and famous and the public over access to certain beaches. One of these is Trancas Beach (a.k.a. Broad Beach).
In the 100 or so houses along this beach are the homes of some of the most famous people in Hollywood. Under the California Constitution (Article]]></description>
			<content:encoded><![CDATA[<p>In Malibu, Calif. there have long been disputes between the rich and famous and the public over access to certain beaches. One of these is <a href="http://www.malibucomplete.com/mc_around_broadbeach.php" target="_blank">Trancas Beach</a> (a.k.a. Broad Beach).</p>
<p>In the 100 or so houses along this beach are the homes of some of the most famous people in Hollywood. Under the California Constitution (Article X, Section 4) the <a href="http://www.venturacountystar.com/news/2007/jul/25/this-land-is-your-land/" target="_blank">public is allowed access</a> to certain areas of beach, but the rich and famous apparently want to keep it all for themselves. They even <a href="http://www.flickr.com/photos/cityprojectca/sets/72157600307195992/" target="_blank">bulldozed the sand</a> to protect their homes but ruined the public section, before being made to undo the damage.</p>
<p>This beach has two public access walkways, but they can be hard to find. They are located between houses and are narrow. According to some reports the local residents try to obsure the locations and put up <a href="http://pruned.blogspot.com/2008/07/field-guide-to-public-beaches-of-malibu.html" target="_blank">false signs</a> to deter people.</p>
<p>Last weekend (August 2009) I went to the beach armed with my GPS unit. I recorded the western public access and I have now added it to OpenStreetMap. Within a few minutes it was rendered (showing the location, steps and the gate).</p>
<p>Now everyone will be able to put this onto their maps and GPS units, easily find this public access point and enjoy free parking and a quiet beach!</p>
<p><a href="http://www.britishideas.com/wp-content/uploads/2009/09/trancasbeachaccess.gif" title="Trancas Beach Access - West"><img src="http://www.britishideas.com/wp-content/uploads/2009/09/trancasbeachaccess.thumbnail.gif" alt="Trancas Beach Access - West" /></a></p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d130').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark to:</em></strong></a>
<br />
<div class="d130" style="overflow:hidden">
<br />
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d130').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d130').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://www.britishideas.com/2009/09/01/openstreetmap-and-beaches-of-the-rich-and-famous/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Twitter + Google Maps + Text Messaging Mashup</title>
		<link>http://www.britishideas.com/2009/08/16/twitter-google-maps-test-messaging-mashup/</link>
		<comments>http://www.britishideas.com/2009/08/16/twitter-google-maps-test-messaging-mashup/#comments</comments>
		<pubDate>Sun, 16 Aug 2009 17:55:05 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Mapping]]></category>
		<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[Text Messaging]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://www.britishideas.com/2009/08/16/twitter-google-maps-test-messaging-mashup/</guid>
		<description><![CDATA[I am planning a road trip and thought about using Twitter to send updates from the road. As my phone doesn&#8217;t have internet access and emailing using the Samsung interface is difficult, I would be restricted to text messaging. However I really wanted a way to post tweets with a link to a map showing]]></description>
			<content:encoded><![CDATA[<p>I am planning a road trip and thought about using <a href="http://twitter.com" target="_blank">Twitter</a> to send updates from the road. As my phone doesn&#8217;t have internet access and emailing using the Samsung interface is difficult, I would be restricted to text messaging. However I really wanted a way to post tweets with a link to a map showing my approximate location. Ideally it would allow vague descriptions such as &#8220;Euclid and Stone, Tucson&#8221; as well as latitude and longitude, e.g. &#8220;N 32. 16.123 W 110 18.654&#8243;.</p>
<p>Surprisingly a search turned up very few options.  There is, however, a service that already does everything I want, and it&#8217;s called <a href="http://geo.ly" target="_blank">Geo.ly</a>. So why not use it I hear you ask? Well there are two large problems. Firstly the twitter interface doesn&#8217;t seem to be working right now and appears to have reliability problems. Secondly about 20% of the time the service will give you a URL to a map that doesn&#8217;t work &#8211; all you see is a blank page.</p>
<p>After a bit more fruitless searching I sat down and wrote my own PHP code that pulls everything together. Here is how it works.</p>
<p>There is a free text messaging service called <a href="http://www.textmarks.com" target="_blank">TextMarks</a> that converts text messaging to/from HTTP requests and responses. All that&#8217;s needed to send and receive text messages is to write a PHP (or CGI) script and put it on a web server somewhere. I tried it and it really is a piece of cake.</p>
<p>Next was to convert the text description of a location into latitude and longitude. For this Google provides a free <a href="http://code.google.com/apis/maps/documentation/geocoding/" target="_blank">geocoding</a> system, providing that the results are shown on a Google map. After a bit more work I had this working and it can accept a wide variety of input descriptions. For example the ones I listed above plus things like &#8220;Grand Canyon National Park&#8221;. Perfect.</p>
<p>The final piece of the puzzle was to automatically post the tweet with the location of the Google map using the <a href="http://apiwiki.twitter.com/" target="_blank">Twitter API</a>. I found that Twitter automatically shortens URLs in tweets using the <a href="http://bit.ly" target="_blank">bit.ly</a> service.</p>
<p>So now I can send a text message with a rough description of my location, the location is converted to coordinates, a tweet is generated with a link to the map and a confirmation text message is sent back to my phone. This typically takes about 15 seconds. Nice!</p>
<p>Below is the PHP script. Use at your own risk. To install:</p>
<ol>
<li>Copy to somewhere on your webserver</li>
<li>Go to TextMarks and create a new TextMark for your service</li>
<li>Create a TextMarks account and edit the configuration. Disable messaging and any public options for your TextMark &#8211; after all you don&#8217;t want other people posting locations to your twitter account.</li>
<li>Edit the script and enter your Twitter username and password. Also enter your <a href="http://code.google.com/apis/maps/signup.html" target="_blank">Google Maps API key</a> (which is free).</li>
</ol>
<p>Note that there is no authentication used in the script. This is because the script is not linked to, uses an obscure name (not twitter.php, which is just an example name), and the TextMark is private. However, if desired, the TextMarks service can pass the phone number to the script allowing for only specific phones to use the system.</p>
<p>A public version would, of course, need more input checking, user authentication, etc.<br />
<code><br />
&lt;?php<br />
// script to take a location description from a text message,<br />
// generate a URL to a map and then tweet the URL<br />
// the result is returned as a text message<br />
</code></p>
<p><code><br />
// (C) Copyright Andrew Ayre, 2009<br />
// andy at britishideas dot com<br />
</code></p>
<p><code><br />
// call from TextMarks using something like:<br />
// http://www.mydomain.com/twitter.php?args=\0<br />
</code></p>
<p><code><br />
// This program is free software; you can redistribute it and/or<br />
// modify it under the terms of the GNU General Public License<br />
// as published by the Free Software Foundation; either version 2<br />
// of the License, or (at your option) any later version.<br />
</code></p>
<p><code><br />
// This program is distributed in the hope that it will be useful,<br />
// but WITHOUT ANY WARRANTY; without even the implied warranty of<br />
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the<br />
// GNU General Public License for more details.<br />
// You should have received a copy of the GNU General Public License<br />
// along with this program; if not, write to the Free Software<br />
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.<br />
// See: http://www.gnu.org/licenses/gpl-2.0.html<br />
</code></p>
<p><code><br />
// twitter username and password<br />
$twitter_username = 'myusername';<br />
$twitter_password = 'mypassword';<br />
// API key for Google Maps<br />
$google_mapsapikey = 'myapikey';<br />
</code></p>
<p><code><br />
// max time to wait for tweet responses from twitter in seconds<br />
$twitter_timeout = 30;<br />
// max time to wait for Google geocoding service in seconds<br />
$google_timeout = 30;<br />
</code></p>
<p><code><br />
// get text message contents<br />
$args = $_GET['args'];<br />
// encode<br />
$args = urlencode($args);<br />
</code></p>
<p><code><br />
// geocode input<br />
$req = curl_init("http://maps.google.com/maps/geo?q=$args&amp;output=json&amp;oe=utf8&amp;sensor=false&amp;key=$google_mapsapikey");<br />
curl_setopt($req, CURLOPT_RETURNTRANSFER, true);<br />
curl_setopt($req, CURLOPT_CONNECTTIMEOUT, $google_timeout);<br />
$output = curl_exec($req);<br />
curl_close($req);<br />
</code></p>
<p><code><br />
// parse geocoding result<br />
$result = json_decode($output, true);<br />
if ($result == NULL) {<br />
echo "Geocoding failed";<br />
return;<br />
}<br />
</code></p>
<p><code><br />
// get address and coordinates<br />
$address = $result['Placemark'][0]['address'];<br />
$lon = $result['Placemark'][0]['Point']['coordinates'][0];<br />
$lat = $result['Placemark'][0]['Point']['coordinates'][1];<br />
</code></p>
<p><code><br />
// construct Google URL<br />
$mapurl = urlencode("http://maps.google.com/maps?q=$lat+$lon&amp;mrt=yp");<br />
</code></p>
<p><code><br />
// send to twitter - based on<br />
// http://morethanseven.net/2007/01/20/posting-to-twitter-using-php/<br />
$tweet = "I am somewhere near $mapurl";<br />
$req = curl_init('https://twitter.com/statuses/update.xml');<br />
curl_setopt($req, CURLOPT_CONNECTTIMEOUT, $twitter_timeout);<br />
curl_setopt($req, CURLOPT_RETURNTRANSFER, true);<br />
curl_setopt($req, CURLOPT_POST, true);<br />
curl_setopt($req, CURLOPT_POSTFIELDS, "status=$tweet");<br />
curl_setopt($req, CURLOPT_USERPWD, "$twitter_username:$twitter_password");<br />
$output = curl_exec($req);<br />
curl_close($req);<br />
</code></p>
<p><code><br />
// return result via text message<br />
if (empty($output))<br />
{<br />
echo "Failed: $address, $lat, $lon";<br />
} else {<br />
echo "Tweeted: $address, $lat, $lon";<br />
}<br />
?&gt;<br />
</code></p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d129').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark to:</em></strong></a>
<br />
<div class="d129" style="overflow:hidden">
<br />
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d129').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d129').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://www.britishideas.com/2009/08/16/twitter-google-maps-test-messaging-mashup/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Open Street Map Quick Start (JOSM)</title>
		<link>http://www.britishideas.com/2009/08/06/open-street-map-quick-start-josm/</link>
		<comments>http://www.britishideas.com/2009/08/06/open-street-map-quick-start-josm/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 00:12:44 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Mapping]]></category>
		<category><![CDATA[JOSM]]></category>
		<category><![CDATA[Mapnik]]></category>

		<guid isPermaLink="false">http://www.britishideas.com/2009/08/06/open-street-map-quick-start-josm/</guid>
		<description><![CDATA[This is a description of how to quickly get going with OpenStreetMap. It is primarily aimed at people who don&#8217;t have a GPS unit or don&#8217;t want to use one. It&#8217;s also aimed at people who want to quickly add something to their local area. It is not a replacement for the OSM wiki.
Get JOSM
First]]></description>
			<content:encoded><![CDATA[<p>This is a description of how to quickly get going with <a href="http://www.openstreetmap.org" target="_blank">OpenStreetMap</a>. It is primarily aimed at people who don&#8217;t have a GPS unit or don&#8217;t want to use one. It&#8217;s also aimed at people who want to quickly add something to their local area. It is not a replacement for the <a href="http://wiki.openstreetmap.org" target="_blank">OSM wiki</a>.</p>
<p><strong>Get JOSM</strong></p>
<p>First <a href="http://josm.openstreetmap.de/josm-latest.jar">download the current version of JOSM</a>, which is a Java based editor. You will also need to install <a href="http://java.sun.com/javase/downloads/" target="_blank">Java 1.5</a>. You can also read more about JOSM <a href="http://josm.openstreetmap.de/" target="_blank">here</a> and <a href="http://wiki.openstreetmap.org/wiki/JOSM" target="_blank">here</a>.</p>
<p>Start JOSM. On the command line this is something like:</p>
<p><code>java -jar -Xmx512M josm-latest.jar</code></p>
<p>There are some JOSM plugins that I think are essential, and here is how to add them:</p>
<ul>
<li>Start JOSM</li>
<li> Go to Edit -&gt; Preferences</li>
<li>Click on the plugins tab (looks like a wall socket/outlet)</li>
<li>Click on &#8220;Download List&#8221;</li>
<li>Check/tick the following: utilsplugin, validator, waydownloader</li>
<li>Click on &#8220;OK&#8221;</li>
<li>Restart JOSM</li>
</ul>
<p>Next you need to tell JOSM your OpenStreetMap username and password.</p>
<ul>
<li>Go to Edit -&gt;Preferences</li>
<li>Click on the connection settings tab (looks like a planet)</li>
<li>Enter your email address and password</li>
<li>Click on &#8220;OK&#8221;</li>
</ul>
<p>Next <a href="http://wiki.openstreetmap.org/wiki/JOSM/Plugins/WMSPlugin" target="_blank">install the WMS Plugin</a> for JOSM that will allow you to view Yahoo satellite images.</p>
<p><strong>Download a Section of the Map</strong></p>
<p>Next you will want to download the part of the map that covers your local area.</p>
<ul>
<li>Click on the Download From OSM toolbar button</li>
<li>Check/tick &#8220;Download as a new layer&#8221;</li>
<li>Drag the map with the right mouse button, zoom with the mouse wheel or Ctrl + arrow keys</li>
<li>Drag a box with the left mouse button to select an area to download. Keep it small for now.</li>
<li>Click on &#8220;OK&#8221; and wait a bit. It could take a few minutes so don&#8217;t give up too quickly</li>
</ul>
<p>You will now be looking at a black screen with lots of lines on it. Zoom in to a few streets using the magnifying glass tool on the toolbar.</p>
<p><strong>Get the Satellite Images</strong></p>
<p>The next step is to get the satellite images so we can see how the streets compare with the real world.</p>
<ul>
<li>Go to  WMS -&gt; Yahoo Sat (may have a slightly different name depending on the JOSM version)</li>
</ul>
<p>At the top right under the Layers heading a new layer should appear called &#8220;Yahoo Sat&#8221; or something like that. Wait a bit and the images should start to appear.</p>
<p><strong>Edit the Map</strong></p>
<p>It&#8217;s now time to start editing. It should be clear if a street is not aligned with the Yahoo images. If it isn&#8217;t then you can click on the Select tool on the toolbar and start dragging the nodes (small yellow boxes). Position a road over where it is in the satellite image.</p>
<p><strong>Upload!</strong></p>
<p>Once you have fixed a few roads click on the Upload to OSM toolbar button.</p>
<ul>
<li>Enter a description for the change</li>
<li>Click on &#8220;Upload Changes&#8221;</li>
</ul>
<p>Once complete you can go to your OSM account page and view your edits. The URL is http://www.openstreetmap.org/user/myusername/edits. Replace &#8220;myusername&#8221; with your user name. You should see your first edit!</p>
<p>After waiting a few minutes your changes should start to appear on the <a href="http://www.openstreetmap.org" target="_blank">map</a>. <a href="http://wiki.openstreetmap.org/wiki/Slippy_Map#Mapnik_tile_rendering" target="_blank">Mapnik</a> (the default renderer) renders the lower zoom levels more frequently, so you should see your changes appear in stages and only in some zoom levels. After a day or so all the lower zoom levels should show your changes.</p>
<p><strong>Some Notes</strong></p>
<p>The Yahoo satellite images are not always in the right place, but it seems from my experience they are pretty good. However this is something to keep in mind.</p>
<p>Along with fixing streets, it&#8217;s also possible to add in schools, malls, hospitals, businesses, rivers, streams, parks, etc. all by using the satellite images. There is plenty to do!</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d128').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark to:</em></strong></a>
<br />
<div class="d128" style="overflow:hidden">
<br />
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d128').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d128').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://www.britishideas.com/2009/08/06/open-street-map-quick-start-josm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

