<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>
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);
}
/**
/**
* 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
/* 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);
* 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);
* 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);