From: Bborie Park Date: Mon, 22 Oct 2012 17:19:48 +0000 (+0000) Subject: have raster2pgsql check for raster bands being NODATA X-Git-Tag: 2.1.0beta2~489 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f8cea63045d6b9d908af5544b2890cc185f56f8f;p=postgis have raster2pgsql check for raster bands being NODATA git-svn-id: http://svn.osgeo.org/postgis/trunk@10516 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/raster/loader/raster2pgsql.c b/raster/loader/raster2pgsql.c index 7c329381e..af551d389 100644 --- a/raster/loader/raster2pgsql.c +++ b/raster/loader/raster2pgsql.c @@ -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); diff --git a/raster/rt_core/rt_api.c b/raster/rt_core/rt_api.c index 6394ab8e5..428fa791e 100644 --- a/raster/rt_core/rt_api.c +++ b/raster/rt_core/rt_api.c @@ -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; }