In [1]:
from colour import Color
import numpy as np
In [2]:
def generateRamp2(col1, col2, steps, rangeMin, rangeMax):
ramp = Color(col1).range_to(Color(col2), steps)
rgbRamp = list(
map(lambda c: list(
map(lambda ve: int(ve * 255), c.rgb)), ramp)
)
linInt = list(map(lambda x: str("%.2f" % round(x, 2)), np.linspace(rangeMin, rangeMax)))
values = list(zip(linInt, rgbRamp))
res_strings = list(map(lambda val:
" ".join(
("case {0} > c.1".format(val[0]),
"return {{red: {0}; green: {1}; blue: {2}}}".format(val[1][0], val[1][1], val[1][2]))
),
values)
)
head_strings = 'image>>for c in ( iri_test ) return encode( switch case c.1 = -9999 return {red: 0; green: 0; blue: 0}'
tail_strings = 'default return {red: 1; green: 1; blue: 1} , "png")'
return (head_strings + " ".join(res_strings) + tail_strings).encode('unicode-escape').decode()
generateRamp2("red", "blue", 100, -5, 5)
Out[2]:
In [ ]:
http://example.org/rasdaman/ows?service=WMS&version=1.3.0&request=InsertStyle
&name=FireMarkup
&layer=dessert_area
&abstract=This style marks the areas where fires are in progress with the color red
&rasqlTransformFragment=case $Iterator when ($Iterator.c1) < 0 then {255, 0, 0} else {0, 255, 0} end
In [ ]: