]> granicus.if.org Git - postgis/commitdiff
Fixed invalid handling of nodatavalue in ST_BandMetaData(). Issue arises due to...
authorBborie Park <bkpark at ucdavis.edu>
Thu, 17 Nov 2011 14:49:34 +0000 (14:49 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Thu, 17 Nov 2011 14:49:34 +0000 (14:49 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@8162 b70326c6-7e19-0410-871a-916f4a2858ee

raster/rt_pg/rt_pg.c
raster/rt_pg/rtpostgis.sql.in.c
raster/test/regress/rt_asraster_expected

index d2825fec601f4d89537b95155cedcb866ba944a6..3a5dba4fb0ed6656cda762ac160079bd36efe233 100644 (file)
@@ -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);
index 18fbe621667436d142ca609be631fa97d4dbb206..4acee61f5235f52cfb49c683eb7fffc48f3c75a4 100644 (file)
@@ -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
 )
index 01b28957f0141fec8ba29671e932ed273a36952c..01aef4c5c87bbff7b60d906462dd89970e1eff1e 100644 (file)
@@ -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