Mercurial > gemma
view pkg/geoserver/templates_test.go @ 5122:0b6b62d247e8 queued-stage-done
Prioritize review jobs on selection
This reverts rev. 37784b70eea3 and instead moves review jobs forward
in the queue when fetching the next job to be run. Also optimized
index setup for filtering by state but not enqueued.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 26 Mar 2020 14:41:23 +0100 |
parents | 3fcc4e11fc00 |
children |
line wrap: on
line source
// This is Free Software under GNU Affero General Public License v >= 3.0 // without warranty, see README.md and license for details. // // SPDX-License-Identifier: AGPL-3.0-or-later // License-Filename: LICENSES/AGPL-3.0.txt // // Copyright (C) 2018 by via donau // – Österreichische Wasserstraßen-Gesellschaft mbH // Software engineering by Intevation GmbH // // Author(s): // * Sascha L. Teichmann <sascha.teichmann@intevation.de> package geoserver import ( "strings" "testing" "text/template" "gemma.intevation.de/gemma/pkg/models" "github.com/sergi/go-diff/diffmatchpatch" ) const sldTmplTxt = `<?xml version="1.0" encoding="UTF-8"?> <StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:se="http://www.opengis.net/se" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" version="1.1.0"> <NamedLayer> <se:Name>sounding_results_contour_lines</se:Name> <UserStyle> <se:Name>sounding_results_contour_lines</se:Name> <se:FeatureTypeStyle> <se:Name>contour_line_colours</se:Name> <se:Description> <se:Abstract> FeatureTypeStyle defining colour classes for height attribute </se:Abstract> </se:Description> {{ range . -}} <se:Rule> {{- if not .HasLow }} <se:Name>≤ {{ printf "%g" .High }}</se:Name> <ogc:Filter> <ogc:PropertyIsLessThanOrEqualTo> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>{{ printf "%g" .High }}</ogc:Literal> </ogc:PropertyIsLessThanOrEqualTo> </ogc:Filter> {{- else if not .HasHigh }} <se:Name>> {{ printf "%g" .Low }}</se:Name> <ogc:Filter> <ogc:PropertyIsGreaterThanOrEqualTo> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>{{ printf "%g" .Low }}</ogc:Literal> </ogc:PropertyIsGreaterThanOrEqualTo> </ogc:Filter> {{- else }} <se:Name>≤ {{ printf "%g" .High }}</se:Name> <ogc:Filter> <ogc:And> <ogc:PropertyIsGreaterThan> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>{{ printf "%g" .Low }}</ogc:Literal> </ogc:PropertyIsGreaterThan> <ogc:PropertyIsLessThanOrEqualTo> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>{{ printf "%g" .High }}</ogc:Literal> </ogc:PropertyIsLessThanOrEqualTo> </ogc:And> </ogc:Filter> {{- end }} <se:LineSymbolizer> <se:Stroke> <se:SvgParameter name="stroke">{{ .Color }}</se:SvgParameter> <se:SvgParameter name="stroke-width">0.5</se:SvgParameter> </se:Stroke> </se:LineSymbolizer> </se:Rule> {{ end }} </se:FeatureTypeStyle> <se:FeatureTypeStyle> <se:Name>contour_lines_emph</se:Name> <se:Description> <se:Abstract> FeatureTypeStyle for emphasized contour lines </se:Abstract> </se:Description> <se:Rule> <se:LegendGraphic> <se:Graphic> </se:Graphic> </se:LegendGraphic> <ogc:Filter> <ogc:Or> {{ range . -}} {{ if .HasHigh -}} <ogc:PropertyIsEqualTo> <ogc:Function name="numberFormat"> <ogc:Literal>0.0</ogc:Literal> <ogc:PropertyName>height</ogc:PropertyName> </ogc:Function> <ogc:Literal>{{ printf "%g" .High }}</ogc:Literal> </ogc:PropertyIsEqualTo> {{ end -}} {{ end }} </ogc:Or> </ogc:Filter> <se:MaxScaleDenominator>5e3</se:MaxScaleDenominator> <se:LineSymbolizer> <se:Stroke> <se:SvgParameter name="stroke-width">1.5</se:SvgParameter> <se:SvgParameter name="stroke"> <ogc:Function name="Recode"> <ogc:Function name="numberFormat"> <ogc:Literal>0.0</ogc:Literal> <ogc:PropertyName>height</ogc:PropertyName> </ogc:Function> {{ range . -}} {{ if .HasHigh -}} <ogc:Literal>{{ printf "%g" .High }}</ogc:Literal> <ogc:Literal>{{ .Color }}</ogc:Literal> {{ end -}} {{ end }} </ogc:Function> </se:SvgParameter> </se:Stroke> </se:LineSymbolizer> </se:Rule> </se:FeatureTypeStyle> <se:FeatureTypeStyle> <se:Name>contour_lines_label</se:Name> <se:Description> <se:Abstract> FeatureTypeStyle for labels at contour lines </se:Abstract> </se:Description> <se:Rule> <se:MaxScaleDenominator>5e3</se:MaxScaleDenominator> <se:TextSymbolizer> <se:Label> <ogc:Function name="Recode"> <ogc:Function name="numberFormat"> <ogc:Literal>0.0</ogc:Literal> <ogc:PropertyName>height</ogc:PropertyName> </ogc:Function> {{ range . -}} {{ if .HasHigh -}} <ogc:Literal> {{- printf "%g" .High -}} </ogc:Literal><ogc:Literal> {{- printf "%g" .High -}} </ogc:Literal> {{ end -}} {{ end }} </ogc:Function> </se:Label> <se:LabelPlacement> <se:LinePlacement> <se:PerpendicularOffset>5</se:PerpendicularOffset> </se:LinePlacement> </se:LabelPlacement> <se:Font> <se:SvgParameter name="font-family">Avenir</se:SvgParameter> <se:SvgParameter name="font-family">Helvetica</se:SvgParameter> <se:SvgParameter name="font-family">Arial</se:SvgParameter> <se:SvgParameter name="font-family">sans-serif</se:SvgParameter> </se:Font> <se:Fill> <se:SvgParameter name="fill">#070707</se:SvgParameter> </se:Fill> </se:TextSymbolizer> </se:Rule> </se:FeatureTypeStyle> </UserStyle> </NamedLayer> </StyledLayerDescriptor> ` const origSLD = `<?xml version="1.0" encoding="UTF-8"?> <StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:se="http://www.opengis.net/se" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" version="1.1.0"> <NamedLayer> <se:Name>sounding_results_contour_lines</se:Name> <UserStyle> <se:Name>sounding_results_contour_lines</se:Name> <se:FeatureTypeStyle> <se:Name>contour_line_colours</se:Name> <se:Description> <se:Abstract> FeatureTypeStyle defining colour classes for height attribute </se:Abstract> </se:Description> <se:Rule> <se:Name>≤ 1</se:Name> <ogc:Filter> <ogc:PropertyIsLessThanOrEqualTo> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>1</ogc:Literal> </ogc:PropertyIsLessThanOrEqualTo> </ogc:Filter> <se:LineSymbolizer> <se:Stroke> <se:SvgParameter name="stroke">#ff00dd</se:SvgParameter> <se:SvgParameter name="stroke-width">0.5</se:SvgParameter> </se:Stroke> </se:LineSymbolizer> </se:Rule> <se:Rule> <se:Name>≤ 1.5</se:Name> <ogc:Filter> <ogc:And> <ogc:PropertyIsGreaterThan> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>1</ogc:Literal> </ogc:PropertyIsGreaterThan> <ogc:PropertyIsLessThanOrEqualTo> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>1.5</ogc:Literal> </ogc:PropertyIsLessThanOrEqualTo> </ogc:And> </ogc:Filter> <se:LineSymbolizer> <se:Stroke> <se:SvgParameter name="stroke">#fb209e</se:SvgParameter> <se:SvgParameter name="stroke-width">0.5</se:SvgParameter> </se:Stroke> </se:LineSymbolizer> </se:Rule> <se:Rule> <se:Name>≤ 1.7</se:Name> <ogc:Filter> <ogc:And> <ogc:PropertyIsGreaterThan> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>1.5</ogc:Literal> </ogc:PropertyIsGreaterThan> <ogc:PropertyIsLessThanOrEqualTo> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>1.7</ogc:Literal> </ogc:PropertyIsLessThanOrEqualTo> </ogc:And> </ogc:Filter> <se:LineSymbolizer> <se:Stroke> <se:SvgParameter name="stroke">#f92c85</se:SvgParameter> <se:SvgParameter name="stroke-width">0.5</se:SvgParameter> </se:Stroke> </se:LineSymbolizer> </se:Rule> <se:Rule> <se:Name>≤ 1.9</se:Name> <ogc:Filter> <ogc:And> <ogc:PropertyIsGreaterThan> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>1.7</ogc:Literal> </ogc:PropertyIsGreaterThan> <ogc:PropertyIsLessThanOrEqualTo> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>1.9</ogc:Literal> </ogc:PropertyIsLessThanOrEqualTo> </ogc:And> </ogc:Filter> <se:LineSymbolizer> <se:Stroke> <se:SvgParameter name="stroke">#f7396c</se:SvgParameter> <se:SvgParameter name="stroke-width">0.5</se:SvgParameter> </se:Stroke> </se:LineSymbolizer> </se:Rule> <se:Rule> <se:Name>≤ 2.1</se:Name> <ogc:Filter> <ogc:And> <ogc:PropertyIsGreaterThan> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>1.9</ogc:Literal> </ogc:PropertyIsGreaterThan> <ogc:PropertyIsLessThanOrEqualTo> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>2.1</ogc:Literal> </ogc:PropertyIsLessThanOrEqualTo> </ogc:And> </ogc:Filter> <se:LineSymbolizer> <se:Stroke> <se:SvgParameter name="stroke">#f54652</se:SvgParameter> <se:SvgParameter name="stroke-width">0.5</se:SvgParameter> </se:Stroke> </se:LineSymbolizer> </se:Rule> <se:Rule> <se:Name>≤ 2.3</se:Name> <ogc:Filter> <ogc:And> <ogc:PropertyIsGreaterThan> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>2.1</ogc:Literal> </ogc:PropertyIsGreaterThan> <ogc:PropertyIsLessThanOrEqualTo> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>2.3</ogc:Literal> </ogc:PropertyIsLessThanOrEqualTo> </ogc:And> </ogc:Filter> <se:LineSymbolizer> <se:Stroke> <se:SvgParameter name="stroke">#f45239</se:SvgParameter> <se:SvgParameter name="stroke-width">0.5</se:SvgParameter> </se:Stroke> </se:LineSymbolizer> </se:Rule> <se:Rule> <se:Name>≤ 2.5</se:Name> <ogc:Filter> <ogc:And> <ogc:PropertyIsGreaterThan> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>2.3</ogc:Literal> </ogc:PropertyIsGreaterThan> <ogc:PropertyIsLessThanOrEqualTo> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>2.5</ogc:Literal> </ogc:PropertyIsLessThanOrEqualTo> </ogc:And> </ogc:Filter> <se:LineSymbolizer> <se:Stroke> <se:SvgParameter name="stroke">#f25f20</se:SvgParameter> <se:SvgParameter name="stroke-width">0.5</se:SvgParameter> </se:Stroke> </se:LineSymbolizer> </se:Rule> <se:Rule> <se:Name>≤ 2.7</se:Name> <ogc:Filter> <ogc:And> <ogc:PropertyIsGreaterThan> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>2.5</ogc:Literal> </ogc:PropertyIsGreaterThan> <ogc:PropertyIsLessThanOrEqualTo> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>2.7</ogc:Literal> </ogc:PropertyIsLessThanOrEqualTo> </ogc:And> </ogc:Filter> <se:LineSymbolizer> <se:Stroke> <se:SvgParameter name="stroke">#e46f1f</se:SvgParameter> <se:SvgParameter name="stroke-width">0.5</se:SvgParameter> </se:Stroke> </se:LineSymbolizer> </se:Rule> <se:Rule> <se:Name>≤ 2.9</se:Name> <ogc:Filter> <ogc:And> <ogc:PropertyIsGreaterThan> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>2.7</ogc:Literal> </ogc:PropertyIsGreaterThan> <ogc:PropertyIsLessThanOrEqualTo> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>2.9</ogc:Literal> </ogc:PropertyIsLessThanOrEqualTo> </ogc:And> </ogc:Filter> <se:LineSymbolizer> <se:Stroke> <se:SvgParameter name="stroke">#d67e1e</se:SvgParameter> <se:SvgParameter name="stroke-width">0.5</se:SvgParameter> </se:Stroke> </se:LineSymbolizer> </se:Rule> <se:Rule> <se:Name>≤ 3.1</se:Name> <ogc:Filter> <ogc:And> <ogc:PropertyIsGreaterThan> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>2.9</ogc:Literal> </ogc:PropertyIsGreaterThan> <ogc:PropertyIsLessThanOrEqualTo> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>3.1</ogc:Literal> </ogc:PropertyIsLessThanOrEqualTo> </ogc:And> </ogc:Filter> <se:LineSymbolizer> <se:Stroke> <se:SvgParameter name="stroke">#c88e1e</se:SvgParameter> <se:SvgParameter name="stroke-width">0.5</se:SvgParameter> </se:Stroke> </se:LineSymbolizer> </se:Rule> <se:Rule> <se:Name>≤ 3.3</se:Name> <ogc:Filter> <ogc:And> <ogc:PropertyIsGreaterThan> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>3.1</ogc:Literal> </ogc:PropertyIsGreaterThan> <ogc:PropertyIsLessThanOrEqualTo> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>3.3</ogc:Literal> </ogc:PropertyIsLessThanOrEqualTo> </ogc:And> </ogc:Filter> <se:LineSymbolizer> <se:Stroke> <se:SvgParameter name="stroke">#bb9e1d</se:SvgParameter> <se:SvgParameter name="stroke-width">0.5</se:SvgParameter> </se:Stroke> </se:LineSymbolizer> </se:Rule> <se:Rule> <se:Name>≤ 3.5</se:Name> <ogc:Filter> <ogc:And> <ogc:PropertyIsGreaterThan> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>3.3</ogc:Literal> </ogc:PropertyIsGreaterThan> <ogc:PropertyIsLessThanOrEqualTo> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>3.5</ogc:Literal> </ogc:PropertyIsLessThanOrEqualTo> </ogc:And> </ogc:Filter> <se:LineSymbolizer> <se:Stroke> <se:SvgParameter name="stroke">#adae1c</se:SvgParameter> <se:SvgParameter name="stroke-width">0.5</se:SvgParameter> </se:Stroke> </se:LineSymbolizer> </se:Rule> <se:Rule> <se:Name>≤ 4</se:Name> <ogc:Filter> <ogc:And> <ogc:PropertyIsGreaterThan> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>3.5</ogc:Literal> </ogc:PropertyIsGreaterThan> <ogc:PropertyIsLessThanOrEqualTo> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>4</ogc:Literal> </ogc:PropertyIsLessThanOrEqualTo> </ogc:And> </ogc:Filter> <se:LineSymbolizer> <se:Stroke> <se:SvgParameter name="stroke">#8ad51a</se:SvgParameter> <se:SvgParameter name="stroke-width">0.5</se:SvgParameter> </se:Stroke> </se:LineSymbolizer> </se:Rule> <se:Rule> <se:Name>≤ 4.5</se:Name> <ogc:Filter> <ogc:And> <ogc:PropertyIsGreaterThan> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>4</ogc:Literal> </ogc:PropertyIsGreaterThan> <ogc:PropertyIsLessThanOrEqualTo> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>4.5</ogc:Literal> </ogc:PropertyIsLessThanOrEqualTo> </ogc:And> </ogc:Filter> <se:LineSymbolizer> <se:Stroke> <se:SvgParameter name="stroke">#76b540</se:SvgParameter> <se:SvgParameter name="stroke-width">0.5</se:SvgParameter> </se:Stroke> </se:LineSymbolizer> </se:Rule> <se:Rule> <se:Name>≤ 5</se:Name> <ogc:Filter> <ogc:And> <ogc:PropertyIsGreaterThan> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>4.5</ogc:Literal> </ogc:PropertyIsGreaterThan> <ogc:PropertyIsLessThanOrEqualTo> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>5</ogc:Literal> </ogc:PropertyIsLessThanOrEqualTo> </ogc:And> </ogc:Filter> <se:LineSymbolizer> <se:Stroke> <se:SvgParameter name="stroke">#639566</se:SvgParameter> <se:SvgParameter name="stroke-width">0.5</se:SvgParameter> </se:Stroke> </se:LineSymbolizer> </se:Rule> <se:Rule> <se:Name>≤ 5.5</se:Name> <ogc:Filter> <ogc:And> <ogc:PropertyIsGreaterThan> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>5</ogc:Literal> </ogc:PropertyIsGreaterThan> <ogc:PropertyIsLessThanOrEqualTo> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>5.5</ogc:Literal> </ogc:PropertyIsLessThanOrEqualTo> </ogc:And> </ogc:Filter> <se:LineSymbolizer> <se:Stroke> <se:SvgParameter name="stroke">#4f758d</se:SvgParameter> <se:SvgParameter name="stroke-width">0.5</se:SvgParameter> </se:Stroke> </se:LineSymbolizer> </se:Rule> <se:Rule> <se:Name>≤ 6</se:Name> <ogc:Filter> <ogc:And> <ogc:PropertyIsGreaterThan> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>5.5</ogc:Literal> </ogc:PropertyIsGreaterThan> <ogc:PropertyIsLessThanOrEqualTo> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>6</ogc:Literal> </ogc:PropertyIsLessThanOrEqualTo> </ogc:And> </ogc:Filter> <se:LineSymbolizer> <se:Stroke> <se:SvgParameter name="stroke">#3b54b3</se:SvgParameter> <se:SvgParameter name="stroke-width">0.5</se:SvgParameter> </se:Stroke> </se:LineSymbolizer> </se:Rule> <se:Rule> <se:Name>≤ 6.5</se:Name> <ogc:Filter> <ogc:And> <ogc:PropertyIsGreaterThan> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>6</ogc:Literal> </ogc:PropertyIsGreaterThan> <ogc:PropertyIsLessThanOrEqualTo> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>6.5</ogc:Literal> </ogc:PropertyIsLessThanOrEqualTo> </ogc:And> </ogc:Filter> <se:LineSymbolizer> <se:Stroke> <se:SvgParameter name="stroke">#2834d9</se:SvgParameter> <se:SvgParameter name="stroke-width">0.5</se:SvgParameter> </se:Stroke> </se:LineSymbolizer> </se:Rule> <se:Rule> <se:Name>≤ 7</se:Name> <ogc:Filter> <ogc:And> <ogc:PropertyIsGreaterThan> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>6.5</ogc:Literal> </ogc:PropertyIsGreaterThan> <ogc:PropertyIsLessThanOrEqualTo> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>7</ogc:Literal> </ogc:PropertyIsLessThanOrEqualTo> </ogc:And> </ogc:Filter> <se:LineSymbolizer> <se:Stroke> <se:SvgParameter name="stroke">#1414ff</se:SvgParameter> <se:SvgParameter name="stroke-width">0.5</se:SvgParameter> </se:Stroke> </se:LineSymbolizer> </se:Rule> <se:Rule> <se:Name>> 7</se:Name> <ogc:Filter> <ogc:PropertyIsGreaterThanOrEqualTo> <ogc:PropertyName>height</ogc:PropertyName> <ogc:Literal>7</ogc:Literal> </ogc:PropertyIsGreaterThanOrEqualTo> </ogc:Filter> <se:LineSymbolizer> <se:Stroke> <se:SvgParameter name="stroke">#1414ff</se:SvgParameter> <se:SvgParameter name="stroke-width">0.5</se:SvgParameter> </se:Stroke> </se:LineSymbolizer> </se:Rule> </se:FeatureTypeStyle> <se:FeatureTypeStyle> <se:Name>contour_lines_emph</se:Name> <se:Description> <se:Abstract> FeatureTypeStyle for emphasized contour lines </se:Abstract> </se:Description> <se:Rule> <se:LegendGraphic> <se:Graphic> </se:Graphic> </se:LegendGraphic> <ogc:Filter> <ogc:Or> <ogc:PropertyIsEqualTo> <ogc:Function name="numberFormat"> <ogc:Literal>0.0</ogc:Literal> <ogc:PropertyName>height</ogc:PropertyName> </ogc:Function> <ogc:Literal>1</ogc:Literal> </ogc:PropertyIsEqualTo> <ogc:PropertyIsEqualTo> <ogc:Function name="numberFormat"> <ogc:Literal>0.0</ogc:Literal> <ogc:PropertyName>height</ogc:PropertyName> </ogc:Function> <ogc:Literal>1.5</ogc:Literal> </ogc:PropertyIsEqualTo> <ogc:PropertyIsEqualTo> <ogc:Function name="numberFormat"> <ogc:Literal>0.0</ogc:Literal> <ogc:PropertyName>height</ogc:PropertyName> </ogc:Function> <ogc:Literal>1.7</ogc:Literal> </ogc:PropertyIsEqualTo> <ogc:PropertyIsEqualTo> <ogc:Function name="numberFormat"> <ogc:Literal>0.0</ogc:Literal> <ogc:PropertyName>height</ogc:PropertyName> </ogc:Function> <ogc:Literal>1.9</ogc:Literal> </ogc:PropertyIsEqualTo> <ogc:PropertyIsEqualTo> <ogc:Function name="numberFormat"> <ogc:Literal>0.0</ogc:Literal> <ogc:PropertyName>height</ogc:PropertyName> </ogc:Function> <ogc:Literal>2.1</ogc:Literal> </ogc:PropertyIsEqualTo> <ogc:PropertyIsEqualTo> <ogc:Function name="numberFormat"> <ogc:Literal>0.0</ogc:Literal> <ogc:PropertyName>height</ogc:PropertyName> </ogc:Function> <ogc:Literal>2.3</ogc:Literal> </ogc:PropertyIsEqualTo> <ogc:PropertyIsEqualTo> <ogc:Function name="numberFormat"> <ogc:Literal>0.0</ogc:Literal> <ogc:PropertyName>height</ogc:PropertyName> </ogc:Function> <ogc:Literal>2.5</ogc:Literal> </ogc:PropertyIsEqualTo> <ogc:PropertyIsEqualTo> <ogc:Function name="numberFormat"> <ogc:Literal>0.0</ogc:Literal> <ogc:PropertyName>height</ogc:PropertyName> </ogc:Function> <ogc:Literal>2.7</ogc:Literal> </ogc:PropertyIsEqualTo> <ogc:PropertyIsEqualTo> <ogc:Function name="numberFormat"> <ogc:Literal>0.0</ogc:Literal> <ogc:PropertyName>height</ogc:PropertyName> </ogc:Function> <ogc:Literal>2.9</ogc:Literal> </ogc:PropertyIsEqualTo> <ogc:PropertyIsEqualTo> <ogc:Function name="numberFormat"> <ogc:Literal>0.0</ogc:Literal> <ogc:PropertyName>height</ogc:PropertyName> </ogc:Function> <ogc:Literal>3.1</ogc:Literal> </ogc:PropertyIsEqualTo> <ogc:PropertyIsEqualTo> <ogc:Function name="numberFormat"> <ogc:Literal>0.0</ogc:Literal> <ogc:PropertyName>height</ogc:PropertyName> </ogc:Function> <ogc:Literal>3.3</ogc:Literal> </ogc:PropertyIsEqualTo> <ogc:PropertyIsEqualTo> <ogc:Function name="numberFormat"> <ogc:Literal>0.0</ogc:Literal> <ogc:PropertyName>height</ogc:PropertyName> </ogc:Function> <ogc:Literal>3.5</ogc:Literal> </ogc:PropertyIsEqualTo> <ogc:PropertyIsEqualTo> <ogc:Function name="numberFormat"> <ogc:Literal>0.0</ogc:Literal> <ogc:PropertyName>height</ogc:PropertyName> </ogc:Function> <ogc:Literal>4</ogc:Literal> </ogc:PropertyIsEqualTo> <ogc:PropertyIsEqualTo> <ogc:Function name="numberFormat"> <ogc:Literal>0.0</ogc:Literal> <ogc:PropertyName>height</ogc:PropertyName> </ogc:Function> <ogc:Literal>4.5</ogc:Literal> </ogc:PropertyIsEqualTo> <ogc:PropertyIsEqualTo> <ogc:Function name="numberFormat"> <ogc:Literal>0.0</ogc:Literal> <ogc:PropertyName>height</ogc:PropertyName> </ogc:Function> <ogc:Literal>5</ogc:Literal> </ogc:PropertyIsEqualTo> <ogc:PropertyIsEqualTo> <ogc:Function name="numberFormat"> <ogc:Literal>0.0</ogc:Literal> <ogc:PropertyName>height</ogc:PropertyName> </ogc:Function> <ogc:Literal>5.5</ogc:Literal> </ogc:PropertyIsEqualTo> <ogc:PropertyIsEqualTo> <ogc:Function name="numberFormat"> <ogc:Literal>0.0</ogc:Literal> <ogc:PropertyName>height</ogc:PropertyName> </ogc:Function> <ogc:Literal>6</ogc:Literal> </ogc:PropertyIsEqualTo> <ogc:PropertyIsEqualTo> <ogc:Function name="numberFormat"> <ogc:Literal>0.0</ogc:Literal> <ogc:PropertyName>height</ogc:PropertyName> </ogc:Function> <ogc:Literal>6.5</ogc:Literal> </ogc:PropertyIsEqualTo> <ogc:PropertyIsEqualTo> <ogc:Function name="numberFormat"> <ogc:Literal>0.0</ogc:Literal> <ogc:PropertyName>height</ogc:PropertyName> </ogc:Function> <ogc:Literal>7</ogc:Literal> </ogc:PropertyIsEqualTo> </ogc:Or> </ogc:Filter> <se:MaxScaleDenominator>5e3</se:MaxScaleDenominator> <se:LineSymbolizer> <se:Stroke> <se:SvgParameter name="stroke-width">1.5</se:SvgParameter> <se:SvgParameter name="stroke"> <ogc:Function name="Recode"> <ogc:Function name="numberFormat"> <ogc:Literal>0.0</ogc:Literal> <ogc:PropertyName>height</ogc:PropertyName> </ogc:Function> <ogc:Literal>1</ogc:Literal> <ogc:Literal>#ff00dd</ogc:Literal> <ogc:Literal>1.5</ogc:Literal> <ogc:Literal>#fb209e</ogc:Literal> <ogc:Literal>1.7</ogc:Literal> <ogc:Literal>#f92c85</ogc:Literal> <ogc:Literal>1.9</ogc:Literal> <ogc:Literal>#f7396c</ogc:Literal> <ogc:Literal>2.1</ogc:Literal> <ogc:Literal>#f54652</ogc:Literal> <ogc:Literal>2.3</ogc:Literal> <ogc:Literal>#f45239</ogc:Literal> <ogc:Literal>2.5</ogc:Literal> <ogc:Literal>#f25f20</ogc:Literal> <ogc:Literal>2.7</ogc:Literal> <ogc:Literal>#e46f1f</ogc:Literal> <ogc:Literal>2.9</ogc:Literal> <ogc:Literal>#d67e1e</ogc:Literal> <ogc:Literal>3.1</ogc:Literal> <ogc:Literal>#c88e1e</ogc:Literal> <ogc:Literal>3.3</ogc:Literal> <ogc:Literal>#bb9e1d</ogc:Literal> <ogc:Literal>3.5</ogc:Literal> <ogc:Literal>#adae1c</ogc:Literal> <ogc:Literal>4</ogc:Literal> <ogc:Literal>#8ad51a</ogc:Literal> <ogc:Literal>4.5</ogc:Literal> <ogc:Literal>#76b540</ogc:Literal> <ogc:Literal>5</ogc:Literal> <ogc:Literal>#639566</ogc:Literal> <ogc:Literal>5.5</ogc:Literal> <ogc:Literal>#4f758d</ogc:Literal> <ogc:Literal>6</ogc:Literal> <ogc:Literal>#3b54b3</ogc:Literal> <ogc:Literal>6.5</ogc:Literal> <ogc:Literal>#2834d9</ogc:Literal> <ogc:Literal>7</ogc:Literal> <ogc:Literal>#1414ff</ogc:Literal> </ogc:Function> </se:SvgParameter> </se:Stroke> </se:LineSymbolizer> </se:Rule> </se:FeatureTypeStyle> <se:FeatureTypeStyle> <se:Name>contour_lines_label</se:Name> <se:Description> <se:Abstract> FeatureTypeStyle for labels at contour lines </se:Abstract> </se:Description> <se:Rule> <se:MaxScaleDenominator>5e3</se:MaxScaleDenominator> <se:TextSymbolizer> <se:Label> <ogc:Function name="Recode"> <ogc:Function name="numberFormat"> <ogc:Literal>0.0</ogc:Literal> <ogc:PropertyName>height</ogc:PropertyName> </ogc:Function> <ogc:Literal>1</ogc:Literal><ogc:Literal>1</ogc:Literal> <ogc:Literal>1.5</ogc:Literal><ogc:Literal>1.5</ogc:Literal> <ogc:Literal>1.7</ogc:Literal><ogc:Literal>1.7</ogc:Literal> <ogc:Literal>1.9</ogc:Literal><ogc:Literal>1.9</ogc:Literal> <ogc:Literal>2.1</ogc:Literal><ogc:Literal>2.1</ogc:Literal> <ogc:Literal>2.3</ogc:Literal><ogc:Literal>2.3</ogc:Literal> <ogc:Literal>2.5</ogc:Literal><ogc:Literal>2.5</ogc:Literal> <ogc:Literal>2.7</ogc:Literal><ogc:Literal>2.7</ogc:Literal> <ogc:Literal>2.9</ogc:Literal><ogc:Literal>2.9</ogc:Literal> <ogc:Literal>3.1</ogc:Literal><ogc:Literal>3.1</ogc:Literal> <ogc:Literal>3.3</ogc:Literal><ogc:Literal>3.3</ogc:Literal> <ogc:Literal>3.5</ogc:Literal><ogc:Literal>3.5</ogc:Literal> <ogc:Literal>4</ogc:Literal><ogc:Literal>4</ogc:Literal> <ogc:Literal>4.5</ogc:Literal><ogc:Literal>4.5</ogc:Literal> <ogc:Literal>5</ogc:Literal><ogc:Literal>5</ogc:Literal> <ogc:Literal>5.5</ogc:Literal><ogc:Literal>5.5</ogc:Literal> <ogc:Literal>6</ogc:Literal><ogc:Literal>6</ogc:Literal> <ogc:Literal>6.5</ogc:Literal><ogc:Literal>6.5</ogc:Literal> <ogc:Literal>7</ogc:Literal><ogc:Literal>7</ogc:Literal> </ogc:Function> </se:Label> <se:LabelPlacement> <se:LinePlacement> <se:PerpendicularOffset>5</se:PerpendicularOffset> </se:LinePlacement> </se:LabelPlacement> <se:Font> <se:SvgParameter name="font-family">Avenir</se:SvgParameter> <se:SvgParameter name="font-family">Helvetica</se:SvgParameter> <se:SvgParameter name="font-family">Arial</se:SvgParameter> <se:SvgParameter name="font-family">sans-serif</se:SvgParameter> </se:Font> <se:Fill> <se:SvgParameter name="fill">#070707</se:SvgParameter> </se:Fill> </se:TextSymbolizer> </se:Rule> </se:FeatureTypeStyle> </UserStyle> </NamedLayer> </StyledLayerDescriptor> ` const classBreaksConfig = `1:#ff00dd,1.5,1.7,1.9,2.1,2.3,` + `2.5:#f25f20,2.7,2.9,3.1,3.3,3.5,` + `4:#8ad51a,4.5,5,5.5,6,6.5,` + `7:#1414ff` func TestTemplate(t *testing.T) { ccs, err := models.ParseColorValues(classBreaksConfig) if err != nil { t.Fatalf("parsing color config failed: %v", err) } cbs := ccs.ClassBreaks() tmpl, err := template.New("test").Parse(sldTmplTxt) if err != nil { t.Fatalf("parsing template failed: %v", err) } var buf strings.Builder if err := tmpl.Execute(&buf, cbs); err != nil { t.Fatalf("templating failed: %v", err) } has := buf.String() if has != origSLD { dmp := diffmatchpatch.New() diffs := dmp.DiffMain(has, origSLD, true) t.Fatalf("Templating results differ: %s", dmp.DiffPrettyText(diffs)) } }