]> granicus.if.org Git - postgis/commitdiff
Added ST_Raster2WorldCoord and ST_World2RasterCoord functions to consume
authorBborie Park <bkpark at ucdavis.edu>
Tue, 22 May 2012 17:06:06 +0000 (17:06 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Tue, 22 May 2012 17:06:06 +0000 (17:06 +0000)
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

index d2033660962f4a940e699a25a2f71aa3e4469a30..0402388d49d4f08782b2052f104be7e77a7471d6 100644 (file)
@@ -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