From: Bborie Park Date: Thu, 17 Nov 2011 14:49:34 +0000 (+0000) Subject: Fixed invalid handling of nodatavalue in ST_BandMetaData(). Issue arises due to... X-Git-Tag: 2.0.0alpha1~698 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6183db897233075bead8ff445911c6336baf3002;p=postgis Fixed invalid handling of nodatavalue in ST_BandMetaData(). Issue arises due to C backend using Float8GetDatum while SQL frontend using real datatype. git-svn-id: http://svn.osgeo.org/postgis/trunk@8162 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/raster/rt_pg/rt_pg.c b/raster/rt_pg/rt_pg.c index d2825fec6..3a5dba4fb 100644 --- a/raster/rt_pg/rt_pg.c +++ b/raster/rt_pg/rt_pg.c @@ -358,6 +358,7 @@ strsplit(const char *str, const char *delimiter, int *n) { char **rtn = NULL; char *token = NULL; + *n = 0; if (!str) return NULL; @@ -386,7 +387,6 @@ strsplit(const char *str, const char *delimiter, int *n) { return rtn; } - *n = 0; token = strtok(tmp, delimiter); while (token != NULL) { if (*n < 1) { @@ -6252,7 +6252,9 @@ Datum RASTER_reclass(PG_FUNCTION_ARGS) { exprset[j]->dst.max = val; } } + pfree(dash_set); } + pfree(colon_set); POSTGIS_RT_DEBUGF(3, "RASTER_reclass: or: %f - %f nr: %f - %f" , exprset[j]->src.min @@ -6262,6 +6264,7 @@ Datum RASTER_reclass(PG_FUNCTION_ARGS) { ); j++; } + pfree(comma_set); /* pixel type */ tupv = GetAttributeByName(tup, "pixeltype", &isnull); @@ -7636,7 +7639,10 @@ Datum RASTER_bandmetadata(PG_FUNCTION_ARGS) if (rt_band_get_hasnodata_flag(band)) hasnodatavalue = TRUE; /* nodatavalue */ - nodatavalue = rt_band_get_nodata(band); + if (hasnodatavalue) + nodatavalue = rt_band_get_nodata(band); + else + nodatavalue = 0; /* path */ tmp = rt_band_get_ext_path(band); diff --git a/raster/rt_pg/rtpostgis.sql.in.c b/raster/rt_pg/rtpostgis.sql.in.c index 18fbe6216..4acee61f5 100644 --- a/raster/rt_pg/rtpostgis.sql.in.c +++ b/raster/rt_pg/rtpostgis.sql.in.c @@ -1835,7 +1835,7 @@ CREATE OR REPLACE FUNCTION st_bandmetadata( band int DEFAULT 1, OUT pixeltype text, OUT hasnodata boolean, - OUT nodatavalue float4, + OUT nodatavalue double precision, OUT isoutdb boolean, OUT path text ) diff --git a/raster/test/regress/rt_asraster_expected b/raster/test/regress/rt_asraster_expected index 01b28957f..01aef4c5c 100644 --- a/raster/test/regress/rt_asraster_expected +++ b/raster/test/regress/rt_asraster_expected @@ -15,14 +15,14 @@ NOTICE: The geometry's SRID (993310) is not the same as the raster's SRID (9921 1.11|993310|100|100|1|1406.537|-869.114|0.000|0.000|-175453.086|114987.661|8BUI|t|0.000|t|1.000|1.000 1.12|993310|100|100|1|1406.537|-869.114|0.000|0.000|-175453.086|114987.661|16BUI|t|0.000|t|1.000|1.000 1.13|993310|100|100|1|1406.537|-869.114|0.000|0.000|-175453.086|114987.661|32BF|t|0.000|t|255.000|255.000 -1.14|993310|100|100|1|1406.537|-869.114|0.000|0.000|-175453.086|114987.661|32BF|t|0.000|t|255.000|255.000 +1.14|993310|100|100|1|1406.537|-869.114|0.000|0.000|-175453.086|114987.661|32BF|t|1.000|t|255.000|255.000 1.15|993310|100|100|1|1406.537|-869.114|0.000|0.000|-175453.086|114987.661|8BUI|t|0.000|t|1.000|1.000 1.16|993310|100|100|1|1406.537|-869.114|0.000|0.000|-175453.086|114987.661|32BF|f|0.000|t|0.000|255.000 1.17|993310|141|87|2|1000.000|-1000.000|0.000|0.000|-175453.086|114987.661|32BF|f|0.000|t|0.000|255.000 1.18|993310|10|10|2|14065.366|-8691.142|0.000|0.000|-175453.086|114987.661|8BUI|t|0.000|t|255.000|255.000 1.19|993310|141|87|3|1000.000|-1000.000|0.000|0.000|-175453.086|114987.661|32BF|f|0.000|t|0.000|255.000 1.2|993310|1407|869|1|100.000|-100.000|0.000|0.000|-175453.086|114987.661|8BUI|t|0.000|t|1.000|1.000 -1.20|993310|141|87|2|1000.000|-1000.000|0.000|0.000|-175453.086|114987.661|8BUI|t|0.000|f|0.000|0.000 +1.20|993310|141|87|2|1000.000|-1000.000|0.000|0.000|-175453.086|114987.661|8BUI|t|1.000|f|0.000|0.000 1.3|993310|500|500|1|281.307|-173.823|0.000|0.000|-175453.086|114987.661|8BUI|t|0.000|t|1.000|1.000 1.4|993310|141|87|1|1000.000|-1000.000|0.000|0.000|-175453.086|114987.661|8BUI|t|0.000|t|1.000|1.000 1.5|993310|141|87|1|1000.000|-1000.000|0.000|0.000|-175453.086|114987.661|8BUI|t|0.000|t|1.000|1.000