pggeodb.nancy.inra.fr/db_robot - db_robot on pggeodb.nancy.inra.fr
Previous topic Chapter index Next topic

Function: st_colormap

 

 

Schema

public

 

Owner

albenard

 

Descriptions

There is no description for function st_colormap

 

Options

Option

Value

Returns

public.raster

Language

plpgsql

Parameters

rast public.raster

nband integer = 1

colormap text = 'grayscale'::text

method text = 'INTERPOLATE'::text

 

Definition

CREATE OR REPLACE FUNCTION public.st_colormap (
 rast public.raster,
 nband integer = 1,
 colormap text = 'grayscale'::text,
 method text = 'INTERPOLATE'::text
)
RETURNS public.raster AS
$span$
DECLARE

_ismap boolean;
_colormap text;
_element text[];
BEGIN
_ismap := TRUE;

-- clean colormap to see what it is
_colormap := split_part(colormap, E'\n', 1);
_colormap := regexp_replace(_colormap, E':+', ' ', 'g');
_colormap := regexp_replace(_colormap, E',+', ' ', 'g');
_colormap := regexp_replace(_colormap, E'\\t+', ' ', 'g');
_colormap := regexp_replace(_colormap, E' +', ' ', 'g');
_element := regexp_split_to_array(_colormap, ' ');

-- treat as colormap
IF (array_length(_element, 1) > 1) THEN
_colormap := colormap;
-- treat as keyword
ELSE
method := 'INTERPOLATE';
CASE lower(trim(both from _colormap))
WHEN 'grayscale', 'greyscale' THEN
_colormap := '
100%   0
 0% 254
 nv 255
'
;
WHEN 'pseudocolor' THEN
_colormap := '
100% 255   0   0 255
50%   0 255   0 255
 0%   0   0 255 255
 nv   0   0   0   0
'
;
WHEN 'fire' THEN
_colormap := '
 100% 243 255 221 255
93.75% 242 255 178 255
87.5% 255 255 135 255
81.25% 255 228  96 255
  75% 255 187  53 255
68.75% 255 131   7 255
62.5% 255  84   0 255
56.25% 255  42   0 255
  50% 255   0   0 255
43.75% 255  42   0 255
37.5% 224  74   0 255
31.25% 183  91   0 255
  25% 140  93   0 255
18.75%  99  82   0 255
12.5%  58  58   1 255
6.25%  12  15   0 255
   0%   0   0   0 255
   nv   0   0   0   0
'
;
WHEN 'bluered' THEN
_colormap := '
100.00% 165   0  33 255
94.12% 216  21  47 255
88.24% 247  39  53 255
82.35% 255  61  61 255
76.47% 255 120  86 255
70.59% 255 172 117 255
64.71% 255 214 153 255
58.82% 255 241 188 255
52.94% 255 255 234 255
47.06% 234 255 255 255
41.18% 188 249 255 255
35.29% 153 234 255 255
29.41% 117 211 255 255
23.53%  86 176 255 255
17.65%  61 135 255 255
11.76%  40  87 255 255
 5.88%  24  28 247 255
 0.00%  36   0 216 255
    nv   0   0   0   0
'
;
ELSE
RAISE EXCEPTION
'Unknown colormap keyword: %', colormap;
END CASE;
END IF;

RETURN public._ST_colormap($1, $2, _colormap, $4);
END;
$span$
LANGUAGE
'plpgsql'
IMMUTABLE
RETURNS NULL ON NULL INPUT
SECURITY INVOKER
COST
100;

This file was generated with SQL Manager for PostgreSQL (www.pgsqlmanager.com) at 26/02/2014 11:51
Previous topic Chapter index Next topic