From e0017e29a6322c62e1e6bb25abc2603eb36d3231 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Thu, 19 Jun 2014 11:23:13 +0000 Subject: [PATCH] Add postgis_noop(raster) function git-svn-id: http://svn.osgeo.org/postgis/trunk@12625 b70326c6-7e19-0410-871a-916f4a2858ee --- NEWS | 1 + raster/rt_pg/rtpg_inout.c | 22 ++++++++++++++++++++++ raster/rt_pg/rtpostgis.sql.in | 11 +++++++++++ 3 files changed, 34 insertions(+) diff --git a/NEWS b/NEWS index f6369bb06..7a4380856 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,7 @@ PostGIS 2.2.0 * New Features * + - Add postgis_noop(raster) - Added missing variants of ST_TPI(), ST_TRI() and ST_Roughness() - Added GUC postgis.gdal_enabled_drivers to specify GDAL config variable GDAL_SKIP diff --git a/raster/rt_pg/rtpg_inout.c b/raster/rt_pg/rtpg_inout.c index 720d7ca00..5d4eaa66d 100644 --- a/raster/rt_pg/rtpg_inout.c +++ b/raster/rt_pg/rtpg_inout.c @@ -35,6 +35,7 @@ Datum RASTER_in(PG_FUNCTION_ARGS); Datum RASTER_out(PG_FUNCTION_ARGS); +Datum RASTER_noop(PG_FUNCTION_ARGS); Datum RASTER_to_bytea(PG_FUNCTION_ARGS); Datum RASTER_to_binary(PG_FUNCTION_ARGS); @@ -201,3 +202,24 @@ Datum RASTER_to_binary(PG_FUNCTION_ARGS) PG_RETURN_POINTER(result); } +PG_FUNCTION_INFO_V1(RASTER_noop); +Datum RASTER_noop(PG_FUNCTION_ARGS) +{ + rt_raster raster; + rt_pgraster *pgraster, *result; + pgraster = (rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0)); + raster = rt_raster_deserialize(pgraster, FALSE); + if (!raster) { + PG_FREE_IF_COPY(pgraster, 0); + elog(ERROR, "RASTER_noop: Could not deserialize raster"); + PG_RETURN_NULL(); + } + result = rt_raster_serialize(raster); + rt_raster_destroy(raster); + if (result == NULL) + PG_RETURN_NULL(); + + SET_VARSIZE(result, raster->size); + PG_RETURN_POINTER(result); +} + diff --git a/raster/rt_pg/rtpostgis.sql.in b/raster/rt_pg/rtpostgis.sql.in index 6ea7e6441..a0fa29f8f 100644 --- a/raster/rt_pg/rtpostgis.sql.in +++ b/raster/rt_pg/rtpostgis.sql.in @@ -8552,6 +8552,17 @@ CREATE OR REPLACE FUNCTION UpdateRasterSRID( AS $$ SELECT _UpdateRasterSRID('', $1, $2, $3) $$ LANGUAGE 'sql' VOLATILE STRICT; +------------------------------------------------------------------- +-- Debugging +------------------------------------------------------------------- + +-- Availability: 2.2.0 +CREATE OR REPLACE FUNCTION postgis_noop(raster) + RETURNS geometry + AS 'MODULE_PATHNAME', 'RASTER_noop' + LANGUAGE 'c' VOLATILE STRICT; + + ------------------------------------------------------------------- -- END ------------------------------------------------------------------- -- 2.50.1