From 5834bd0117f125d3c99059d44f6e2441f38827f3 Mon Sep 17 00:00:00 2001 From: Bborie Park Date: Sun, 29 Jul 2012 02:34:16 +0000 Subject: [PATCH] Removed quantile data type. Ticket is #1939 git-svn-id: http://svn.osgeo.org/postgis/trunk@10134 b70326c6-7e19-0410-871a-916f4a2858ee --- doc/reference_raster.xml | 10 +- raster/rt_pg/rtpostgis.sql.in.c | 181 +++++++++++++++++++++------ raster/rt_pg/rtpostgis_drop.sql.in.c | 1 + 3 files changed, 150 insertions(+), 42 deletions(-) diff --git a/doc/reference_raster.xml b/doc/reference_raster.xml index d388c8433..db9f6bd3a 100644 --- a/doc/reference_raster.xml +++ b/doc/reference_raster.xml @@ -5348,19 +5348,19 @@ FROM (SELECT rid, ST_Histogram(rast, 2,6,ARRAY[0.5,1,4,100,5]) As stats - SETOF quantile ST_Quantile + SETOF record ST_Quantile raster rast integer nband=1 boolean exclude_nodata_value=true double precision[] quantiles=NULL - SETOF quantile ST_Quantile + SETOF record ST_Quantile raster rast double precision[] quantiles - SETOF quantile ST_Quantile + SETOF record ST_Quantile raster rast integer nband double precision[] quantiles @@ -5398,7 +5398,7 @@ FROM (SELECT rid, ST_Histogram(rast, 2,6,ARRAY[0.5,1,4,100,5]) As stats - setof quantile ST_Quantile + SETOF record ST_Quantile text rastertable text rastercolumn integer nband=1 @@ -5406,7 +5406,7 @@ FROM (SELECT rid, ST_Histogram(rast, 2,6,ARRAY[0.5,1,4,100,5]) As stats double precision[] quantiles=NULL - setof quantile ST_Quantile + SETOF record ST_Quantile text rastertable text rastercolumn integer nband diff --git a/raster/rt_pg/rtpostgis.sql.in.c b/raster/rt_pg/rtpostgis.sql.in.c index 36449bd63..2c43a95d3 100644 --- a/raster/rt_pg/rtpostgis.sql.in.c +++ b/raster/rt_pg/rtpostgis.sql.in.c @@ -815,30 +815,51 @@ CREATE OR REPLACE FUNCTION st_approxhistogram(rastertable text, rastercolumn tex ----------------------------------------------------------------------- -- ST_Quantile and ST_ApproxQuantile ----------------------------------------------------------------------- -CREATE TYPE quantile AS ( - quantile double precision, - value double precision -); - -- Cannot be strict as "quantiles" can be NULL -CREATE OR REPLACE FUNCTION _st_quantile(rast raster, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, sample_percent double precision DEFAULT 1, quantiles double precision[] DEFAULT NULL) - RETURNS SETOF quantile +CREATE OR REPLACE FUNCTION _st_quantile( + rast raster, + nband int DEFAULT 1, + exclude_nodata_value boolean DEFAULT TRUE, + sample_percent double precision DEFAULT 1, + quantiles double precision[] DEFAULT NULL, + OUT quantile double precision, + OUT value double precision +) + RETURNS SETOF record AS 'MODULE_PATHNAME','RASTER_quantile' LANGUAGE 'c' IMMUTABLE; -- Cannot be strict as "quantiles" can be NULL -CREATE OR REPLACE FUNCTION st_quantile(rast raster, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, quantiles double precision[] DEFAULT NULL) - RETURNS SETOF quantile +CREATE OR REPLACE FUNCTION st_quantile( + rast raster, + nband int DEFAULT 1, + exclude_nodata_value boolean DEFAULT TRUE, + quantiles double precision[] DEFAULT NULL, + OUT quantile double precision, + OUT value double precision +) + RETURNS SETOF record AS $$ SELECT _st_quantile($1, $2, $3, 1, $4) $$ LANGUAGE 'sql' IMMUTABLE; -CREATE OR REPLACE FUNCTION st_quantile(rast raster, nband int, quantiles double precision[]) - RETURNS SETOF quantile +CREATE OR REPLACE FUNCTION st_quantile( + rast raster, + nband int, + quantiles double precision[], + OUT quantile double precision, + OUT value double precision +) + RETURNS SETOF record AS $$ SELECT _st_quantile($1, $2, TRUE, 1, $3) $$ LANGUAGE 'sql' IMMUTABLE STRICT; -CREATE OR REPLACE FUNCTION st_quantile(rast raster, quantiles double precision[]) - RETURNS SETOF quantile +CREATE OR REPLACE FUNCTION st_quantile( + rast raster, + quantiles double precision[], + OUT quantile double precision, + OUT value double precision +) + RETURNS SETOF record AS $$ SELECT _st_quantile($1, 1, TRUE, 1, $2) $$ LANGUAGE 'sql' IMMUTABLE STRICT; @@ -864,25 +885,51 @@ CREATE OR REPLACE FUNCTION st_quantile(rast raster, quantile double precision) LANGUAGE 'sql' IMMUTABLE STRICT; -- Cannot be strict as "quantiles" can be NULL -CREATE OR REPLACE FUNCTION st_approxquantile(rast raster, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, sample_percent double precision DEFAULT 0.1, quantiles double precision[] DEFAULT NULL) - RETURNS SETOF quantile +CREATE OR REPLACE FUNCTION st_approxquantile( + rast raster, + nband int DEFAULT 1, + exclude_nodata_value boolean DEFAULT TRUE, + sample_percent double precision DEFAULT 0.1, + quantiles double precision[] DEFAULT NULL, + OUT quantile double precision, + OUT value double precision +) + RETURNS SETOF record AS $$ SELECT _st_quantile($1, $2, $3, $4, $5) $$ LANGUAGE 'sql' IMMUTABLE; -- Cannot be strict as "quantiles" can be NULL -CREATE OR REPLACE FUNCTION st_approxquantile(rast raster, nband int, sample_percent double precision, quantiles double precision[] DEFAULT NULL) - RETURNS SETOF quantile +CREATE OR REPLACE FUNCTION st_approxquantile( + rast raster, + nband int, + sample_percent double precision, + quantiles double precision[] DEFAULT NULL, + OUT quantile double precision, + OUT value double precision +) + RETURNS SETOF record AS $$ SELECT _st_quantile($1, $2, TRUE, $3, $4) $$ LANGUAGE 'sql' IMMUTABLE; -- Cannot be strict as "quantiles" can be NULL -CREATE OR REPLACE FUNCTION st_approxquantile(rast raster, sample_percent double precision, quantiles double precision[] DEFAULT NULL) - RETURNS SETOF quantile +CREATE OR REPLACE FUNCTION st_approxquantile( + rast raster, + sample_percent double precision, + quantiles double precision[] DEFAULT NULL, + OUT quantile double precision, + OUT value double precision +) + RETURNS SETOF record AS $$ SELECT _st_quantile($1, 1, TRUE, $2, $3) $$ LANGUAGE 'sql' IMMUTABLE; -CREATE OR REPLACE FUNCTION st_approxquantile(rast raster, quantiles double precision[]) - RETURNS SETOF quantile +CREATE OR REPLACE FUNCTION st_approxquantile( + rast raster, + quantiles double precision[], + OUT quantile double precision, + OUT value double precision +) + RETURNS SETOF record AS $$ SELECT _st_quantile($1, 1, TRUE, 0.1, $2) $$ LANGUAGE 'sql' IMMUTABLE STRICT; @@ -913,24 +960,54 @@ CREATE OR REPLACE FUNCTION st_approxquantile(rast raster, quantile double precis LANGUAGE 'sql' IMMUTABLE; -- Cannot be strict as "quantiles" can be NULL -CREATE OR REPLACE FUNCTION _st_quantile(rastertable text, rastercolumn text, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, sample_percent double precision DEFAULT 1, quantiles double precision[] DEFAULT NULL) - RETURNS SETOF quantile +CREATE OR REPLACE FUNCTION _st_quantile( + rastertable text, + rastercolumn text, + nband int DEFAULT 1, + exclude_nodata_value boolean DEFAULT TRUE, + sample_percent double precision DEFAULT 1, + quantiles double precision[] DEFAULT NULL, + OUT quantile double precision, + OUT value double precision +) + RETURNS SETOF record AS 'MODULE_PATHNAME','RASTER_quantileCoverage' LANGUAGE 'c' STABLE; -- Cannot be strict as "quantiles" can be NULL -CREATE OR REPLACE FUNCTION st_quantile(rastertable text, rastercolumn text, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, quantiles double precision[] DEFAULT NULL) - RETURNS SETOF quantile +CREATE OR REPLACE FUNCTION st_quantile( + rastertable text, + rastercolumn text, + nband int DEFAULT 1, + exclude_nodata_value boolean DEFAULT TRUE, + quantiles double precision[] DEFAULT NULL, + OUT quantile double precision, + OUT value double precision +) + RETURNS SETOF record AS $$ SELECT _st_quantile($1, $2, $3, $4, 1, $5) $$ LANGUAGE 'sql' STABLE; -CREATE OR REPLACE FUNCTION st_quantile(rastertable text, rastercolumn text, nband int, quantiles double precision[]) - RETURNS SETOF quantile +CREATE OR REPLACE FUNCTION st_quantile( + rastertable text, + rastercolumn text, + nband int, + quantiles double precision[], + OUT quantile double precision, + OUT value double precision +) + RETURNS SETOF record AS $$ SELECT _st_quantile($1, $2, $3, TRUE, 1, $4) $$ LANGUAGE 'sql' STABLE STRICT; -CREATE OR REPLACE FUNCTION st_quantile(rastertable text, rastercolumn text, quantiles double precision[]) - RETURNS SETOF quantile +CREATE OR REPLACE FUNCTION st_quantile( + rastertable text, + rastercolumn text, + quantiles double precision[], + OUT quantile double precision, + OUT value double precision +) + RETURNS SETOF record AS $$ SELECT _st_quantile($1, $2, 1, TRUE, 1, $3) $$ LANGUAGE 'sql' STABLE STRICT; @@ -956,25 +1033,55 @@ CREATE OR REPLACE FUNCTION st_quantile(rastertable text, rastercolumn text, quan LANGUAGE 'sql' STABLE STRICT; -- Cannot be strict as "quantiles" can be NULL -CREATE OR REPLACE FUNCTION st_approxquantile(rastertable text, rastercolumn text, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, sample_percent double precision DEFAULT 0.1, quantiles double precision[] DEFAULT NULL) - RETURNS SETOF quantile +CREATE OR REPLACE FUNCTION st_approxquantile( + rastertable text, + rastercolumn text, + nband int DEFAULT 1, + exclude_nodata_value boolean DEFAULT TRUE, + sample_percent double precision DEFAULT 0.1, + quantiles double precision[] DEFAULT NULL, + OUT quantile double precision, + OUT value double precision +) + RETURNS SETOF record AS $$ SELECT _st_quantile($1, $2, $3, $4, $5, $6) $$ LANGUAGE 'sql' STABLE; -- Cannot be strict as "quantiles" can be NULL -CREATE OR REPLACE FUNCTION st_approxquantile(rastertable text, rastercolumn text, nband int, sample_percent double precision, quantiles double precision[] DEFAULT NULL) - RETURNS SETOF quantile +CREATE OR REPLACE FUNCTION st_approxquantile( + rastertable text, + rastercolumn text, + nband int, + sample_percent double precision, + quantiles double precision[] DEFAULT NULL, + OUT quantile double precision, + OUT value double precision +) + RETURNS SETOF record AS $$ SELECT _st_quantile($1, $2, $3, TRUE, $4, $5) $$ LANGUAGE 'sql' STABLE; -- Cannot be strict as "quantiles" can be NULL -CREATE OR REPLACE FUNCTION st_approxquantile(rastertable text, rastercolumn text, sample_percent double precision, quantiles double precision[] DEFAULT NULL) - RETURNS SETOF quantile +CREATE OR REPLACE FUNCTION st_approxquantile( + rastertable text, + rastercolumn text, + sample_percent double precision, + quantiles double precision[] DEFAULT NULL, + OUT quantile double precision, + OUT value double precision +) + RETURNS SETOF record AS $$ SELECT _st_quantile($1, $2, 1, TRUE, $3, $4) $$ LANGUAGE 'sql' STABLE; -CREATE OR REPLACE FUNCTION st_approxquantile(rastertable text, rastercolumn text, quantiles double precision[]) - RETURNS SETOF quantile +CREATE OR REPLACE FUNCTION st_approxquantile( + rastertable text, + rastercolumn text, + quantiles double precision[], + OUT quantile double precision, + OUT value double precision +) + RETURNS SETOF record AS $$ SELECT _st_quantile($1, $2, 1, TRUE, 0.1, $3) $$ LANGUAGE 'sql' STABLE STRICT; diff --git a/raster/rt_pg/rtpostgis_drop.sql.in.c b/raster/rt_pg/rtpostgis_drop.sql.in.c index 25ee00108..ea3eab4f8 100644 --- a/raster/rt_pg/rtpostgis_drop.sql.in.c +++ b/raster/rt_pg/rtpostgis_drop.sql.in.c @@ -213,6 +213,7 @@ DROP FUNCTION IF EXISTS ST_PixelAsPolygons(raster,integer); DROP TYPE IF EXISTS bandmetadata; DROP TYPE IF EXISTS geomvalxy; DROP TYPE IF EXISTS summarystats; +DROP TYPE IF EXISTS quantile; -- raster_columns and raster_overviews tables are deprecated DROP FUNCTION IF EXISTS _rename_raster_tables(); -- 2.50.1