# HG changeset patch # User Sascha L. Teichmann # Date 1562253485 -7200 # Node ID cbced21c6d9450912e3cfa4eec4c3a8ddc70425e # Parent 0ffea636d6b0eea66c60af4663631ac746bc258a Adjusted unit test for SLD templating. diff -r 0ffea636d6b0 -r cbced21c6d94 pkg/geoserver/templates_test.go --- a/pkg/geoserver/templates_test.go Thu Jul 04 11:26:11 2019 +0200 +++ b/pkg/geoserver/templates_test.go Thu Jul 04 17:18:05 2019 +0200 @@ -34,21 +34,37 @@ sounding_results_contour_lines - contour_line_colours + contour_line_colours FeatureTypeStyle defining colour classes for height attribute {{ range . -}} - {{- if and .HasLow .HasHigh -}} - ≤ {{ printf "%.1f" .High }} + {{- if not .HasLow }} + ≤ {{ printf "%g" .High }} + + + height + {{ printf "%g" .High }} + + + {{- else if not .HasHigh }} + > {{ printf "%g" .Low }} + + + height + {{ printf "%g" .Low }} + + + {{- else }} + ≤ {{ printf "%g" .High }} height - {{.Low}} + {{ printf "%g" .Low }} height @@ -56,46 +72,14 @@ - + {{- end }} + - {{.Color}} + {{ .Color }} 0.5 - {{ else if .HasLow -}} - - > {{ printf "%.1f" .Low }} - - - height - {{ printf "%g" .Low }} - - - - - {{.Color}} - 0.5 - - - - {{ else if .HasHigh -}} - - ≤ {{ printf "%.1f" .High }} - - - height - {{ printf "%g" .High }} - - - - - {{.Color}} - 0.5 - - - - {{ end -}} {{ end }} @@ -104,25 +88,25 @@ FeatureTypeStyle for emphasized contour lines - - - - + + + + - - {{- range . }} - {{if .HasHigh -}} - + + {{ range . -}} + {{ if .HasHigh -}} + 0.0 height - {{ printf "%.1f" .High }} - - {{- end -}} - {{end }} + {{ printf "%g" .High }} + + {{ end -}} + {{ end }} 5e3 @@ -135,12 +119,12 @@ 0.0 height - {{- range .}} - {{if .HasHigh -}} - {{ printf "%.1f" .High }} - {{.Color}} - {{- end -}} - {{end}} + {{ range . -}} + {{ if .HasHigh -}} + {{ printf "%g" .High }} + {{ .Color }} + {{ end -}} + {{ end }} @@ -163,13 +147,15 @@ 0.0 height - {{- range . }} + {{ range . -}} {{ if .HasHigh -}} - {{ printf "%.1f" .High}}{{ printf "%.1f" .High}} - {{- else if .HasLow -}} - {{ printf "%.1f" .Low}}{{ printf "%.1f" .Low}} - {{- end }} - {{- end }} + + {{- printf "%g" .High -}} + + {{- printf "%g" .High -}} + + {{ end -}} + {{ end }} @@ -194,8 +180,7 @@ ` -const origSLD = ` - +const origSLD = ` sounding_results_contour_lines - contour_line_colours + contour_line_colours FeatureTypeStyle defining colour classes for height attribute - ≤ 1.0 + ≤ 1 height 1 - + #ff00dd 0.5 @@ -243,9 +228,9 @@ - + - #fb08b6 + #fb209e 0.5 @@ -264,9 +249,9 @@ - + - #f81090 + #f92c85 0.5 @@ -285,9 +270,9 @@ - + - #f5196a + #f7396c 0.5 @@ -306,9 +291,9 @@ - + - #f22144 + #f54652 0.5 @@ -327,9 +312,9 @@ - + - #f03326 + #f45239 0.5 @@ -348,7 +333,7 @@ - + #f25f20 0.5 @@ -369,9 +354,9 @@ - + - #f38b1a + #e46f1f 0.5 @@ -390,9 +375,9 @@ - + - #f5b814 + #d67e1e 0.5 @@ -411,9 +396,9 @@ - + - #f7e40e + #c88e1e 0.5 @@ -432,9 +417,9 @@ - + - #e2f30e + #bb9e1d 0.5 @@ -453,15 +438,15 @@ - + - #b6e414 + #adae1c 0.5 - ≤ 4.0 + ≤ 4 @@ -474,7 +459,7 @@ - + #8ad51a 0.5 @@ -495,15 +480,15 @@ - + - #5ec620 + #76b540 0.5 - ≤ 5.0 + ≤ 5 @@ -516,9 +501,9 @@ - + - #32b726 + #639566 0.5 @@ -537,15 +522,15 @@ - + - #249a49 + #4f758d 0.5 - ≤ 6.0 + ≤ 6 @@ -558,9 +543,9 @@ - + - #207977 + #3b54b3 0.5 @@ -579,15 +564,15 @@ - + - #1c57a4 + #2834d9 0.5 - ≤ 7.0 + ≤ 7 @@ -600,28 +585,29 @@ - - - #1835d1 - 0.5 - - - - - > 7.0 - - - height - 7 - - - + #1414ff 0.5 + + > 7 + + + height + 7 + + + + + #1414ff + 0.5 + + + + contour_lines_emph @@ -629,154 +615,148 @@ FeatureTypeStyle for emphasized contour lines - - - - + + + + - + 0.0 height - 1.0 - + 1 + 0.0 height 1.5 - + 0.0 height 1.7 - + 0.0 height 1.9 - + 0.0 height 2.1 - + 0.0 height 2.3 - + 0.0 height 2.5 - + 0.0 height 2.7 - + 0.0 height 2.9 - + 0.0 height 3.1 - + 0.0 height 3.3 - + 0.0 height 3.5 - + 0.0 height - 4.0 - + 4 + 0.0 height 4.5 - + 0.0 height - 5.0 - + 5 + 0.0 height 5.5 - + 0.0 height - 6.0 - + 6 + 0.0 height 6.5 - + 0.0 height - 7.0 - - - - 0.0 - height - - 7.5 - + 7 + + 5e3 @@ -789,46 +769,45 @@ 0.0 height - 1.0 + 1 #ff00dd 1.5 - #fb08b6 + #fb209e 1.7 - #f81090 + #f92c85 1.9 - #f5196a + #f7396c 2.1 - #f22144 + #f54652 2.3 - #f03326 + #f45239 2.5 #f25f20 2.7 - #f38b1a + #e46f1f 2.9 - #f5b814 + #d67e1e 3.1 - #f7e40e + #c88e1e 3.3 - #e2f30e + #bb9e1d 3.5 - #b6e414 - 4.0 + #adae1c + 4 #8ad51a 4.5 - #5ec620 - 5.0 - #32b726 + #76b540 + 5 + #639566 5.5 - #249a49 - 6.0 - #207977 + #4f758d + 6 + #3b54b3 6.5 - #1c57a4 - 7.0 - #1835d1 - 7.5 + #2834d9 + 7 #1414ff + @@ -851,7 +830,7 @@ 0.0 height - 1.01.0 + 11 1.51.5 1.71.7 1.91.9 @@ -863,14 +842,14 @@ 3.13.1 3.33.3 3.53.5 - 4.04.0 + 44 4.54.5 - 5.05.0 + 55 5.55.5 - 6.06.0 + 66 6.56.5 - 7.07.0 - 7.57.5 + 77 + @@ -897,7 +876,8 @@ 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.5:#1414ff` + `4:#8ad51a,4.5,5,5.5,6,6.5,` + + `7:#1414ff` func TestTemplate(t *testing.T) { @@ -906,16 +886,6 @@ t.Fatalf("parsing color config failed: %v", err) } - /* - for i := range ccs { - fmt.Printf("%.1f #%02x%02x%02x\n", - ccs[i].value, - ccs[i].color.R, - ccs[i].color.G, - ccs[i].color.B) - } - */ - cbs := ccs.toClassBreaks() tmpl, err := template.New("test").Parse(sldTmplTxt)