Schema
Owner
postgres
Descriptions
args: rast, georefcoords, format=GDAL - Set Georeference 6 georeference parameters in a single call. Numbers should be separated by white space. Accepts inputs in GDAL or ESRI format. Default is GDAL.
Options
Option | Value |
---|---|
Returns |
public.raster |
Language |
|
Parameters |
rast public.raster georef text format text = 'GDAL'::text |
Definition
CREATE OR REPLACE FUNCTION public.st_setgeoreference (
rast public.raster,
georef text,
format text = 'GDAL'::text
)
RETURNS public.raster AS
$span$
DECLARE
params text[];
rastout raster;
BEGIN
IF rast IS NULL THEN
RAISE WARNING 'Cannot set georeferencing on a null raster in st_setgeoreference.';
RETURN rastout;
END IF;
SELECT regexp_matches(georef,
E'(-?\\d+(?:\\.\\d+)?)\\s(-?\\d+(?:\\.\\d+)?)\\s(-?\\d+(?:\\.\\d+)?)\\s' ||
E'(-?\\d+(?:\\.\\d+)?)\\s(-?\\d+(?:\\.\\d+)?)\\s(-?\\d+(?:\\.\\d+)?)') INTO params;
IF NOT FOUND THEN
RAISE EXCEPTION 'st_setgeoreference requires a string with 6 floating point values.';
END IF;
IF format = 'ESRI' THEN
-- params array is now:
-- {scalex, skewy, skewx, scaley, upperleftx, upperlefty}
rastout := st_setscale(rast, params[1]::float8, params[4]::float8);
rastout := st_setskew(rastout, params[3]::float8, params[2]::float8);
rastout := st_setupperleft(rastout,
params[5]::float8 - (params[1]::float8 * 0.5),
params[6]::float8 - (params[4]::float8 * 0.5));
ELSE
IF format != 'GDAL' THEN
RAISE WARNING 'Format ''%'' is not recognized, defaulting to GDAL format.', format;
END IF;
-- params array is now:
-- {scalex, skewy, skewx, scaley, upperleftx, upperlefty}
rastout := st_setscale(rast, params[1]::float8, params[4]::float8);
rastout := st_setskew( rastout, params[3]::float8, params[2]::float8);
rastout := st_setupperleft(rastout, params[5]::float8, params[6]::float8);
END IF;
RETURN rastout;
END;
$span$
LANGUAGE 'plpgsql'
IMMUTABLE
RETURNS NULL ON NULL INPUT
SECURITY INVOKER
COST 100;
COMMENT ON FUNCTION public.st_setgeoreference(rast public.raster, georef text, format text)
IS 'args: rast, georefcoords, format=GDAL - Set Georeference 6 georeference parameters in a single call. Numbers should be separated by white space. Accepts inputs in GDAL or ESRI format. Default is GDAL.';
This file was generated with SQL Manager for PostgreSQL (www.pgsqlmanager.com) at 13/03/2014 13:23 |