[postgis-tickets] r16205 - stubs
Bborie Park
dustymugs at dspiral.net
Mon Jan 1 05:02:23 PST 2018
Author: dustymugs
Date: 2018-01-01 17:02:23 -0800 (Mon, 01 Jan 2018)
New Revision: 16205
Modified:
trunk/raster/rt_pg/rtpostgis.sql.in
Log:
stubs
Modified: trunk/raster/rt_pg/rtpostgis.sql.in
===================================================================
--- trunk/raster/rt_pg/rtpostgis.sql.in 2018-01-01 19:58:34 UTC (rev 16204)
+++ trunk/raster/rt_pg/rtpostgis.sql.in 2018-01-02 01:02:23 UTC (rev 16205)
@@ -10,9 +10,9 @@
-- Copyright (c) 2009-2010 Jorge Arevalo <jorge.arevalo at deimos-space.com>
-- Copyright (c) 2009-2010 Mateusz Loskot <mateusz at loskot.net>
-- Copyright (c) 2010 David Zwarg <dzwarg at azavea.com>
--- Copyright (C) 2011-2013 Regents of the University of California
+-- Copyright (c) 2011-2013 Regents of the University of California
-- <bkpark at ucdavis.edu>
--- Copyright (C) 2013 Bborie Park <dustymugs at gmail.com>
+-- Copyright (c) 2013-2017 Bborie Park <dustymugs at gmail.com>
--
-- This program is free software; you can redistribute it and/or
-- modify it under the terms of the GNU General Public License
@@ -3918,7 +3918,7 @@
IF interpolate_nodata IS TRUE THEN
_rast := @extschema at .ST_MapAlgebra(
ARRAY[ROW(rast, nband)]::rastbandarg[],
- 'st_invdistweight4ma(double precision[][][], integer[][], text[])'::regprocedure,
+ '@extschema at .st_invdistweight4ma(double precision[][][], integer[][], text[])'::regprocedure,
pixeltype,
'FIRST', NULL,
1, 1
@@ -4099,7 +4099,7 @@
IF interpolate_nodata IS TRUE THEN
_rast := @extschema at .ST_MapAlgebra(
ARRAY[ROW(rast, nband)]::rastbandarg[],
- 'st_invdistweight4ma(double precision[][][], integer[][], text[])'::regprocedure,
+ '@extschema at .st_invdistweight4ma(double precision[][][], integer[][], text[])'::regprocedure,
pixeltype,
'FIRST', NULL,
1, 1
@@ -4307,7 +4307,7 @@
IF interpolate_nodata IS TRUE THEN
_rast := @extschema at .ST_MapAlgebra(
ARRAY[ROW(rast, nband)]::rastbandarg[],
- 'st_invdistweight4ma(double precision[][][], integer[][], text[])'::regprocedure,
+ '@extschema at .st_invdistweight4ma(double precision[][][], integer[][], text[])'::regprocedure,
pixeltype,
'FIRST', NULL,
1, 1
@@ -4467,7 +4467,7 @@
IF interpolate_nodata IS TRUE THEN
_rast := @extschema at .ST_MapAlgebra(
ARRAY[ROW(rast, nband)]::rastbandarg[],
- 'st_invdistweight4ma(double precision[][][], integer[][], text[])'::regprocedure,
+ '@extschema at .st_invdistweight4ma(double precision[][][], integer[][], text[])'::regprocedure,
pixeltype,
'FIRST', NULL,
1, 1
@@ -4603,7 +4603,7 @@
IF interpolate_nodata IS TRUE THEN
_rast := @extschema at .ST_MapAlgebra(
ARRAY[ROW(rast, nband)]::rastbandarg[],
- 'st_invdistweight4ma(double precision[][][], integer[][], text[])'::regprocedure,
+ '@extschema at .st_invdistweight4ma(double precision[][][], integer[][], text[])'::regprocedure,
pixeltype,
'FIRST', NULL,
1, 1
@@ -4749,7 +4749,7 @@
IF interpolate_nodata IS TRUE THEN
_rast := @extschema at .ST_MapAlgebra(
ARRAY[ROW(rast, nband)]::rastbandarg[],
- 'st_invdistweight4ma(double precision[][][], integer[][], text[])'::regprocedure,
+ '@extschema at .st_invdistweight4ma(double precision[][][], integer[][], text[])'::regprocedure,
pixeltype,
'FIRST', NULL,
1, 1
@@ -4785,6 +4785,63 @@
LANGUAGE 'sql' IMMUTABLE _PARALLEL;
-----------------------------------------------------------------------
+-- ST_Grayscale
+-----------------------------------------------------------------------
+
+-- Availability: 2.5.0
+CREATE OR REPLACE FUNCTION _st_grayscale4ma(value double precision[][][], pos integer[][], VARIADIC userargs text[] DEFAULT NULL)
+ RETURNS double precision
+ AS $$
+ DECLARE
+ ndims integer;
+ _value double precision[][][];
+
+ red double precision;
+ green double precision;
+ blue double precision;
+ BEGIN
+
+ RAISE NOTICE 'value = %', value;
+ ndims := array_ndims(value);
+ -- add a third dimension if 2-dimension
+ IF ndims = 2 THEN
+ _value := @extschema at ._ST_convertarray4ma(value);
+ ELSEIF ndims != 3 THEN
+ RAISE EXCEPTION 'First parameter of function must be a 3-dimension array';
+ ELSE
+ _value := value;
+ END IF;
+
+ red := _value[1][1][1];
+ green := _value[2][1][1];
+ blue := _value[3][1][1];
+
+ RETURN 0.2989 * red + 0.5870 * green + 0.1140 * blue;
+ END;
+ $$ LANGUAGE 'plpgsql' IMMUTABLE _PARALLEL;
+
+-- Availability: 2.5.0
+CREATE OR REPLACE FUNCTION st_grayscale(rast raster, redband integer DEFAULT 1, blueband DEFAULT 2, greenband DEFAULT 3)
+ RETURNS RASTER
+ AS $$
+ DECLARE
+ BEGIN
+
+ -- check that each band index is found in raster
+
+ -- check that each band is 8BUI. if not, reclassify to 8BUI
+
+ -- call map algebra with _st_grayscale4ma
+ RETURN @extschema at .ST_MapAlgebra(
+ rast,
+ ARRAY[redband, blueband, greenband],
+ '@extschema at ._ST_Grayscale4MA(double precision[][][], integer[][], text[])'::regprocedure,,
+ '8BUI'
+ );
+ END;
+ $$ LANGUAGE 'plpgsql' IMMUTABLE _PARALLEL;
+
+-----------------------------------------------------------------------
-- Get information about the raster
-----------------------------------------------------------------------
CREATE OR REPLACE FUNCTION st_isempty(rast raster)
More information about the postgis-tickets
mailing list