[OSM-newbies] XSLT question

Andrew Errington a.errington at lancaster.ac.uk
Tue Sep 15 08:00:51 BST 2009


On Tue, September 15, 2009 14:55, Renaud MICHEL wrote:
> Le mardi 15 septembre 2009 à 06:40, Andrew Errington a écrit :
>
>> Thanks for your help.  I have made this,
<snip>
> You can make it a lot simpler with an xpath like I gave before:
>
> <xsl:template match="node[tag[@k='amenity' and @v=$amenity]]">
> <xsl:value-of select='@id'/><br/>
> <xsl:value-of select='@lat'/><br/>
> <xsl:value-of select='@lon'/><br/>
> <xsl:value-of select='tag[@k="name"]/@v'/><br/>
> </xsl:template>

Ok.  I see what you did there.  :)

I only just started using XSLT so I'm not actually any good at it, but I
recognise the power of the tools, so I know it's worth persevering.

>> For an area I will match "way" but then I have to get all nodes that
>> make the way and calculate a simple centroid.
>
> Using an xsl:key is the way to go here:
>
<snip>

Thanks for the code.  I will try it out.

The end result will be a simple textfile containing a certain type of
amenity.  I will load it up as a layer using this example:

http://wiki.openstreetmap.org/wiki/Openlayers_POI_layer_example#textfile.txt

It means I can make a local map with half a dozen layers for different
amenities (restaurants, shops, schools, public buildings, etc.) to make a
'Town Guide'.  It will be sort of interactive insofar as you can turn the
layers on and off.

Again, there are probably better solutions out there, but this is a
concrete way to learn XSLT.  I also like the idea of not having to write
too much code.  The workflow is:

1. download region from OSM
2. Run XSLT to make POI layers
3. Err,
4. That's it!

Best wishes,

Andrew





More information about the newbies mailing list