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

Function: st_sum4ma

 

 

Schema

public

 

Owner

albenard

 

Descriptions

There is no description for function st_sum4ma

 

Options

Option

Value

Returns

double precision

Language

plpgsql

Parameters

value double precision []

pos integer []

variadic userargs text [] = NULL::text[]

 

Definition

CREATE OR REPLACE FUNCTION public.st_sum4ma (
 value double precision [],
 pos integer [],
 variadic userargs text [] = NULL::text[]
)
RETURNS double precision AS
$span$
DECLARE

_value double precision[][][];
sum double precision;
x int;
y int;
z int;
ndims int;
BEGIN
sum := 0;

ndims := array_ndims(value);
-- add a third dimension if 2-dimension
IF ndims = 2 THEN
_value := public._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];
END LOOP;
END LOOP;
END LOOP;

RETURN sum;
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 26/02/2014 11:51
Previous topic Chapter index Next topic