Commit f2705864 authored by Bborie Park's avatar Bborie Park

Refactored expression variant of ST_MapAlgebra() to be faster.

Performance is almost as good as ST_MapAlgebraExpr(). Ticket #2133

git-svn-id: http://svn.osgeo.org/postgis/trunk@11222 b70326c6-7e19-0410-871a-916f4a2858ee
parent 7459bb81
This diff is collapsed.
......@@ -2707,9 +2707,63 @@ CREATE OR REPLACE FUNCTION st_mapalgebra(
LANGUAGE 'sql' STABLE;
-----------------------------------------------------------------------
-- n-Raster ST_MapAlgebra with expressions
-- 1 or 2-Raster ST_MapAlgebra with expressions
-----------------------------------------------------------------------
CREATE OR REPLACE FUNCTION _st_mapalgebra(
rastbandargset rastbandarg[],
expression text,
pixeltype text DEFAULT NULL, extenttype text DEFAULT 'INTERSECTION',
nodata1expr text DEFAULT NULL, nodata2expr text DEFAULT NULL,
nodatanodataval double precision DEFAULT NULL
)
RETURNS raster
AS 'MODULE_PATHNAME', 'RASTER_nMapAlgebraExpr'
LANGUAGE 'c' STABLE;
CREATE OR REPLACE FUNCTION st_mapalgebra(
rast raster, nband integer,
pixeltype text,
expression text, nodataval double precision DEFAULT NULL
)
RETURNS raster
AS $$ SELECT _st_mapalgebra(ARRAY[ROW($1, $2)]::rastbandarg[], $4, $3, 'FIRST', $5::text) $$
LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_mapalgebra(
rast raster,
pixeltype text,
expression text, nodataval double precision DEFAULT NULL
)
RETURNS raster
AS $$ SELECT st_mapalgebra($1, 1, $2, $3, $4) $$
LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_mapalgebra(
rast1 raster, band1 integer,
rast2 raster, band2 integer,
expression text,
pixeltype text DEFAULT NULL, extenttype text DEFAULT 'INTERSECTION',
nodata1expr text DEFAULT NULL, nodata2expr text DEFAULT NULL,
nodatanodataval double precision DEFAULT NULL
)
RETURNS raster
AS $$ SELECT _st_mapalgebra(ARRAY[ROW($1, $2), ROW($3, $4)]::rastbandarg[], $5, $6, $7, $8, $9, $10) $$
LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_mapalgebra(
rast1 raster,
rast2 raster,
expression text,
pixeltype text DEFAULT NULL, extenttype text DEFAULT 'INTERSECTION',
nodata1expr text DEFAULT NULL, nodata2expr text DEFAULT NULL,
nodatanodataval double precision DEFAULT NULL
)
RETURNS raster
AS $$ SELECT st_mapalgebra($1, 1, $2, 1, $3, $4, $5, $6, $7, $8) $$
LANGUAGE 'sql' STABLE;
/*
CREATE OR REPLACE FUNCTION st_mapalgebra(
rast raster, nband integer,
pixeltype text,
......@@ -2928,6 +2982,7 @@ CREATE OR REPLACE FUNCTION st_mapalgebra(
RETURNS raster
AS $$ SELECT st_mapalgebra($1, 1, $2, 1, $3, $4, $5, $6, $7, $8) $$
LANGUAGE 'sql' VOLATILE;
*/
-----------------------------------------------------------------------
-- ST_MapAlgebra callback functions
......
......@@ -6,16 +6,16 @@ T4||2
T5||2
T6||-1
T7|100|15
ERROR: RASTER_nMapAlgebra: Invalid pixel type: 4BUId
ERROR: RASTER_nMapAlgebraExpr: Invalid pixel type: 4BUId
T9|101|3
T10.6.2|10|40
T10.6.3|10|30
T10.6.4|10|25
T10.7.2|10|45
T10.7.3|10|33
T10.7.4|10|27
T10.7.3|10|34
T10.7.4|10|28
T10.8.2|10|50
T10.8.3|10|36
T10.8.3|10|37
T10.8.4|10|30
ERROR: division by zero
T11.1|10|2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment