User talk:Stevage/Mapnik-support
Jump to navigation
Jump to search
This template tells you whether Mapnik supports a given tag. Usage is simple:
{{User:Stevage/Mapnik-support|access|permissive}}
{{User:Stevage/Mapnik-support|access|random}}
This gives:
- yes
- no
Here's the XSLT to generate it from osm.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Plan:
1) Loop over all filters that contain something
2) Add each element of each filter to a global sequence
3) Clean out the global sequence (remove dupes, sort?)
4) Iterate over global sequence
5) For each item, list places it occurs (not yet implemented)
-->
<xsl:template match="Map">
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<html>
<body>
<xsl:variable name="tags" as="item()+">
<xsl:for-each select="Style/Rule/Filter/..">
<!-- convert "[natural] = 'peak'" to "natural=peak" -->
<xsl:analyze-string select="Filter" regex="\[([-a-zA-Z0-9_]+)\]\s*(<>|=)\s*'([^']*)'" >
<xsl:matching-substring >
<xsl:sequence select="concat(regex-group(1),'=', regex-group(3))"/>
</xsl:matching-substring >
</xsl:analyze-string>
<xsl:analyze-string select="Filter" regex="\[([-a-zA-Z0-9_]+)\]\s*=\s*([0-9+]+)" >
<xsl:matching-substring >
<xsl:sequence select="concat(regex-group(1),'=', regex-group(2))"/>
</xsl:matching-substring >
</xsl:analyze-string> >
<xsl:analyze-string select="Filter" regex="\[([-a-zA-Z0-9_]+)\]\s*<?>?=?<?>?\s*([0-9+]+)" >
<xsl:matching-substring >
<xsl:sequence select="concat(regex-group(1),'~=', regex-group(2))"/>
</xsl:matching-substring >
</xsl:analyze-string> >
</xsl:for-each>
</xsl:variable>
Total filter arguments: <xsl:value-of select="count($tags)" /><br />
Distinct filter arguments: <xsl:value-of select="count(distinct-values($tags))" /><br />
<h1> HTML version </h1>
<ol>
<xsl:for-each select="distinct-values($tags)">
<xsl:sort select="."/>
<li><xsl:value-of select="." /> </li>
</xsl:for-each>
</ol>
<h1> Wiki list </h1>
<xsl:for-each select="distinct-values($tags)">
<xsl:sort select="."/>
# {{tag|<xsl:value-of select="tokenize(., '~?=')[1]" />|<xsl:value-of select="tokenize(., '~?=')[2]" />}}
<br />
</xsl:for-each>
<h1> Wiki template </h1>
{{#switch: {{{1}}}~{{{2}}}
<xsl:for-each select="distinct-values($tags)">
<xsl:sort select="."/>
| <xsl:value-of select="tokenize(., '~?=')[1]" />~<xsl:value-of select="tokenize(., '~?=')[2]" /> = yes
<br />
</xsl:for-each>
| no
}}
</body>
</html>
</xsl:template>
</xsl:stylesheet>