Technomancy

Entries tagged “openstreetmap”

There already is a Navit format of the OSM planet!

written by rory, on Nov 30, 2009 1:09:40 PM.

I wrote previously about my difficulties in creating a navit file for the whole OpenStreetMap planet file.

However I discovered today that the Navit project provides an dump of the OSM planet file on their website!

Navit formatted OSM planet file

osm2sqlite - A programme to convert from OSM files to SQLite

written by rory, on Nov 29, 2009 7:50:00 PM.

I've created osm2sqlite, a programme to convert from OSM files (OpenStreetMap's XML file format) into a SQLite database. It's not very good for display OpenStreetMap data in a GIS programme. It's good if you want to muck around with raw OpenStreetMap data, in a familiar SQL environment.

I'm using git to store the code, you can get it here: http://repo.or.cz/w/osm2sqlite.git

Sample usage:

  • Checkout the code
    git clone git://repo.or.cz/osm2sqlite.git .
  • For this example, we'll download the OSM data from Ireland.
    wget http://download.geofabrik.de/osm/europe/ireland.osm.bz2
  • Unzip the file. Currently it has to be unzipped. Support for converting bzipped files is planned.
    bunzip2 ireland.osm.bz2
  • And finally run the script to convert the OpenStreetMap file to a database called ireland.sqlite.
    ./convert_osm_to_sqlite.sh -o ireland-2009-11-17.osm -d ireland.sqlite

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.