Mercurial > gemma
diff pkg/geoserver/templates_test.go @ 3828:885eb90255ff sld-colors
Cleanup templating of styles [WIP].
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 03 Jul 2019 18:26:41 +0200 |
parents | 4b1184fa0326 |
children | 464a6a6e05e6 |
line wrap: on
line diff
--- a/pkg/geoserver/templates_test.go Wed Jul 03 17:48:47 2019 +0200 +++ b/pkg/geoserver/templates_test.go Wed Jul 03 18:26:41 2019 +0200 @@ -14,7 +14,6 @@ package geoserver import ( - "fmt" "strings" "testing" "text/template" @@ -166,10 +165,10 @@ </ogc:Function> {{- range . }} {{ if .HasHigh -}} - <ogc:Literal>{{ printf "%.1f" .High}}</ogc:Literal><ogc:Literal>{{ printf "%.1f" .High}}</ogc:Literal> - {{- else if .HasLow -}} - <ogc:Literal>{{ printf "%.1f" .Low}}</ogc:Literal><ogc:Literal>{{ printf "%.1f" .Low}}</ogc:Literal> - {{- end }} + <ogc:Literal>{{ printf "%.1f" .High}}</ogc:Literal><ogc:Literal>{{ printf "%.1f" .High}}</ogc:Literal> + {{- else if .HasLow -}} + <ogc:Literal>{{ printf "%.1f" .Low}}</ogc:Literal><ogc:Literal>{{ printf "%.1f" .Low}}</ogc:Literal> + {{- end }} {{- end }} </ogc:Function> </se:Label> @@ -898,14 +897,6 @@ 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,7.5:#1414ff` -type classBreaks struct { - High float64 - HasHigh bool - Low float64 - HasLow bool - Color string -} - func TestTemplate(t *testing.T) { ccs, err := parseColorClasses(classBreaksConfig) @@ -923,21 +914,7 @@ } */ - cbs := make([]classBreaks, len(ccs)) - for i := range ccs { - if i > 0 { - cbs[i].Low = ccs[i-1].value - cbs[i].HasLow = true - } - if i < len(ccs)-1 { - cbs[i].High = ccs[i].value - cbs[i].HasHigh = true - } - cbs[i].Color = fmt.Sprintf("#%02x%02x%02x", - ccs[i].color.R, - ccs[i].color.G, - ccs[i].color.B) - } + cbs := ccs.toClassBreaks() tmpl, err := template.New("test").Parse(sldTmplTxt) if err != nil {