Technomancy

Entries tagged “osm”

How to make a map based on OpenStreetMap

written by rory, on Sep 12, 2009 9:06:00 PM.

I recently made an OpenStreetMap (OSM) based AJAX map of all the Hackerspaces in OSM. It pulls out the list of hackerspaces from XAPI, converts it from OSM to GeoRSS using XSLT, then displayes it on a map using OpenLayers.

The XAPI URL I'm using is:

wget -q -O /var/www/osm-hackerspaces/hackerspaces.osm 
"http://osmxapi.hypercube.telascience.org/api/0.6/*[leisure=hackerspace]"

I'm also setting a nice User-Agent giving my contact details and I've installed a local squid proxy and using that. I'm being a good web citizen

I convert the OSM file to GeoRSS using the following XSLT file:

<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>

<xsl:template match="/osm">
<?xml-stylesheet href="http://yelp.com/css/atom.css" type="text/css" media="screen"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"> 
	<rights></rights> 
	<title>Hackerspaces in OpenStreetMap</title>
	<link href="http://www.technomancy.org/osm-hackerspaces/" />
	<updated>
        <xsl:for-each select="./node">
            <xsl:sort select="@timestamp" data-type="text" order="descending" />
            <xsl:if test="position() = 1">
                <xsl:value-of select="@timestamp" />
            </xsl:if>
        </xsl:for-each>
    </updated>
	<author>
		<name>OpenStreetMap contributors</name>
	</author>

    
    <xsl:for-each select="./node">
        <entry>
            <title><xsl:value-of select="./tag[@k='name']/@v" /></title>
            <xsl:choose>
                <xsl:when test="not(./tag[@k='website']/@v)">
                    <link rel="alternate" type="text/html" href="" />
                    <id></id>
                </xsl:when>
                <xsl:when test="substring(./tag[@k='website']/@v, 0, 5) = 'http'">
                    <xsl:variable name="website" select="./tag[@k='website']/@v" />
                    <link rel="alternate" type="text/html" href="{$website}" />
                    <id><xsl:value-of select="$website" /></id>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:variable name="website">http://<xsl:value-of select="./tag[@k='website']/@v" /></xsl:variable>
                    <link rel="alternate" type="text/html" href="{$website}" />
                    <id><xsl:value-of select="$website" /></id>
                </xsl:otherwise>
            </xsl:choose>
            <updated><xsl:value-of select="./@timestamp" /></updated>

            <summary type="html"><xsl:value-of select="./tag[@k='addr:full']/@v" /><xsl:text> </xsl:text><xsl:value-of select="./tag[@k='note']/@v" /></summary>
            <geo:long><xsl:value-of select="./@lon" /></geo:long>	
            <geo:lat><xsl:value-of select="./@lat" /></geo:lat>
        </entry>
    </xsl:for-each>

</feed>
</xsl:template>

</xsl:stylesheet>

I use xmlstarlet to convert using this command line:

xmlstarlet tr osm2georss.xslt hackerspaces.osm > hackerspaces.georss.xml

I made a little 20x20 logo from the hackerspace logo.

OpenLayers has built in support for GeoRSS, so it was just a matter of giving it the filename of the above.

I have a cron running that every 6 hours to update it.

Helmet camera - Inital thoughts

written by rory, on Jul 24, 2009 12:32:45 PM.

I'd like to make a helmet camera. This would be a camera that's attached to the top of my motorcycle camera, and records what I see. Recently I went on a motorbike trip and I saw some lovely scenery, however I couldn't take any photos because I was riding my motorbike. A helmet camera would be great for this. It could also be used for mapping in OpenStreetMap. I could drive around with this recording video and then use screenshots to map features in OpenStreetMap. Someone suggested a Sanyo Xacti camera as a simple little camera I could get on eBay that I could take apart.

osm2navit doesn't work with the latest OSM planet dump

written by rory, on Jul 13, 2009 9:34:00 PM.

In my quest for creating an offline atlas of the world that can given away for free, I've been trying to use navit, an open source satnav system. They have a very compact file format for OpenStreetMap files. I downloaded the latest OpenStreetMap planet dump, planet-090701.osm.bz2, (MD5 checksum: 9133f22e4d09b73f86e1f4d68539879d) and ran osm2navit on it. As soon as I started to run it, I got thousands and thousands of errors like this:
WARNING: unknown tag in   <changeset id="1696734" created_at="2009-07-01T00:10:10Z" closed_at="2009-07-01T00:10:14Z" open="false" min_lon="9.5064856" min_lat="52.7634646" max_lon="9.6230595" max_lat="52.8229376"  user="mfi" uid="58950">
WARNING: unknown tag in   </changeset>
However I let it run, and after about 2 hours, osm2navit crashed and I got the following error:
PROGRESS1: Processed 378663035 nodes (14343033 out) 29925604 ways 140057 relations 0 tiles
5 slices
flush_nodes 1
slice 1 of 5
reading -4294967297 bytes from coords.tmp at 4294967296
osm2navit: osm2navit.c:1642: load_buffer: Assertion `b->base != ((void *)0)' failed.
Aborted
And that's where I am now. I think it might be because OpenStreetMap have moved to a new file and API format, 0.6, and perhaps osm2navit hasn't been updated.

Navit as an OfflineOSM viewer

written by rory, on Jul 8, 2009 10:36:00 PM.

I'm trying to find a way to show OpenStreetMap data offline, so it can be used in places with little or no internet. Navit is a open source car navigation system. It runs fine as a desktop application. And they have created a binary file format for storing OpenStreetMap data. It has an advantage of creating small file sizes. This might mean it'd be possible to store the whole OpenStreetMap planet file on one CD. The XML file compressed is 6.7GB, which is too large to fit on any practical disk. I'm downloading the OpenStreetMap planet file and will convert it to Navit format to see how much space it takes.

The Navit interface is OK but isn't great. It's good if you want to look at street level, but I envision an Offline OpenStreetMap being used in an education context, which means looking at it at a country or county level. Someone on #navit suggested using Navit's binary file format and plugging it into a nicer rendering engine.

Offline OpenStreetMap

written by rory, on Jul 3, 2009 12:35:15 PM.

Ubuntu NGO is a new Ubuntu group that's forming organise Ubuntu people around helping NGOs. I've done some volunteer work with Camara. One problem in the developing world is the lack of internet. People have made offline Wikipedia dumps, which is awesome. I'm big OpenStreetMap fan. It'd great to have a map of the world on your desktop. So I thought I'd try to make an offline OpenStreetMap. This blog (and the offlineosm tag) will be used to plan this out.