<div dir="ltr">hi, thanks allot!<div>that is exactly what i did after another user suggested it (<span style="font-family:arial,sans-serif;font-size:12.571428298950195px;white-space:nowrap"> </span><span name="Cristiano Sumariva" class="" style="font-size:12.571428298950195px;font-family:arial,sans-serif">Cristiano Sumariva</span><span style="font-family:arial,sans-serif;font-size:12.571428298950195px;white-space:nowrap"> )</span>. </div>
<div><br></div><div>here it is for reference:</div><div><br></div><div><div>CREATE OR REPLACE FUNCTION temp.ms_colorMath( percentile double precision )</div><div>RETURNS varchar</div><div>LANGUAGE plpgsql</div><div>AS</div>
<div>$$</div><div>DECLARE </div><div><span class="" style="white-space:pre"> </span>C double precision;</div><div><span class="" style="white-space:pre"> </span>X double precision;</div><div><span class="" style="white-space:pre"> </span>m double precision;</div>
<div><span class="" style="white-space:pre"> </span>H int;</div><div><span class="" style="white-space:pre"> </span>V double precision;</div><div><span class="" style="white-space:pre"> </span>S double precision;</div><div>
<br></div><div><span class="" style="white-space:pre"> </span>R int;</div><div><span class="" style="white-space:pre"> </span>G int;</div><div><span class="" style="white-space:pre"> </span>B int;</div><div>BEGIN</div><div>
--see here <a href="http://www.rapidtables.com/convert/color/hsv-to-rgb.htm">http://www.rapidtables.com/convert/color/hsv-to-rgb.htm</a></div><div>--if H != 0 need to change the function</div><div>--curently - red gradient</div>
<div><span class="" style="white-space:pre"> </span>S := percentile;</div><div><span class="" style="white-space:pre"> </span>IF (S < 0.1 AND S > 0) THEN S := 0.1; END IF;</div><div><span class="" style="white-space:pre"> </span></div>
<div><span class="" style="white-space:pre"> </span>H := 0;</div><div><span class="" style="white-space:pre"> </span>V := 1.0;</div><div><span class="" style="white-space:pre"> </span>C := V * S;</div><div><span class="" style="white-space:pre"> </span>X := C * (1-abs(mod(H/60,2)-1));</div>
<div><span class="" style="white-space:pre"> </span>m := V-C;</div><div><br></div><div><span class="" style="white-space:pre"> </span>R := ((C + m)*255 )::int;</div><div><span class="" style="white-space:pre"> </span>G := ((X + m)*255 )::int;</div>
<div><span class="" style="white-space:pre"> </span>B := ((0 + m)*255 )::int;</div><div><br></div><div><span class="" style="white-space:pre"> </span></div><div><span class="" style="white-space:pre"> </span>RETURN (R)::text || ' ' || (G)::text || ' ' || (B)::text;</div>
<div>END</div><div>$$;</div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jun 26, 2014 at 6:24 PM, Carlos Ruiz <span dir="ltr"><<a href="mailto:boolean10001@yahoo.com" target="_blank">boolean10001@yahoo.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">To achieve more flexibility as you want, you have to code a function with PL/pgSQL in PostgreSQL or with PHP/Python/Java/C# with Mapscript to define which is the base color (red, green, blue, yellow ...) and then to calculate the percent in the right RGB channel.<br>
<br>
<br>
Cheers<br>
<br>
Mtro. Carlos Ruiz<br>
<br>
--------------------------------------------<br>
On Mon, 6/23/14, Do Wi <<a href="mailto:dowi84@gmail.com">dowi84@gmail.com</a>> wrote:<br>
<br>
Subject: Re: [mapserver-users] color attribute question<br>
To: "Carlos Ruiz" <<a href="mailto:boolean10001@yahoo.com">boolean10001@yahoo.com</a>><br>
Date: Monday, June 23, 2014, 2:56 PM<br>
<div class=""><br>
thanks allot!<br>
Steve and another user here mentioned this path<br>
</div> and it did work!only problem is that it cannot be<br>
<div class="HOEnZb"><div class="h5"> changed later if for example the user chooses a blue<br>
gradient.<br>
<br>
how will i go about doing it with<br>
mapscript?<br>
maybe it relates to my question herehttp://<a href="http://gis.stackexchange.com/questions/102862/when-to-choose-mapscript-over-mapfile-or-vice-versa" target="_blank">gis.stackexchange.com/questions/102862/when-to-choose-mapscript-over-mapfile-or-vice-versa</a><br>
<br>
<br>
:-)<br>
thanks allot!dovi<br>
<br>
On Mon, Jun 23, 2014<br>
at 6:13 PM, Carlos Ruiz <<a href="mailto:boolean10001@yahoo.com">boolean10001@yahoo.com</a>><br>
wrote:<br>
<br>
<br>
Do,<br>
If<br>
you want to do this without using mapscript, you can pull<br>
the gradient calculation as an attribute from your data<br>
table.<br>
<br>
<br>
ALTER TABLE mytable ADD COLUMN gradient_color<br>
VARCHAR;<br>
UPTATE mytable SET gradient_color = floor(gradient *<br>
255)::text || ' 0 0';<br>
<br>
Cheers<br>
<br>
Mtro. Carlos Ruiz<br>
<br>
<br>
<br>
On Monday, June 23, 2014 4:59 PM, "Lime, Steve D<br>
(MNIT)" <<a href="mailto:Steve.Lime@state.mn.us">Steve.Lime@state.mn.us</a>><br>
wrote:<br>
<br>
<br>
<br>
<br>
<br>
You can compute a color<br>
string using PostgreSQL string functions:<br>
<br>
SELECT percentage ||<br>
‘ 0 0’ AS color FROM …<br>
<br>
Steve<br>
<br>
From: <a href="mailto:mapserver-users-bounces@lists.osgeo.org">mapserver-users-bounces@lists.osgeo.org</a><br>
[mailto:<a href="mailto:mapserver-users-bounces@lists.osgeo.org">mapserver-users-bounces@lists.osgeo.org</a>]<br>
On Behalf Of Do Wi<br>
<br>
Sent: Sunday, June 22, 2014 3:50 PM<br>
<br>
To: <a href="mailto:mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a><br>
<br>
Subject: [mapserver-users] color attribute<br>
question<br>
<br>
<br>
hi!<br>
<br>
<br>
<br>
<br>
i have this<br>
scenario:<br>
<br>
<br>
i have a column in my<br>
postgis table which contains a double representing a<br>
percentage.<br>
<br>
<br>
<br>
<br>
<br>
i want to color my<br>
polygons in a gradient fashion based on that<br>
number.<br>
<br>
<br>
<br>
<br>
<br>
the docs states three<br>
ways to specify color:<br>
<br>
<br>
1. three [1-255]<br>
numbers<br>
<br>
<br>
2. hex<br>
string<br>
<br>
<br>
3.<br>
[attribute]<br>
<br>
<br>
<br>
<br>
<br>
but the attribute must<br>
be a string by itself in the same format as options 1 or<br>
2.<br>
<br>
<br>
<br>
<br>
<br>
how can i achieve<br>
something like <br>
<br>
<br>
<br>
<br>
<br>
COLOR [percentage]*255 0<br>
0<br>
<br>
<br>
or<br>
<br>
<br>
COLOR [percentage] 0<br>
0<br>
<br>
<br>
if percentageis already<br>
0..255<br>
<br>
<br>
<br>
<br>
<br>
for a red gradient for<br>
example? <br>
<br>
<br>
<br>
<br>
<br>
thanks<br>
allot!<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
mapserver-users mailing list<br>
<a href="mailto:mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a><br>
<br>
<a href="http://lists.osgeo.org/mailman/listinfo/mapserver-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/mapserver-users</a><br>
</div></div></blockquote></div><br></div>