[postgis-commits] svn - r3787 - spike/wktraster/rt_pg

postgis-commits at postgis.refractions.net postgis-commits at postgis.refractions.net
Tue Mar 3 08:41:32 PST 2009


Author: mloskot
Date: 2009-03-03 08:41:32 -0800 (Tue, 03 Mar 2009)
New Revision: 3787

Modified:
   spike/wktraster/rt_pg/rt_pg.c
Log:
Fixed RT_Value to accept 1-based X and Y coordinates to conform indexing of bands.

Modified: spike/wktraster/rt_pg/rt_pg.c
===================================================================
--- spike/wktraster/rt_pg/rt_pg.c	2009-03-03 16:20:36 UTC (rev 3786)
+++ spike/wktraster/rt_pg/rt_pg.c	2009-03-03 16:41:32 UTC (rev 3787)
@@ -939,7 +939,9 @@
 }
 
 /**
- * Fetch value of raster sample in specified band.
+ * Return value of a single pixel.
+ * Pixel location is specified by 1-based index of Nth band of raster and
+ * X,Y coordinates (X <= RT_Width(raster) and Y <= RT_Height(raster)).
  *
  * TODO: Should we returen NUMERIC instead of FLOAT8 ?
  */
@@ -980,7 +982,7 @@
         PG_RETURN_NULL();
     }
 
-    /* Fetch requested band */
+    /* Fetch Nth band using 0-based internal index */
     band = rt_raster_get_band(ctx, raster, nband - 1);
     if ( ! band ) {
         /* TODO: Throw rrror or notice or nothing? */
@@ -988,7 +990,8 @@
         PG_RETURN_NULL();
     }
 
-    pixvalue = rt_band_get_pixel(ctx, band, x, y);
+    /* Fetch pixel using 0-based coordiantes */
+    pixvalue = rt_band_get_pixel(ctx, band, x - 1, y - 1);
     PG_RETURN_FLOAT8(pixvalue);
 }
 



More information about the postgis-commits mailing list