Mercurial > dive4elements > gnv-client
changeset 520:a8f6ca59b26e
Cosmetic cleanups on palette -> QQIS style transformation.
gnv-artifacts/trunk@614 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 24 Jan 2010 12:10:50 +0000 |
parents | 4e347624ee7c |
children | 1bf058f1a2d1 |
files | gnv-artifacts/ChangeLog gnv-artifacts/contrib/palette2qgis.xsl |
diffstat | 2 files changed, 121 insertions(+), 123 deletions(-) [+] |
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog Sat Jan 23 21:16:45 2010 +0000 +++ b/gnv-artifacts/ChangeLog Sun Jan 24 12:10:50 2010 +0000 @@ -1,3 +1,7 @@ +2010-01-24 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * contrib/palette2qgis.xsl: Cosmetic cleanups. + 2010-01-23 Sascha L. Teichmann <sascha.teichmann@intevation.de> * src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileMeshCrossOutputState.java:
--- a/gnv-artifacts/contrib/palette2qgis.xsl Sat Jan 23 21:16:45 2010 +0000 +++ b/gnv-artifacts/contrib/palette2qgis.xsl Sun Jan 24 12:10:50 2010 +0000 @@ -1,10 +1,6 @@ <?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" > - <!-- +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> + <!-- palette2qgis.xsl ================ Transforms palette XML files into QGIS style files. Useful @@ -16,129 +12,127 @@ Author: Sascha L. Teichmann (sascha.teichmann@intevation.de) --> - - <xsl:output - method="xml" - doctype-system="PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'"/> + <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:template name="hex2number"> + <xsl:param name="hex"/> + <xsl:choose> + <xsl:when test="string-length($hex) < 1"> + <xsl:value-of select="0"/> + </xsl:when> + <xsl:otherwise> + <xsl:variable + name="x" + select="translate(substring($hex, string-length($hex), 1), 'ABCDEF', 'abcdef')"/> + <xsl:variable name="last"> + <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:otherwise> + <xsl:value-of select="$x"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:variable name="rest"> + <xsl:call-template name="hex2number"> + <xsl:with-param + name="hex" + select="substring($hex, 1, string-length($hex)-1)"/> + </xsl:call-template> + </xsl:variable> + <xsl:value-of select="number($last) + 16*$rest"/> + </xsl:otherwise> + </xsl:choose> + </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: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/> + <scaleclassificationfieldname/> + <symbolfieldname/> + <outlinecolor red="0" blue="0" green="0"/> + <outlinestyle>NoPen</outlinestyle> + <outlinewidth>0.26</outlinewidth> + <xsl:variable name="rgb"> + <xsl:call-template name="hex2number"> + <xsl:with-param name="hex" 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"/> + </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"/> + <uppervalue null="1"/> + <label>Andere</label> + <pointsymbol>hard:circle</pointsymbol> + <pointsize>2</pointsize> + <pointsizeunits>pixels</pointsizeunits> + <rotationclassificationfieldname/> + <scaleclassificationfieldname/> + <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"/> + </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/> + <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> -