From 948642394dfa89dbc24f746ded2bd4675c88107f Mon Sep 17 00:00:00 2001 From: Bborie Park Date: Tue, 22 May 2012 17:06:06 +0000 Subject: [PATCH] Added ST_Raster2WorldCoord and ST_World2RasterCoord functions to consume RASTER_rasterToWorldCoord and RASTER_worldToRasterCoord functions. Refactored existing ST_Raster2WorldCoord(X|Y) and ST_World2RasterCoord(X|Y) functions to call new functions git-svn-id: http://svn.osgeo.org/postgis/trunk@9792 b70326c6-7e19-0410-871a-916f4a2858ee --- raster/rt_pg/rtpostgis.sql.in.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/raster/rt_pg/rtpostgis.sql.in.c b/raster/rt_pg/rtpostgis.sql.in.c index d20336609..0402388d4 100644 --- a/raster/rt_pg/rtpostgis.sql.in.c +++ b/raster/rt_pg/rtpostgis.sql.in.c @@ -2506,6 +2506,21 @@ CREATE OR REPLACE FUNCTION _st_world2rastercoord( AS 'MODULE_PATHNAME', 'RASTER_worldToRasterCoord' LANGUAGE 'c' IMMUTABLE; +--------------------------------------------------------------------------------- +-- ST_World2RasterCoord(rast raster, longitude float8, latitude float8) +-- Returns the pixel column and row covering the provided X and Y world +-- coordinates. +-- This function works even if the world coordinates are outside the raster extent. +--------------------------------------------------------------------------------- +CREATE OR REPLACE FUNCTION st_world2rastercoord( + rast raster, + longitude double precision, latitude double precision, + OUT columnx integer, + OUT rowy integer +) + AS $$ SELECT columnx, rowy FROM _st_world2rastercoord($1, $2, $3) $$ + LANGUAGE 'sql' IMMUTABLE STRICT; + --------------------------------------------------------------------------------- -- ST_World2RasterCoordX(rast raster, xw float8, yw float8) -- Returns the column number of the pixel covering the provided X and Y world @@ -2607,6 +2622,22 @@ CREATE OR REPLACE FUNCTION _st_raster2worldcoord( AS 'MODULE_PATHNAME', 'RASTER_rasterToWorldCoord' LANGUAGE 'c' IMMUTABLE; +--------------------------------------------------------------------------------- +-- ST_Raster2WorldCoordX(rast raster, xr int, yr int) +-- Returns the longitude and latitude of the upper left corner of the pixel +-- located at the provided pixel column and row. +-- This function works even if the provided raster column and row are beyond or +-- below the raster width and height. +--------------------------------------------------------------------------------- +CREATE OR REPLACE FUNCTION st_raster2worldcoord( + rast raster, + columnx integer, rowy integer, + OUT longitude double precision, + OUT latitude double precision +) + AS $$ SELECT longitude, latitude FROM _st_raster2worldcoord($1, $2, $3) $$ + LANGUAGE 'sql' IMMUTABLE STRICT; + --------------------------------------------------------------------------------- -- ST_Raster2WorldCoordX(rast raster, xr int, yr int) -- Returns the X world coordinate of the upper left corner of the pixel located at -- 2.40.0