[mapserver-users] color attribute question
Do Wi
dowi84 at gmail.com
Thu Jun 26 08:29:27 PDT 2014
hi, thanks allot!
that is exactly what i did after another user suggested it ( Cristiano
Sumariva ).
here it is for reference:
CREATE OR REPLACE FUNCTION temp.ms_colorMath( percentile double precision )
RETURNS varchar
LANGUAGE plpgsql
AS
$$
DECLARE
C double precision;
X double precision;
m double precision;
H int;
V double precision;
S double precision;
R int;
G int;
B int;
BEGIN
--see here http://www.rapidtables.com/convert/color/hsv-to-rgb.htm
--if H != 0 need to change the function
--curently - red gradient
S := percentile;
IF (S < 0.1 AND S > 0) THEN S := 0.1; END IF;
H := 0;
V := 1.0;
C := V * S;
X := C * (1-abs(mod(H/60,2)-1));
m := V-C;
R := ((C + m)*255 )::int;
G := ((X + m)*255 )::int;
B := ((0 + m)*255 )::int;
RETURN (R)::text || ' ' || (G)::text || ' ' || (B)::text;
END
$$;
On Thu, Jun 26, 2014 at 6:24 PM, Carlos Ruiz <boolean10001 at yahoo.com> wrote:
> 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.
>
>
> Cheers
>
> Mtro. Carlos Ruiz
>
> --------------------------------------------
> On Mon, 6/23/14, Do Wi <dowi84 at gmail.com> wrote:
>
> Subject: Re: [mapserver-users] color attribute question
> To: "Carlos Ruiz" <boolean10001 at yahoo.com>
> Date: Monday, June 23, 2014, 2:56 PM
>
> thanks allot!
> Steve and another user here mentioned this path
> and it did work!only problem is that it cannot be
> changed later if for example the user chooses a blue
> gradient.
>
> how will i go about doing it with
> mapscript?
> maybe it relates to my question herehttp://
> gis.stackexchange.com/questions/102862/when-to-choose-mapscript-over-mapfile-or-vice-versa
>
>
> :-)
> thanks allot!dovi
>
> On Mon, Jun 23, 2014
> at 6:13 PM, Carlos Ruiz <boolean10001 at yahoo.com>
> wrote:
>
>
> Do,
> If
> you want to do this without using mapscript, you can pull
> the gradient calculation as an attribute from your data
> table.
>
>
> ALTER TABLE mytable ADD COLUMN gradient_color
> VARCHAR;
> UPTATE mytable SET gradient_color = floor(gradient *
> 255)::text || ' 0 0';
>
> Cheers
>
> Mtro. Carlos Ruiz
>
>
>
> On Monday, June 23, 2014 4:59 PM, "Lime, Steve D
> (MNIT)" <Steve.Lime at state.mn.us>
> wrote:
>
>
>
>
>
> You can compute a color
> string using PostgreSQL string functions:
>
> SELECT percentage ||
> ‘ 0 0’ AS color FROM …
>
> Steve
>
> From: mapserver-users-bounces at lists.osgeo.org
> [mailto:mapserver-users-bounces at lists.osgeo.org]
> On Behalf Of Do Wi
>
> Sent: Sunday, June 22, 2014 3:50 PM
>
> To: mapserver-users at lists.osgeo.org
>
> Subject: [mapserver-users] color attribute
> question
>
>
> hi!
>
>
>
>
> i have this
> scenario:
>
>
> i have a column in my
> postgis table which contains a double representing a
> percentage.
>
>
>
>
>
> i want to color my
> polygons in a gradient fashion based on that
> number.
>
>
>
>
>
> the docs states three
> ways to specify color:
>
>
> 1. three [1-255]
> numbers
>
>
> 2. hex
> string
>
>
> 3.
> [attribute]
>
>
>
>
>
> but the attribute must
> be a string by itself in the same format as options 1 or
> 2.
>
>
>
>
>
> how can i achieve
> something like
>
>
>
>
>
> COLOR [percentage]*255 0
> 0
>
>
> or
>
>
> COLOR [percentage] 0
> 0
>
>
> if percentageis already
> 0..255
>
>
>
>
>
> for a red gradient for
> example?
>
>
>
>
>
> thanks
> allot!
>
>
>
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
>
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20140626/91d6697e/attachment.htm>
More information about the MapServer-users
mailing list