From: Bborie Park Date: Tue, 22 May 2012 17:06:06 +0000 (+0000) Subject: Added ST_Raster2WorldCoord and ST_World2RasterCoord functions to consume X-Git-Tag: 2.1.0beta2~991 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=948642394dfa89dbc24f746ded2bd4675c88107f;p=postgis 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 --- 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