changeset 516:4f2a18abc780

Added little XSL tranformation to turn palette XML files into QGIS style definitions. Useful to display "Horizontalschnitte" in correct colors. gnv-artifacts/trunk@610 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sat, 23 Jan 2010 14:03:26 +0000
parents 234d9892e497
children 96a1e92e7ed2
files gnv-artifacts/ChangeLog gnv-artifacts/contrib/palette2qgis.xsl
diffstat 2 files changed, 160 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog	Fri Jan 22 18:51:47 2010 +0000
+++ b/gnv-artifacts/ChangeLog	Sat Jan 23 14:03:26 2010 +0000
@@ -1,3 +1,19 @@
+2010-01-22	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* contrib/palette2qgis.xsl: New. XST tranformation to turn a
+	  palette XML file into a style definition suitable to be used
+	  in QGIS. Tested with QGIS 1.4.0-Enceladus. Usage:
+
+	  $ xsltproc contrib/palette2qgis.xsl       \
+	    doc/conf/palette/water-temperature.xml  \
+		> water-temperature.qml
+
+	  Do similar to process salinity.xml et al.
+
+	  When you've loaded the "Horizontalschnitt" polygon layer 
+	  in QGIS, class it via the "CLASS" attribute, load the
+	  according style and apply it. Voila!
+	  
 2010-01-22	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/gnv/math/Interpolation3D.java:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gnv-artifacts/contrib/palette2qgis.xsl	Sat Jan 23 14:03:26 2010 +0000
@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet
+    version="1.0"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:html="http://www.w3.org/1999/xhtml"
+    xmlns="http://www.w3.org/1999/xhtml" >
+    <!--
+    palette2qgis.xsl
+    ================
+    Transforms palette XML files into QGIS style files. Useful
+    to display "Horizontalschnitte" with the right colors.
+
+    Tested with Quantum GIS 1.4.0-Enceladus.
+
+    usage: xsltproc palette2qgis.xsl palette.xml > style.qml
+
+    Author: Sascha L. Teichmann (sascha.teichmann@intevation.de)
+    -->
+
+    <xsl:output
+        method="xml"
+        doctype-system="PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'"/>
+
+    <xsl:template name="hex">
+        <xsl:param name="value"/>
+        <xsl:variable name="x" select="translate(substring($value, string-length($value), 1), 'ABCDEF', 'abcdef')"/>
+        <xsl:variable name="result">
+            <xsl:choose>
+                <xsl:when test="$x = 'a'">10</xsl:when>
+                <xsl:when test="$x = 'b'">11</xsl:when>
+                <xsl:when test="$x = 'c'">12</xsl:when>
+                <xsl:when test="$x = 'd'">13</xsl:when>
+                <xsl:when test="$x = 'e'">14</xsl:when>
+                <xsl:when test="$x = 'f'">15</xsl:when>
+                <xsl:otherwise><xsl:value-of select="$x"/></xsl:otherwise>
+            </xsl:choose>
+        </xsl:variable>
+        <xsl:variable name="rest">
+            <xsl:choose>
+                <xsl:when test="string-length($value) > 1">
+                    <xsl:call-template name="hex">
+                        <xsl:with-param name="value" select="substring($value, 1, string-length($value)-1)"/>
+                    </xsl:call-template>
+                </xsl:when>
+                <xsl:otherwise><xsl:value-of select="0"/></xsl:otherwise>
+            </xsl:choose>
+        </xsl:variable>
+        <xsl:value-of select="number($result) + 16*$rest"/>
+    </xsl:template>
+
+    <xsl:template match="/ranges/range">
+        <symbol>
+          <lowervalue><xsl:value-of select="@index"/></lowervalue>
+          <uppervalue><xsl:value-of select="@index"/></uppervalue>
+          <label><xsl:value-of select="@description"/></label>
+          <pointsymbol>hard:circle</pointsymbol>
+          <pointsize>2</pointsize>
+          <pointsizeunits>pixels</pointsizeunits>
+          <rotationclassificationfieldname></rotationclassificationfieldname>
+          <scaleclassificationfieldname></scaleclassificationfieldname>
+          <symbolfieldname></symbolfieldname>
+          <outlinecolor red="0" blue="0" green="0" />
+          <outlinestyle>NoPen</outlinestyle>
+          <outlinewidth>0.26</outlinewidth>
+          <xsl:variable name="rgb">
+            <xsl:call-template name="hex">
+                <xsl:with-param name="value" select="substring(@rgb, 2)"/>
+            </xsl:call-template>
+          </xsl:variable>
+          <xsl:variable name="red"   select="floor(($rgb div (256*256)) mod 256)"/>
+          <xsl:variable name="green" select="floor(($rgb div 256) mod 256)"/>
+          <xsl:variable name="blue"  select="floor($rgb mod 256)"/>
+          <fillcolor red="{$red}" blue="{$blue}" green="{$green}"/>
+          <fillpattern>SolidPattern</fillpattern>
+          <texturepath null="1" ></texturepath>
+        </symbol>
+    </xsl:template>
+
+    <xsl:template match="/">
+        <qgis version="1.4.0-Enceladus" 
+              minimumScale="1" 
+              maximumScale="1e+08" 
+              minLabelScale="1" 
+              maxLabelScale="1e+08"
+              hasScaleBasedVisibilityFlag="0" 
+              scaleBasedLabelVisibilityFlag="0" >
+        <transparencyLevelInt>255</transparencyLevelInt>
+        <classificationattribute>CLASS</classificationattribute>
+            <symbol>
+                <lowervalue null="1" ></lowervalue>
+                <uppervalue null="1" ></uppervalue>
+                <label>Andere</label>
+                <pointsymbol>hard:circle</pointsymbol>
+                <pointsize>2</pointsize>
+                <pointsizeunits>pixels</pointsizeunits>
+                <rotationclassificationfieldname></rotationclassificationfieldname>
+                <scaleclassificationfieldname></scaleclassificationfieldname>
+                <symbolfieldname></symbolfieldname>
+                <outlinecolor red="0" blue="0" green="0" />
+                <outlinestyle>DashDotDotLine</outlinestyle>
+                <outlinewidth>0.26</outlinewidth>
+                <fillcolor red="59" blue="81" green="179" />
+                <fillpattern>SolidPattern</fillpattern>
+                <texturepath null="1" ></texturepath>
+            </symbol>
+            <uniquevalue>
+                <classificationfield>CLASS</classificationfield>
+                <xsl:apply-templates/>
+            </uniquevalue>
+            <edittypes>
+                <edittype type="0" name="CLASS" />
+                <edittype type="0" name="DATE" />
+                <edittype type="0" name="LAYER" />
+                <edittype type="0" name="PARAMETER" />
+            </edittypes>
+            <editform></editform>
+            <editforminit></editforminit>
+            <displayfield>PARAMETER</displayfield>
+            <label>0</label>
+            <attributeactions/>
+            <labelattributes>
+                <label fieldname="" text="Beschriftung" />
+                <family fieldname="" name="Sans Serif" />
+                <size fieldname="" units="pt" value="12" />
+                <bold fieldname="" on="0" />
+                <italic fieldname="" on="0" />
+                <underline fieldname="" on="0" />
+                <color fieldname="" red="0" blue="0" green="0" />
+                <x fieldname="" />
+                <y fieldname="" />
+                <offset x="0" y="0" units="pt" yfieldname="" xfieldname="" />
+                <angle fieldname="" value="0" auto="0" />
+                <alignment fieldname="" value="center" />
+                <buffercolor fieldname="" red="255" blue="255" green="255" />
+                <buffersize fieldname="" units="pt" value="1" />
+                <bufferenabled fieldname="" on="" />
+                <multilineenabled fieldname="" on="" />
+            </labelattributes>
+        </qgis>
+    </xsl:template>
+
+    <xsl:template match="text()"/>
+</xsl:stylesheet>
+

http://dive4elements.wald.intevation.org