]> granicus.if.org Git - postgis/commitdiff
Changed rt_raster_has_no_band to use 0-based band index instead of 1-based. Removed...
authorBborie Park <bkpark at ucdavis.edu>
Fri, 21 Oct 2011 18:11:46 +0000 (18:11 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Fri, 21 Oct 2011 18:11:46 +0000 (18:11 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@7998 b70326c6-7e19-0410-871a-916f4a2858ee

doc/reference_raster.xml
raster/rt_core/rt_api.c
raster/rt_core/rt_api.h
raster/rt_pg/rt_pg.c

index ef4ce0ac242360db82007598475ae1c17af03a02..eaffce4ebf5b7b15d9cbc4122cc6f65ca91db743 100644 (file)
@@ -2798,14 +2798,10 @@ WHERE rid = 2;
                
                        <refsynopsisdiv>
                                <funcsynopsis>
-                               <funcprototype>
-                                       <funcdef>boolean <function>ST_HasNoBand</function></funcdef>
-                                       <paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
-                                 </funcprototype>
                                  <funcprototype>
-                                       <funcdef>boolean <function>ST_HasNoBand</function></funcdef>
-                                       <paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
-                                       <paramdef><type>integer </type> <parameter>bandnum</parameter></paramdef>
+                                               <funcdef>boolean <function>ST_HasNoBand</function></funcdef>
+                                               <paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
+                                               <paramdef><type>integer </type> <parameter>bandnum=1</parameter></paramdef>
                                  </funcprototype>
                                </funcsynopsis>
                        </refsynopsisdiv>
index 5b987deb4de95692cae673d369fdadd80122402d..ab27e579549dc262307fa39f1b7b948090398130 100644 (file)
@@ -5891,16 +5891,29 @@ rt_raster_deserialize(void* serialized, int header_only) {
     return rast;
 }
 
-int rt_raster_is_empty(rt_raster raster) {
-
-
-    return (NULL == raster || raster->height <= 0 || raster->width <= 0);
+/**
+ * Return TRUE if the raster is empty. i.e. is NULL, width = 0 or height = 0
+ *
+ * @param raster: the raster to get info from
+ *
+ * @return TRUE if the raster is empty, FALSE otherwise
+ */
+int
+rt_raster_is_empty(rt_raster raster) {
+       return (NULL == raster || raster->height <= 0 || raster->width <= 0);
 }
 
-int rt_raster_has_no_band(rt_raster raster, int nband) {
-
-
-    return (NULL == raster || raster->numBands < nband);
+/**
+ * Return TRUE if the raster do not have a band of this number.
+ *
+ * @param raster: the raster to get info from
+ * @param nband: the band number. 0-based
+ *
+ * @return TRUE if the raster do not have a band of this number, FALSE otherwise
+ */
+int
+rt_raster_has_no_band(rt_raster raster, int nband) {
+       return (NULL == raster || nband >= raster->numBands || nband < 0);
 }
 
 /**
index 7dcff50e5ad4e5ad46c6283dd24cd39c728438b6..14acc5b33b060364ce740f1693f99306863dfde5 100644 (file)
@@ -904,20 +904,23 @@ rt_raster rt_raster_deserialize(void* serialized, int header_only);
 
 /**
  * Return TRUE if the raster is empty. i.e. is NULL, width = 0 or height = 0
+ *
  * @param raster: the raster to get info from
+ *
  * @return TRUE if the raster is empty, FALSE otherwise
  */
 int rt_raster_is_empty(rt_raster raster);
 
 /**
  * Return TRUE if the raster do not have a band of this number.
+ *
  * @param raster: the raster to get info from
- * @param nband: the band number.
+ * @param nband: the band number. 0-based
+ *
  * @return TRUE if the raster do not have a band of this number, FALSE otherwise
  */
 int rt_raster_has_no_band(rt_raster raster, int nband);
 
-
 /**
  * Copy one band from one raster to another
  * @param torast: raster to copy band to
index dff54c9744b808f3fc6667ae52b653100712e5f0..60daeb575620922cdf9cf5ab47ef7f92a0c3207c 100644 (file)
@@ -2393,7 +2393,7 @@ Datum RASTER_hasNoBand(PG_FUNCTION_ARGS)
 
     /* Get band number */
     bandindex = PG_GETARG_INT32(1);
-    hasnoband = rt_raster_has_no_band(raster, bandindex);
+    hasnoband = rt_raster_has_no_band(raster, bandindex - 1);
 
     rt_raster_destroy(raster);
 
@@ -2521,7 +2521,7 @@ Datum RASTER_mapAlgebraExpr(PG_FUNCTION_ARGS)
      * Check if the raster has the required band. Otherwise, return a raster
      * without band
      **/
-    if (rt_raster_has_no_band(raster, nband)) {
+    if (rt_raster_has_no_band(raster, nband - 1)) {
         elog(NOTICE, "Raster does not have the required band. Returning a raster "
                 "without a band");
         rt_raster_destroy(raster);
@@ -3122,7 +3122,7 @@ Datum RASTER_mapAlgebraFct(PG_FUNCTION_ARGS)
      * Check if the raster has the required band. Otherwise, return a raster
      * without band
      **/
-    if (rt_raster_has_no_band(raster, nband)) {
+    if (rt_raster_has_no_band(raster, nband - 1)) {
         elog(NOTICE, "Raster does not have the required band. Returning a raster "
             "without a band");
         rt_raster_destroy(raster);