Schema
Owner
postgres
Descriptions
args: rast, percentwidth, percentheight, algorithm=NearestNeighbor, maxerr=0.125 - Resize a raster to a new width/height
Options
Option | Value |
---|---|
Returns |
public.raster |
Language |
|
Parameters |
rast public.raster percentwidth double precision percentheight double precision algorithm text = 'NearestNeighbour'::text maxerr double precision = 0.125 |
Definition
CREATE OR REPLACE FUNCTION public.st_resize (
rast public.raster,
percentwidth double precision,
percentheight double precision,
algorithm text = 'NearestNeighbour'::text,
maxerr double precision = 0.125
)
RETURNS public.raster AS
$span$
DECLARE
_width integer;
_height integer;
BEGIN
-- range check
IF $2 <= 0. OR $2 > 1. OR $3 <= 0. OR $3 > 1. THEN
RAISE EXCEPTION 'Percentages must be a value greater than zero and less than or equal to one, e.g. 0.5 for 50%%';
END IF;
SELECT width, height INTO _width, _height FROM public.ST_Metadata($1);
_width := round(_width::double precision * $2)::integer;
_height:= round(_height::double precision * $3)::integer;
IF _width < 1 THEN
_width := 1;
END IF;
IF _height < 1 THEN
_height := 1;
END IF;
RETURN public._ST_gdalwarp(
$1,
$4, $5,
NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
_width, _height
);
END;
$span$
LANGUAGE 'plpgsql'
STABLE
RETURNS NULL ON NULL INPUT
SECURITY INVOKER
COST 100;
COMMENT ON FUNCTION public.st_resize(rast public.raster, percentwidth double precision, percentheight double precision, algorithm text, maxerr double precision)
IS 'args: rast, percentwidth, percentheight, algorithm=NearestNeighbor, maxerr=0.125 - Resize a raster to a new width/height';
This file was generated with SQL Manager for PostgreSQL (www.pgsqlmanager.com) at 13/03/2014 13:23 |