From f77975da4f8e55f8fca57b92bfa142827d2be8c8 Mon Sep 17 00:00:00 2001
From: Bborie Park <bkpark at ucdavis.edu>
Date: Mon, 21 Nov 2011 19:55:54 +0000
Subject: [PATCH] Fixed behavior of one raster not having specified band and
 being sampled.

Associated ticket is #1316.


git-svn-id: http://svn.osgeo.org/postgis/trunk@8216 b70326c6-7e19-0410-871a-916f4a2858ee
---
 raster/rt_pg/rt_pg.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/raster/rt_pg/rt_pg.c b/raster/rt_pg/rt_pg.c
index ffa59ca9c..9263718e2 100644
--- a/raster/rt_pg/rt_pg.c
+++ b/raster/rt_pg/rt_pg.c
@@ -8673,7 +8673,13 @@ Datum RASTER_mapAlgebra2(PG_FUNCTION_ARGS)
 					_y = y - (int) _rastoffset[i][1];
 
 					/* get pixel value */
-					if (
+					if (_band[i] == NULL) {
+						if (!_hasnodata[i]) {
+							_haspixel[i] = 1;
+							_pixel[i] = _nodataval[i];
+						}
+					}
+					else if (
 						!_isempty[i] &&
 						(_x >= 0 && _x < _dim[i][0]) &&
 						(_y >= 0 && _y < _dim[i][1])
@@ -8692,6 +8698,7 @@ Datum RASTER_mapAlgebra2(PG_FUNCTION_ARGS)
 
 							PG_RETURN_NULL();
 						}
+
 						if (!_hasnodata[i] || FLT_NEQ(_nodataval[i], _pixel[i]))
 							_haspixel[i] = 1;
 					}
@@ -9517,7 +9524,7 @@ rt_pg_alloc(size_t size)
 {
     void * result;
 
-    POSTGIS_RT_DEBUGF(5, "rt_pgalloc(%ld) called", size);
+    POSTGIS_RT_DEBUGF(5, "rt_pgalloc(%ld) called", (long int) size);
 
     result = palloc(size);
 
@@ -9529,7 +9536,7 @@ rt_pg_realloc(void *mem, size_t size)
 {
     void * result;
 
-    POSTGIS_RT_DEBUGF(5, "rt_pg_realloc(%ld) called", size);
+    POSTGIS_RT_DEBUGF(5, "rt_pg_realloc(%ld) called", (long int) size);
 
     if (mem)
         result = repalloc(mem, size);
-- 
2.40.0