]> granicus.if.org Git - postgis/commitdiff
have raster2pgsql check for raster bands being NODATA
authorBborie Park <bkpark at ucdavis.edu>
Mon, 22 Oct 2012 17:19:48 +0000 (17:19 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Mon, 22 Oct 2012 17:19:48 +0000 (17:19 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@10516 b70326c6-7e19-0410-871a-916f4a2858ee

raster/loader/raster2pgsql.c
raster/rt_core/rt_api.c

index 7c329381e91f7e4fa354686362cf7255090625e6..af551d389534e8ddb090ebcb2055c69353602975 100644 (file)
@@ -1422,6 +1422,8 @@ convert_raster(int idx, RTLOADERCFG *config, RASTERINFO *info, STRINGBUFFER *til
        const char* pszProjectionRef = NULL;
 
        rt_raster rast = NULL;
+       int numbands = 0;
+       rt_band band = NULL;
        char *hex;
        uint32_t hexlen = 0;
 
@@ -1596,8 +1598,6 @@ convert_raster(int idx, RTLOADERCFG *config, RASTERINFO *info, STRINGBUFFER *til
 
        /* out-db raster */
        if (config->outdb) {
-               rt_band band = NULL;
-
                GDALClose(hdsSrc);
 
                /* each tile is a raster */
@@ -1637,6 +1637,9 @@ convert_raster(int idx, RTLOADERCFG *config, RASTERINFO *info, STRINGBUFFER *til
                                                return 0;
                                        }
 
+                                       /* inspect each band of raster where band is NODATA */
+                                       rt_band_check_is_nodata(band);
+
                                        /* add band to raster */
                                        if (rt_raster_add_band(rast, band, rt_raster_get_num_bands(rast)) == -1) {
                                                rterror(_("convert_raster: Could not add offlineband to raster"));
@@ -1742,6 +1745,14 @@ convert_raster(int idx, RTLOADERCFG *config, RASTERINFO *info, STRINGBUFFER *til
                                /* set srid if provided */
                                rt_raster_set_srid(rast, info->srid);
 
+                               /* inspect each band of raster where band is NODATA */
+                               numbands = rt_raster_get_num_bands(rast);
+                               for (i = 0; i < numbands; i++) {
+                                       band = rt_raster_get_band(rast, i);
+                                       if (band != NULL)
+                                               rt_band_check_is_nodata(band);
+                               }
+
                                /* convert rt_raster to hexwkb */
                                hex = rt_raster_to_hexwkb(rast, &hexlen);
                                raster_destroy(rast);
index 6394ab8e57137ff9db80520242cf6a6317a9afaa..428fa791e6274efc7b45d4b147fc2786c6efc51f 100644 (file)
@@ -7182,7 +7182,8 @@ rt_band_from_wkb(uint16_t width, uint16_t height,
             *ptr += sz + 1;
 
             /* TODO: How could we know if the offline band is a nodata band? */
-            band->isnodata = FALSE;
+                                               /* trust in the force */
+            /*band->isnodata = FALSE;*/
         }
         return band;
     }