Schema
Owner
postgres
Descriptions
There is no description for function st_mean4ma
Options
Option | Value |
---|---|
Returns |
double precision |
Language |
|
Parameters |
value double precision [] pos integer [] variadic userargs text [] = NULL::text[] |
Definition
CREATE OR REPLACE FUNCTION public.st_mean4ma (
value double precision [],
pos integer [],
variadic userargs text [] = NULL::text[]
)
RETURNS double precision AS
$span$
DECLARE
_value double precision[][][];
sum double precision;
count int;
x int;
y int;
z int;
ndims int;
BEGIN
sum := 0;
count := 0;
ndims := array_ndims(value);
-- add a third dimension if 2-dimension
IF ndims = 2 THEN
_value := _st_convertarray4ma(value);
ELSEIF ndims != 3 THEN
RAISE EXCEPTION 'First parameter of function must be a 3-dimension array';
ELSE
_value := value;
END IF;
-- raster
FOR z IN array_lower(_value, 1)..array_upper(_value, 1) LOOP
-- row
FOR y IN array_lower(_value, 2)..array_upper(_value, 2) LOOP
-- column
FOR x IN array_lower(_value, 3)..array_upper(_value, 3) LOOP
IF _value[z][y][x] IS NULL THEN
IF array_length(userargs, 1) > 0 THEN
_value[z][y][x] = userargs[array_lower(userargs, 1)]::double precision;
ELSE
CONTINUE;
END IF;
END IF;
sum := sum + _value[z][y][x];
count := count + 1;
END LOOP;
END LOOP;
END LOOP;
IF count < 1 THEN
RETURN NULL;
END IF;
RETURN sum / count::double precision;
END;
$span$
LANGUAGE 'plpgsql'
IMMUTABLE
CALLED ON NULL INPUT
SECURITY INVOKER
COST 100;
This file was generated with SQL Manager for PostgreSQL (www.pgsqlmanager.com) at 13/03/2014 13:23 |