From: Bborie Park Date: Sun, 29 Jul 2012 02:34:29 +0000 (+0000) Subject: Removed histogram data type. Ticket is #1939 X-Git-Tag: 2.1.0beta2~732 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1a791c73a62e9931e8a9a6f93290f943d160a186;p=postgis Removed histogram data type. Ticket is #1939 git-svn-id: http://svn.osgeo.org/postgis/trunk@10136 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/doc/reference_raster.xml b/doc/reference_raster.xml index db9f6bd3a..47dee238e 100644 --- a/doc/reference_raster.xml +++ b/doc/reference_raster.xml @@ -142,40 +142,6 @@ VALUES (1, - - - histogram - A composite type used as record output of the ST_Histogram and ST_ApproxHistogram functions. - - - Description - A composite type used as record outputs of the ST_ApproxHistogram functions. Note that depending on exclude_nodata_value of function, may or may not contain nodata pixels. - Each histogram record in results corresponds to a bin for a selected raster band. - - - min double precision - minimum pixel value in this bin - - - max double precision - Maximum pixel value in this bin. - - - count integer - count of pixels in this bin. - - - percent double precision - Percent of pixels of the overall population in this bin. - - - - - See Also - - - - raster @@ -5165,13 +5131,13 @@ rid | exclude_nodata | include_nodata ST_Histogram - Returns a set of histogram summarizing a raster or raster coverage data distribution separate bin ranges. Number of bins are autocomputed if not specified. + Returns a set of record summarizing a raster or raster coverage data distribution separate bin ranges. Number of bins are autocomputed if not specified. - SETOF histogram ST_Histogram + SETOF record ST_Histogram raster rast integer nband=1 boolean exclude_nodata_value=true @@ -5181,7 +5147,7 @@ rid | exclude_nodata | include_nodata - SETOF histogram ST_Histogram + SETOF record ST_Histogram raster rast integer nband integer bins @@ -5190,7 +5156,7 @@ rid | exclude_nodata | include_nodata - SETOF histogram ST_Histogram + SETOF record ST_Histogram raster rast integer nband boolean exclude_nodata_value @@ -5199,7 +5165,7 @@ rid | exclude_nodata | include_nodata - SETOF histogram ST_Histogram + SETOF record ST_Histogram raster rast integer nband integer bins @@ -5207,7 +5173,7 @@ rid | exclude_nodata | include_nodata - SETOF histogram ST_Histogram + SETOF record ST_Histogram text rastertable text rastercolumn integer nband @@ -5216,7 +5182,7 @@ rid | exclude_nodata | include_nodata - SETOF histogram ST_Histogram + SETOF record ST_Histogram text rastertable text rastercolumn integer nband @@ -5226,7 +5192,7 @@ rid | exclude_nodata | include_nodata - SETOF histogram ST_Histogram + SETOF record ST_Histogram text rastertable text rastercolumn integer nband=1 @@ -5237,7 +5203,7 @@ rid | exclude_nodata | include_nodata - SETOF histogram ST_Histogram + SETOF record ST_Histogram text rastertable text rastercolumn integer nband=1 @@ -5251,7 +5217,7 @@ rid | exclude_nodata | include_nodata Description - Returns set of histogram records consisting of min,max, count, percent for a given raster band for each bin. If no band is specified nband defaults to 1. + Returns set of records consisting of min, max, count, percent for a given raster band for each bin. If no band is specified nband defaults to 1. By default only considers pixel values not equal to the nodata value . Set exclude_nodata_value to false to get count all pixels. @@ -5335,7 +5301,10 @@ FROM (SELECT rid, ST_Histogram(rast, 2,6,ARRAY[0.5,1,4,100,5]) As stats See Also - , , + + , + + diff --git a/raster/rt_pg/rtpostgis.sql.in.c b/raster/rt_pg/rtpostgis.sql.in.c index 1d886b004..86911b05a 100644 --- a/raster/rt_pg/rtpostgis.sql.in.c +++ b/raster/rt_pg/rtpostgis.sql.in.c @@ -659,13 +659,6 @@ CREATE OR REPLACE FUNCTION st_approxcount(rastertable text, rastercolumn text, s ----------------------------------------------------------------------- -- ST_Histogram and ST_ApproxHistogram ----------------------------------------------------------------------- -CREATE TYPE histogram AS ( - min double precision, - max double precision, - count bigint, - percent double precision -); - -- Cannot be strict as "width", "min" and "max" can be NULL CREATE OR REPLACE FUNCTION _st_histogram( rast raster, nband int DEFAULT 1, @@ -673,31 +666,69 @@ CREATE OR REPLACE FUNCTION _st_histogram( sample_percent double precision DEFAULT 1, bins int DEFAULT 0, width double precision[] DEFAULT NULL, right boolean DEFAULT FALSE, - min double precision DEFAULT NULL, max double precision DEFAULT NULL + min double precision DEFAULT NULL, max double precision DEFAULT NULL, + OUT min double precision, + OUT max double precision, + OUT count bigint, + OUT percent double precision ) - RETURNS SETOF histogram + RETURNS SETOF record AS 'MODULE_PATHNAME','RASTER_histogram' LANGUAGE 'c' IMMUTABLE; -- Cannot be strict as "width" can be NULL -CREATE OR REPLACE FUNCTION st_histogram(rast raster, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, bins int DEFAULT 0, width double precision[] DEFAULT NULL, right boolean DEFAULT FALSE) - RETURNS SETOF histogram +CREATE OR REPLACE FUNCTION st_histogram( + rast raster, nband int DEFAULT 1, + exclude_nodata_value boolean DEFAULT TRUE, + bins int DEFAULT 0, width double precision[] DEFAULT NULL, + right boolean DEFAULT FALSE, + OUT min double precision, + OUT max double precision, + OUT count bigint, + OUT percent double precision +) + RETURNS SETOF record AS $$ SELECT min, max, count, percent FROM _st_histogram($1, $2, $3, 1, $4, $5, $6) $$ LANGUAGE 'sql' IMMUTABLE; -CREATE OR REPLACE FUNCTION st_histogram(rast raster, nband int, exclude_nodata_value boolean, bins int, right boolean) - RETURNS SETOF histogram +CREATE OR REPLACE FUNCTION st_histogram( + rast raster, nband int, + exclude_nodata_value boolean, + bins int, + right boolean, + OUT min double precision, + OUT max double precision, + OUT count bigint, + OUT percent double precision +) + RETURNS SETOF record AS $$ SELECT min, max, count, percent FROM _st_histogram($1, $2, $3, 1, $4, NULL, $5) $$ LANGUAGE 'sql' IMMUTABLE STRICT; -- Cannot be strict as "width" can be NULL -CREATE OR REPLACE FUNCTION st_histogram(rast raster, nband int, bins int, width double precision[] DEFAULT NULL, right boolean DEFAULT FALSE) - RETURNS SETOF histogram +CREATE OR REPLACE FUNCTION st_histogram( + rast raster, nband int, + bins int, width double precision[] DEFAULT NULL, + right boolean DEFAULT FALSE, + OUT min double precision, + OUT max double precision, + OUT count bigint, + OUT percent double precision +) + RETURNS SETOF record AS $$ SELECT min, max, count, percent FROM _st_histogram($1, $2, TRUE, 1, $3, $4, $5) $$ LANGUAGE 'sql' IMMUTABLE; -CREATE OR REPLACE FUNCTION st_histogram(rast raster, nband int, bins int, right boolean) - RETURNS SETOF histogram +CREATE OR REPLACE FUNCTION st_histogram( + rast raster, nband int, + bins int, + right boolean, + OUT min double precision, + OUT max double precision, + OUT count bigint, + OUT percent double precision +) + RETURNS SETOF record AS $$ SELECT min, max, count, percent FROM _st_histogram($1, $2, TRUE, 1, $3, NULL, $4) $$ LANGUAGE 'sql' IMMUTABLE STRICT; @@ -707,35 +738,80 @@ CREATE OR REPLACE FUNCTION st_approxhistogram( exclude_nodata_value boolean DEFAULT TRUE, sample_percent double precision DEFAULT 0.1, bins int DEFAULT 0, width double precision[] DEFAULT NULL, - right boolean DEFAULT FALSE + right boolean DEFAULT FALSE, + OUT min double precision, + OUT max double precision, + OUT count bigint, + OUT percent double precision ) - RETURNS SETOF histogram + RETURNS SETOF record AS $$ SELECT min, max, count, percent FROM _st_histogram($1, $2, $3, $4, $5, $6, $7) $$ LANGUAGE 'sql' IMMUTABLE; -CREATE OR REPLACE FUNCTION st_approxhistogram(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision, bins int, right boolean) - RETURNS SETOF histogram +CREATE OR REPLACE FUNCTION st_approxhistogram( + rast raster, nband int, + exclude_nodata_value boolean, + sample_percent double precision, + bins int, + right boolean, + OUT min double precision, + OUT max double precision, + OUT count bigint, + OUT percent double precision +) + RETURNS SETOF record AS $$ SELECT min, max, count, percent FROM _st_histogram($1, $2, $3, $4, $5, NULL, $6) $$ LANGUAGE 'sql' IMMUTABLE STRICT; -CREATE OR REPLACE FUNCTION st_approxhistogram(rast raster, nband int, sample_percent double precision) - RETURNS SETOF histogram +CREATE OR REPLACE FUNCTION st_approxhistogram( + rast raster, nband int, + sample_percent double precision, + OUT min double precision, + OUT max double precision, + OUT count bigint, + OUT percent double precision +) + RETURNS SETOF record AS $$ SELECT min, max, count, percent FROM _st_histogram($1, $2, TRUE, $3, 0, NULL, FALSE) $$ LANGUAGE 'sql' IMMUTABLE STRICT; -CREATE OR REPLACE FUNCTION st_approxhistogram(rast raster, sample_percent double precision) - RETURNS SETOF histogram +CREATE OR REPLACE FUNCTION st_approxhistogram( + rast raster, + sample_percent double precision, + OUT min double precision, + OUT max double precision, + OUT count bigint, + OUT percent double precision +) + RETURNS SETOF record AS $$ SELECT min, max, count, percent FROM _st_histogram($1, 1, TRUE, $2, 0, NULL, FALSE) $$ LANGUAGE 'sql' IMMUTABLE STRICT; -- Cannot be strict as "width" can be NULL -CREATE OR REPLACE FUNCTION st_approxhistogram(rast raster, nband int, sample_percent double precision, bins int, width double precision[] DEFAULT NULL, right boolean DEFAULT FALSE) - RETURNS SETOF histogram +CREATE OR REPLACE FUNCTION st_approxhistogram( + rast raster, nband int, + sample_percent double precision, + bins int, width double precision[] DEFAULT NULL, + right boolean DEFAULT FALSE, + OUT min double precision, + OUT max double precision, + OUT count bigint, + OUT percent double precision +) + RETURNS SETOF record AS $$ SELECT min, max, count, percent FROM _st_histogram($1, $2, TRUE, $3, $4, $5, $6) $$ LANGUAGE 'sql' IMMUTABLE STRICT; -CREATE OR REPLACE FUNCTION st_approxhistogram(rast raster, nband int, sample_percent double precision, bins int, right boolean) - RETURNS SETOF histogram +CREATE OR REPLACE FUNCTION st_approxhistogram( + rast raster, nband int, + sample_percent double precision, + bins int, right boolean, + OUT min double precision, + OUT max double precision, + OUT count bigint, + OUT percent double precision +) + RETURNS SETOF record AS $$ SELECT min, max, count, percent FROM _st_histogram($1, $2, TRUE, $3, $4, NULL, $5) $$ LANGUAGE 'sql' IMMUTABLE STRICT; @@ -746,30 +822,68 @@ CREATE OR REPLACE FUNCTION _st_histogram( exclude_nodata_value boolean DEFAULT TRUE, sample_percent double precision DEFAULT 1, bins int DEFAULT 0, width double precision[] DEFAULT NULL, - right boolean DEFAULT FALSE + right boolean DEFAULT FALSE, + OUT min double precision, + OUT max double precision, + OUT count bigint, + OUT percent double precision ) - RETURNS SETOF histogram + RETURNS SETOF record AS 'MODULE_PATHNAME','RASTER_histogramCoverage' LANGUAGE 'c' IMMUTABLE; -CREATE OR REPLACE FUNCTION st_histogram(rastertable text, rastercolumn text, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, bins int DEFAULT 0, width double precision[] DEFAULT NULL, right boolean DEFAULT FALSE) - RETURNS SETOF histogram +CREATE OR REPLACE FUNCTION st_histogram( + rastertable text, rastercolumn text, nband int DEFAULT 1, + exclude_nodata_value boolean DEFAULT TRUE, + bins int DEFAULT 0, width double precision[] DEFAULT NULL, + right boolean DEFAULT FALSE, + OUT min double precision, + OUT max double precision, + OUT count bigint, + OUT percent double precision +) + RETURNS SETOF record AS $$ SELECT _st_histogram($1, $2, $3, $4, 1, $5, $6, $7) $$ LANGUAGE 'sql' STABLE; -CREATE OR REPLACE FUNCTION st_histogram(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean, bins int, right boolean) - RETURNS SETOF histogram +CREATE OR REPLACE FUNCTION st_histogram( + rastertable text, rastercolumn text, nband int, + exclude_nodata_value boolean, + bins int, + right boolean, + OUT min double precision, + OUT max double precision, + OUT count bigint, + OUT percent double precision +) + RETURNS SETOF record AS $$ SELECT _st_histogram($1, $2, $3, $4, 1, $5, NULL, $6) $$ LANGUAGE 'sql' STABLE STRICT; -- Cannot be strict as "width" can be NULL -CREATE OR REPLACE FUNCTION st_histogram(rastertable text, rastercolumn text, nband int, bins int, width double precision[] DEFAULT NULL, right boolean DEFAULT FALSE) - RETURNS SETOF histogram +CREATE OR REPLACE FUNCTION st_histogram( + rastertable text, rastercolumn text, nband int, + bins int, width double precision[] DEFAULT NULL, + right boolean DEFAULT FALSE, + OUT min double precision, + OUT max double precision, + OUT count bigint, + OUT percent double precision +) + RETURNS SETOF record AS $$ SELECT _st_histogram($1, $2, $3, TRUE, 1, $4, $5, $6) $$ LANGUAGE 'sql' STABLE; -CREATE OR REPLACE FUNCTION st_histogram(rastertable text, rastercolumn text, nband int, bins int, right boolean) - RETURNS SETOF histogram +CREATE OR REPLACE FUNCTION st_histogram( + rastertable text, rastercolumn text, nband int, + bins int, + right boolean, + OUT min double precision, + OUT max double precision, + OUT count bigint, + OUT percent double precision +) + RETURNS SETOF record AS $$ SELECT _st_histogram($1, $2, $3, TRUE, 1, $4, NULL, $5) $$ LANGUAGE 'sql' STABLE STRICT; @@ -780,35 +894,81 @@ CREATE OR REPLACE FUNCTION st_approxhistogram( exclude_nodata_value boolean DEFAULT TRUE, sample_percent double precision DEFAULT 0.1, bins int DEFAULT 0, width double precision[] DEFAULT NULL, - right boolean DEFAULT FALSE + right boolean DEFAULT FALSE, + OUT min double precision, + OUT max double precision, + OUT count bigint, + OUT percent double precision ) - RETURNS SETOF histogram + RETURNS SETOF record AS $$ SELECT _st_histogram($1, $2, $3, $4, $5, $6, $7, $8) $$ LANGUAGE 'sql' STABLE; -CREATE OR REPLACE FUNCTION st_approxhistogram(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean, sample_percent double precision, bins int, right boolean) - RETURNS SETOF histogram +CREATE OR REPLACE FUNCTION st_approxhistogram( + rastertable text, rastercolumn text, nband int, + exclude_nodata_value boolean, + sample_percent double precision, + bins int, + right boolean, + OUT min double precision, + OUT max double precision, + OUT count bigint, + OUT percent double precision +) + RETURNS SETOF record AS $$ SELECT _st_histogram($1, $2, $3, $4, $5, $6, NULL, $7) $$ LANGUAGE 'sql' STABLE STRICT; -CREATE OR REPLACE FUNCTION st_approxhistogram(rastertable text, rastercolumn text, nband int, sample_percent double precision) - RETURNS SETOF histogram +CREATE OR REPLACE FUNCTION st_approxhistogram( + rastertable text, rastercolumn text, nband int, + sample_percent double precision, + OUT min double precision, + OUT max double precision, + OUT count bigint, + OUT percent double precision +) + RETURNS SETOF record AS $$ SELECT _st_histogram($1, $2, $3, TRUE, $4, 0, NULL, FALSE) $$ LANGUAGE 'sql' STABLE STRICT; -CREATE OR REPLACE FUNCTION st_approxhistogram(rastertable text, rastercolumn text, sample_percent double precision) - RETURNS SETOF histogram +CREATE OR REPLACE FUNCTION st_approxhistogram( + rastertable text, rastercolumn text, + sample_percent double precision, + OUT min double precision, + OUT max double precision, + OUT count bigint, + OUT percent double precision +) + RETURNS SETOF record AS $$ SELECT _st_histogram($1, $2, 1, TRUE, $3, 0, NULL, FALSE) $$ LANGUAGE 'sql' STABLE STRICT; -- Cannot be strict as "width" can be NULL -CREATE OR REPLACE FUNCTION st_approxhistogram(rastertable text, rastercolumn text, nband int, sample_percent double precision, bins int, width double precision[] DEFAULT NULL, right boolean DEFAULT FALSE) - RETURNS SETOF histogram +CREATE OR REPLACE FUNCTION st_approxhistogram( + rastertable text, rastercolumn text, nband int, + sample_percent double precision, + bins int, width double precision[] DEFAULT NULL, + right boolean DEFAULT FALSE, + OUT min double precision, + OUT max double precision, + OUT count bigint, + OUT percent double precision +) + RETURNS SETOF record AS $$ SELECT _st_histogram($1, $2, $3, TRUE, $4, $5, $6, $7) $$ LANGUAGE 'sql' STABLE STRICT; -CREATE OR REPLACE FUNCTION st_approxhistogram(rastertable text, rastercolumn text, nband int, sample_percent double precision, bins int, right boolean) - RETURNS SETOF histogram +CREATE OR REPLACE FUNCTION st_approxhistogram( + rastertable text, rastercolumn text, nband int, + sample_percent double precision, + bins int, + right boolean, + OUT min double precision, + OUT max double precision, + OUT count bigint, + OUT percent double precision +) + RETURNS SETOF record AS $$ SELECT _st_histogram($1, $2, $3, TRUE, $4, $5, NULL, $6) $$ LANGUAGE 'sql' STABLE STRICT; @@ -1127,6 +1287,7 @@ CREATE OR REPLACE FUNCTION _st_valuecount( OUT count integer, OUT percent double precision ) + RETURNS SETOF record AS 'MODULE_PATHNAME', 'RASTER_valueCount' LANGUAGE 'c' IMMUTABLE; @@ -1213,6 +1374,7 @@ CREATE OR REPLACE FUNCTION _st_valuecount( OUT count integer, OUT percent double precision ) + RETURNS SETOF record AS 'MODULE_PATHNAME', 'RASTER_valueCountCoverage' LANGUAGE 'c' STABLE; diff --git a/raster/rt_pg/rtpostgis_drop.sql.in.c b/raster/rt_pg/rtpostgis_drop.sql.in.c index 1a17b55a0..94ed9ddd9 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 histogram; DROP TYPE IF EXISTS quantile; DROP TYPE IF EXISTS valuecount;