]> granicus.if.org Git - postgis/commitdiff
Fixed the function rt_band_get_summary_stats rt_core/rt_api.c to correctly handle...
authorBborie Park <bkpark at ucdavis.edu>
Thu, 25 Aug 2011 23:23:46 +0000 (23:23 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Thu, 25 Aug 2011 23:23:46 +0000 (23:23 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@7788 b70326c6-7e19-0410-871a-916f4a2858ee

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

index a23df57fffd092c9103319b582129c99c280b6e8..1e81608ca24f0aeaf4ec4d6eccc936c8d0d65aa1 100644 (file)
@@ -1603,28 +1603,34 @@ rt_band_get_summary_stats(rt_band band, int exclude_nodata_value, double sample,
 
        /* entire band is nodata */
        if (rt_band_get_isnodata_flag(band) != FALSE) {
+               stats = (rt_bandstats) rtalloc(sizeof(struct rt_bandstats_t));
+               if (NULL == stats) {
+                       rterror("rt_band_get_summary_stats: Unable to allocate memory for stats");
+                       return NULL;
+               }
+
+               stats->sample = 1;
+               stats->sorted = 0;
+               stats->values = NULL;
+
                if (exclude_nodata_value) {
                        rtwarn("All pixels of band have the NODATA value");
-                       return NULL;
+
+                       stats->count = 0;
+                       stats->min = stats->max = 0;
+                       stats->sum = 0;
+                       stats->mean = 0;
+                       stats->stddev = -1;
                }
                else {
-                       stats = (rt_bandstats) rtalloc(sizeof(struct rt_bandstats_t));
-                       if (NULL == stats) {
-                               rterror("rt_band_get_summary_stats: Unable to allocate memory for stats");
-                               return NULL;
-                       }
-
-                       stats->sample = 1;
                        stats->count = band->width * band->height;
                        stats->min = stats->max = nodata;
                        stats->sum = stats->count * nodata;
                        stats->mean = nodata;
                        stats->stddev = 0;
-                       stats->values = NULL;
-                       stats->sorted = 0;
-
-                       return stats;
                }
+
+               return stats;
        }
 
        /* clamp percentage */
@@ -1667,6 +1673,21 @@ rt_band_get_summary_stats(rt_band band, int exclude_nodata_value, double sample,
                }
        }
 
+       /* initialize stats */
+       stats = (rt_bandstats) rtalloc(sizeof(struct rt_bandstats_t));
+       if (NULL == stats) {
+               rterror("rt_band_get_summary_stats: Unable to allocate memory for stats");
+               return NULL;
+       }
+       stats->sample = sample;
+       stats->count = 0;
+       stats->sum = 0;
+       stats->mean = 0;
+       stats->stddev = -1;
+       stats->min = stats->max = 0;
+       stats->values = NULL;
+       stats->sorted = 0;
+
        for (x = 0, j = 0, k = 0; x < band->width; x++) {
                y = -1;
                diff = 0;
@@ -1683,6 +1704,10 @@ rt_band_get_summary_stats(rt_band band, int exclude_nodata_value, double sample,
                        if (y >= band->height || z > sample_per) break;
 
                        rtn = rt_band_get_pixel(band, x, y, &value);
+#if POSTGIS_DEBUG_LEVEL > 0
+                       if (rtn != -1)
+                               RASTER_DEBUGF(4, "(x, y, value) = (%d,%d, %f)", x, y, value);
+#endif
 
                        j++;
                        if (
@@ -1729,24 +1754,9 @@ rt_band_get_summary_stats(rt_band band, int exclude_nodata_value, double sample,
                                }
 
                                /* min/max */
-                               if (NULL == stats) {
-                                       stats = (rt_bandstats) rtalloc(sizeof(struct rt_bandstats_t));
-                                       if (NULL == stats) {
-                                               rterror("rt_band_get_summary_stats: Unable to allocate memory for stats");
-                                               return NULL;
-                                       }
-
-                                       stats->sample = sample;
-                                       stats->count = 0;
-
-                                       stats->sum = 0;
-                                       stats->mean = 0;
-                                       stats->stddev = -1;
+                               if (stats->count < 1) {
+                                       stats->count = 1;
                                        stats->min = stats->max = value;
-
-                                       stats->values = NULL;
-                                       stats->sorted = 0;
-
                                }
                                else {
                                        if (value < stats->min)
@@ -1763,6 +1773,7 @@ rt_band_get_summary_stats(rt_band band, int exclude_nodata_value, double sample,
 
        RASTER_DEBUG(3, "sampling complete");
 
+       stats->count = k;
        if (k > 0) {
                if (inc_vals) {
                        /* free unused memory */
@@ -1773,7 +1784,6 @@ rt_band_get_summary_stats(rt_band band, int exclude_nodata_value, double sample,
                        stats->values = values;
                }
 
-               stats->count = k;
                stats->sum = sum;
                stats->mean = sum / k;
 
@@ -1789,17 +1799,18 @@ rt_band_get_summary_stats(rt_band band, int exclude_nodata_value, double sample,
                }
        }
        /* inc_vals thus values allocated but not used */
-       else if (inc_vals) {
+       else if (inc_vals)
                rtdealloc(values);
-       }
+
+       /* if count is zero and do_sample is one */
+       if (k < 0 && do_sample)
+               rtwarn("All sampled pixels of band have the NODATA value");
 
 #if POSTGIS_DEBUG_LEVEL > 0
-       if (NULL != stats) {
-               stop = clock();
-               elapsed = ((double) (stop - start)) / CLOCKS_PER_SEC;
-               RASTER_DEBUGF(3, "(time, count, mean, stddev, min, max) = (%0.4f, %d, %f, %f, %f, %f)",
-                       elapsed, stats->count, stats->mean, stats->stddev, stats->min, stats->max);
-       }
+       stop = clock();
+       elapsed = ((double) (stop - start)) / CLOCKS_PER_SEC;
+       RASTER_DEBUGF(3, "(time, count, mean, stddev, min, max) = (%0.4f, %d, %f, %f, %f, %f)",
+               elapsed, stats->count, stats->mean, stats->stddev, stats->min, stats->max);
 #endif
 
        RASTER_DEBUG(3, "done");
index a90559ae1b68007971cc35235cc0995e206940c4..2b3709100acf661e5c013bbd722896a07bbf5d89 100644 (file)
@@ -3239,7 +3239,7 @@ Datum RASTER_summaryStats(PG_FUNCTION_ARGS)
        /* get band */
        band = rt_raster_get_band(raster, bandindex - 1);
        if (!band) {
-               elog(NOTICE, "Could not find raster band of index %d. Returning NULL", bandindex);
+               elog(NOTICE, "Could not find band at index %d. Returning NULL", bandindex);
                rt_raster_destroy(raster);
                PG_RETURN_NULL();
        }
@@ -3250,7 +3250,7 @@ Datum RASTER_summaryStats(PG_FUNCTION_ARGS)
        rt_raster_destroy(raster);
        PG_FREE_IF_COPY(pgraster, 0);
        if (NULL == stats) {
-               elog(NOTICE, "Could not retrieve summary statistics of band of index %d. Returning NULL", bandindex);
+               elog(NOTICE, "Unable to compute summary statistics for band at index %d. Returning NULL", bandindex);
                PG_RETURN_NULL();
        }
 
@@ -3461,7 +3461,7 @@ Datum RASTER_summaryStatsCoverage(PG_FUNCTION_ARGS)
                /* get band */
                band = rt_raster_get_band(raster, bandindex - 1);
                if (!band) {
-                       elog(NOTICE, "Could not find raster band of index %d. Returning NULL", bandindex);
+                       elog(NOTICE, "Could not find band at index %d. Returning NULL", bandindex);
 
                        if (SPI_tuptable) SPI_freetuptable(tuptable);
                        SPI_cursor_close(portal);
@@ -3480,7 +3480,7 @@ Datum RASTER_summaryStatsCoverage(PG_FUNCTION_ARGS)
                rt_raster_destroy(raster);
 
                if (NULL == stats) {
-                       elog(NOTICE, "Could not retrieve summary statistics of band of index %d. Returning NULL", bandindex);
+                       elog(NOTICE, "Unable to compute summary statistics for band at index %d. Returning NULL", bandindex);
 
                        if (SPI_tuptable) SPI_freetuptable(tuptable);
                        SPI_cursor_close(portal);
@@ -3492,37 +3492,39 @@ Datum RASTER_summaryStatsCoverage(PG_FUNCTION_ARGS)
                }
 
                /* initialize rtn */
-               if (NULL == rtn) {
-                       rtn = (rt_bandstats) palloc(sizeof(struct rt_bandstats_t));
+               if (stats->count > 0) {
                        if (NULL == rtn) {
-                               elog(ERROR, "RASTER_summaryStatsCoverage: Unable to allocate memory for summary stats\n");
-
-                               if (SPI_tuptable) SPI_freetuptable(tuptable);
-                               SPI_cursor_close(portal);
-                               SPI_finish();
-
-                               PG_RETURN_NULL();
-                       }
+                               rtn = (rt_bandstats) palloc(sizeof(struct rt_bandstats_t));
+                               if (NULL == rtn) {
+                                       elog(ERROR, "RASTER_summaryStatsCoverage: Unable to allocate memory for summary stats of coverage\n");
 
-                       rtn->sample = stats->sample;
-                       rtn->count = stats->count;
-                       rtn->min = stats->min;
-                       rtn->max = stats->max;
-                       rtn->sum = stats->sum;
-                       rtn->mean = stats->mean;
-                       rtn->stddev = -1;
+                                       if (SPI_tuptable) SPI_freetuptable(tuptable);
+                                       SPI_cursor_close(portal);
+                                       SPI_finish();
 
-                       rtn->values = NULL;
-                       rtn->sorted = 0;
-               }
-               else {
-                       rtn->count += stats->count;
-                       rtn->sum += stats->sum;
+                                       PG_RETURN_NULL();
+                               }
 
-                       if (stats->min < rtn->min)
+                               rtn->sample = stats->sample;
+                               rtn->count = stats->count;
                                rtn->min = stats->min;
-                       if (stats->max > rtn->max)
                                rtn->max = stats->max;
+                               rtn->sum = stats->sum;
+                               rtn->mean = stats->mean;
+                               rtn->stddev = -1;
+
+                               rtn->values = NULL;
+                               rtn->sorted = 0;
+                       }
+                       else {
+                               rtn->count += stats->count;
+                               rtn->sum += stats->sum;
+
+                               if (stats->min < rtn->min)
+                                       rtn->min = stats->min;
+                               if (stats->max > rtn->max)
+                                       rtn->max = stats->max;
+                       }
                }
 
                pfree(stats);
@@ -3536,7 +3538,7 @@ Datum RASTER_summaryStatsCoverage(PG_FUNCTION_ARGS)
        SPI_finish();
 
        if (NULL == rtn) {
-               elog(ERROR, "RASTER_summaryStatsCoverage: Unable to get coverage summary stats\n");
+               elog(ERROR, "RASTER_summaryStatsCoverage: Unable to compute coverage summary stats\n");
                PG_RETURN_NULL();
        }
 
@@ -3756,7 +3758,7 @@ Datum RASTER_histogram(PG_FUNCTION_ARGS)
                /* get band */
                band = rt_raster_get_band(raster, bandindex - 1);
                if (!band) {
-                       elog(NOTICE, "Could not find raster band of index %d. Returning NULL", bandindex);
+                       elog(NOTICE, "Could not find band at index %d. Returning NULL", bandindex);
                        rt_raster_destroy(raster);
                        SRF_RETURN_DONE(funcctx);
                }
@@ -3767,7 +3769,11 @@ Datum RASTER_histogram(PG_FUNCTION_ARGS)
                rt_raster_destroy(raster);
                PG_FREE_IF_COPY(pgraster, 0);
                if (NULL == stats || NULL == stats->values) {
-                       elog(NOTICE, "Could not retrieve summary statistics of raster band of index %d", bandindex);
+                       elog(NOTICE, "Unable to compute summary statistics for band at index %d", bandindex);
+                       SRF_RETURN_DONE(funcctx);
+               }
+               else if (stats->count < 1) {
+                       elog(NOTICE, "Unable to compute histogram for band at index %d as the band has no values", bandindex);
                        SRF_RETURN_DONE(funcctx);
                }
 
@@ -3776,7 +3782,7 @@ Datum RASTER_histogram(PG_FUNCTION_ARGS)
                if (bin_width_count) pfree(bin_width);
                pfree(stats);
                if (NULL == hist || !count) {
-                       elog(NOTICE, "Could not retrieve histogram of raster band of index %d", bandindex);
+                       elog(NOTICE, "Unable to compute histogram for band at index %d", bandindex);
                        SRF_RETURN_DONE(funcctx);
                }
 
@@ -4063,7 +4069,7 @@ Datum RASTER_histogramCoverage(PG_FUNCTION_ARGS)
                spi_result = SPI_execute(sql, TRUE, 0);
                pfree(sql);
                if (spi_result != SPI_OK_SELECT || SPI_tuptable == NULL || SPI_processed != 1) {
-                       elog(ERROR, "RASTER_histogramCoverage: Could not get coverage summary stats");
+                       elog(ERROR, "RASTER_histogramCoverage: Could not get summary stats of coverage");
 
                        if (SPI_tuptable) SPI_freetuptable(tuptable);
                        SPI_finish();
@@ -4079,7 +4085,7 @@ Datum RASTER_histogramCoverage(PG_FUNCTION_ARGS)
 
                tmp = SPI_getvalue(tuple, tupdesc, 1);
                if (NULL == tmp || !strlen(tmp)) {
-                       elog(ERROR, "RASTER_histogramCoverage: Could not get coverage summary stats");
+                       elog(ERROR, "RASTER_histogramCoverage: Could not get summary stats of coverage");
 
                        if (SPI_tuptable) SPI_freetuptable(tuptable);
                        SPI_finish();
@@ -4094,7 +4100,7 @@ Datum RASTER_histogramCoverage(PG_FUNCTION_ARGS)
 
                tmp = SPI_getvalue(tuple, tupdesc, 2);
                if (NULL == tmp || !strlen(tmp)) {
-                       elog(ERROR, "RASTER_histogramCoverage: Could not get coverage summary stats");
+                       elog(ERROR, "RASTER_histogramCoverage: Could not get summary stats of coverage");
 
                        if (SPI_tuptable) SPI_freetuptable(tuptable);
                        SPI_finish();
@@ -4193,7 +4199,7 @@ Datum RASTER_histogramCoverage(PG_FUNCTION_ARGS)
                        /* get band */
                        band = rt_raster_get_band(raster, bandindex - 1);
                        if (!band) {
-                               elog(NOTICE, "Could not find raster band of index %d. Returning NULL", bandindex);
+                               elog(NOTICE, "Could not find band at index %d. Returning NULL", bandindex);
 
                                if (SPI_tuptable) SPI_freetuptable(tuptable);
                                SPI_cursor_close(portal);
@@ -4213,7 +4219,7 @@ Datum RASTER_histogramCoverage(PG_FUNCTION_ARGS)
                        rt_raster_destroy(raster);
 
                        if (NULL == stats) {
-                               elog(NOTICE, "Could not retrieve summary statistics of band of index %d. Returning NULL", bandindex);
+                               elog(NOTICE, "Unable to compute summary statistics for band at index %d. Returning NULL", bandindex);
 
                                if (SPI_tuptable) SPI_freetuptable(tuptable);
                                SPI_cursor_close(portal);
@@ -4226,58 +4232,60 @@ Datum RASTER_histogramCoverage(PG_FUNCTION_ARGS)
                        }
 
                        /* get histogram */
-                       hist = rt_band_get_histogram(stats, bin_count, bin_width, bin_width_count, right, min, max, &count);
-                       pfree(stats);
-                       if (NULL == hist || !count) {
-                               elog(NOTICE, "Could not retrieve histogram of raster band of index %d", bandindex);
-
-                               if (SPI_tuptable) SPI_freetuptable(tuptable);
-                               SPI_cursor_close(portal);
-                               SPI_finish();
-
-                               if (NULL != covhist) pfree(covhist);
-                               if (bin_width_count) pfree(bin_width);
-
-                               SRF_RETURN_DONE(funcctx);
-                       }
-
-                       POSTGIS_RT_DEBUGF(3, "%d bins returned", count);
-
-                       /* coverage histogram */
-                       if (NULL == covhist) {
-                               covhist = (rt_histogram) palloc(sizeof(struct rt_histogram_t) * count);
-                               if (NULL == covhist) {
-                                       elog(ERROR, "RASTER_histogramCoverage: Unable to allocate memory for coverage histogram");
+                       if (stats->count > 0) {
+                               hist = rt_band_get_histogram(stats, bin_count, bin_width, bin_width_count, right, min, max, &count);
+                               pfree(stats);
+                               if (NULL == hist || !count) {
+                                       elog(NOTICE, "Unable to compute histogram for band at index %d", bandindex);
 
                                        if (SPI_tuptable) SPI_freetuptable(tuptable);
                                        SPI_cursor_close(portal);
                                        SPI_finish();
 
+                                       if (NULL != covhist) pfree(covhist);
                                        if (bin_width_count) pfree(bin_width);
-                                       pfree(hist);
 
                                        SRF_RETURN_DONE(funcctx);
                                }
 
-                               for (i = 0; i < count; i++) {
-                                       sum += hist[i].count;
-                                       covhist[i].count = hist[i].count;
-                                       covhist[i].percent = 0;
-                                       covhist[i].min = hist[i].min;
-                                       covhist[i].max = hist[i].max;
+                               POSTGIS_RT_DEBUGF(3, "%d bins returned", count);
+
+                               /* coverage histogram */
+                               if (NULL == covhist) {
+                                       covhist = (rt_histogram) palloc(sizeof(struct rt_histogram_t) * count);
+                                       if (NULL == covhist) {
+                                               elog(ERROR, "RASTER_histogramCoverage: Unable to allocate memory for histogram of coverage");
+
+                                               if (SPI_tuptable) SPI_freetuptable(tuptable);
+                                               SPI_cursor_close(portal);
+                                               SPI_finish();
+
+                                               if (bin_width_count) pfree(bin_width);
+                                               pfree(hist);
+
+                                               SRF_RETURN_DONE(funcctx);
+                                       }
+
+                                       for (i = 0; i < count; i++) {
+                                               sum += hist[i].count;
+                                               covhist[i].count = hist[i].count;
+                                               covhist[i].percent = 0;
+                                               covhist[i].min = hist[i].min;
+                                               covhist[i].max = hist[i].max;
+                                       }
                                }
-                       }
-                       else {
-                               for (i = 0; i < count; i++) {
-                                       sum += hist[i].count;
-                                       covhist[i].count += hist[i].count;
+                               else {
+                                       for (i = 0; i < count; i++) {
+                                               sum += hist[i].count;
+                                               covhist[i].count += hist[i].count;
+                                       }
                                }
-                       }
 
-                       pfree(hist);
+                               pfree(hist);
 
-                       /* assuming bin_count wasn't set, force consistency */
-                       if (bin_count <= 0) bin_count = count;
+                               /* assuming bin_count wasn't set, force consistency */
+                               if (bin_count <= 0) bin_count = count;
+                       }
 
                        /* next record */
                        SPI_cursor_fetch(portal, TRUE, 1);
@@ -4511,7 +4519,7 @@ Datum RASTER_quantile(PG_FUNCTION_ARGS)
                /* get band */
                band = rt_raster_get_band(raster, bandindex - 1);
                if (!band) {
-                       elog(NOTICE, "Could not find raster band of index %d. Returning NULL", bandindex);
+                       elog(NOTICE, "Could not find band at index %d. Returning NULL", bandindex);
                        rt_raster_destroy(raster);
                        SRF_RETURN_DONE(funcctx);
                }
@@ -4522,7 +4530,11 @@ Datum RASTER_quantile(PG_FUNCTION_ARGS)
                rt_raster_destroy(raster);
                PG_FREE_IF_COPY(pgraster, 0);
                if (NULL == stats || NULL == stats->values) {
-                       elog(NOTICE, "Could not retrieve summary statistics of raster band of index %d", bandindex);
+                       elog(NOTICE, "Could not retrieve summary statistics for band at index %d", bandindex);
+                       SRF_RETURN_DONE(funcctx);
+               }
+               else if (stats->count < 1) {
+                       elog(NOTICE, "Unable to compute quantiles for band at index %d as the band has no values", bandindex);
                        SRF_RETURN_DONE(funcctx);
                }
 
@@ -4531,7 +4543,7 @@ Datum RASTER_quantile(PG_FUNCTION_ARGS)
                if (quantiles_count) pfree(quantiles);
                pfree(stats);
                if (NULL == quant || !count) {
-                       elog(NOTICE, "Could not retrieve quantiles of raster band of index %d", bandindex);
+                       elog(NOTICE, "Unable to compute quantiles for band at index %d", bandindex);
                        SRF_RETURN_DONE(funcctx);
                }
 
@@ -4800,7 +4812,7 @@ Datum RASTER_quantileCoverage(PG_FUNCTION_ARGS)
                spi_result = SPI_execute(sql, TRUE, 0);
                pfree(sql);
                if (spi_result != SPI_OK_SELECT || SPI_tuptable == NULL || SPI_processed != 1) {
-                       elog(ERROR, "RASTER_quantileCoverage: Could not get coverage summary stats");
+                       elog(ERROR, "RASTER_quantileCoverage: Could not get summary stats of coverage");
 
                        if (SPI_tuptable) SPI_freetuptable(tuptable);
                        SPI_finish();
@@ -4814,7 +4826,7 @@ Datum RASTER_quantileCoverage(PG_FUNCTION_ARGS)
 
                tmp = SPI_getvalue(tuple, tupdesc, 1);
                if (NULL == tmp || !strlen(tmp)) {
-                       elog(ERROR, "RASTER_quantileCoverage: Could not get coverage summary stats");
+                       elog(ERROR, "RASTER_quantileCoverage: Could not get summary stats of coverage");
 
                        if (SPI_tuptable) SPI_freetuptable(tuptable);
                        SPI_finish();
@@ -4927,7 +4939,7 @@ Datum RASTER_quantileCoverage(PG_FUNCTION_ARGS)
                        rt_raster_destroy(raster);
 
                        if (NULL == covquant || !count) {
-                               elog(NOTICE, "Could not retrieve quantiles of roaster band of index %d", bandindex);
+                               elog(NOTICE, "Unable to compute quantiles for band at index %d", bandindex);
 
                                if (SPI_tuptable) SPI_freetuptable(tuptable);
                                SPI_cursor_close(portal);
@@ -5157,7 +5169,7 @@ Datum RASTER_valueCount(PG_FUNCTION_ARGS) {
                /* get band */
                band = rt_raster_get_band(raster, bandindex - 1);
                if (!band) {
-                       elog(NOTICE, "Could not find raster band of index %d. Returning NULL", bandindex);
+                       elog(NOTICE, "Could not find band at index %d. Returning NULL", bandindex);
                        rt_raster_destroy(raster);
                        SRF_RETURN_DONE(funcctx);
                }
@@ -5168,7 +5180,7 @@ Datum RASTER_valueCount(PG_FUNCTION_ARGS) {
                rt_raster_destroy(raster);
                PG_FREE_IF_COPY(pgraster, 0);
                if (NULL == vcnts || !count) {
-                       elog(NOTICE, "Could not count the values of raster band of index %d", bandindex);
+                       elog(NOTICE, "Unable to count the values for band at index %d", bandindex);
                        SRF_RETURN_DONE(funcctx);
                }
 
@@ -5489,7 +5501,7 @@ Datum RASTER_valueCountCoverage(PG_FUNCTION_ARGS) {
                        /* get band */
                        band = rt_raster_get_band(raster, bandindex - 1);
                        if (!band) {
-                               elog(NOTICE, "Could not find raster band of index %d. Returning NULL", bandindex);
+                               elog(NOTICE, "Could not find band at index %d. Returning NULL", bandindex);
 
                                if (SPI_tuptable) SPI_freetuptable(tuptable);
                                SPI_cursor_close(portal);
@@ -5507,7 +5519,7 @@ Datum RASTER_valueCountCoverage(PG_FUNCTION_ARGS) {
                        rt_band_destroy(band);
                        rt_raster_destroy(raster);
                        if (NULL == vcnts || !count) {
-                               elog(NOTICE, "Could not count the values of raster band of index %d", bandindex);
+                               elog(NOTICE, "Unable to count the values for band at index %d", bandindex);
                                SRF_RETURN_DONE(funcctx);
                        }
 
@@ -5522,7 +5534,7 @@ Datum RASTER_valueCountCoverage(PG_FUNCTION_ARGS) {
                                */
                                covvcnts = (rt_valuecount) malloc(sizeof(struct rt_valuecount_t) * count);
                                if (NULL == covvcnts) {
-                                       elog(ERROR, "RASTER_valueCountCoverage: Unable to allocate memory for coverage value counts");
+                                       elog(ERROR, "RASTER_valueCountCoverage: Unable to allocate memory for value counts of coverage");
 
                                        if (SPI_tuptable) SPI_freetuptable(tuptable);
                                        SPI_cursor_close(portal);
@@ -5560,7 +5572,7 @@ Datum RASTER_valueCountCoverage(PG_FUNCTION_ARGS) {
                                                covcount++;
                                                covvcnts = realloc(covvcnts, sizeof(struct rt_valuecount_t) * covcount);
                                                if (NULL == covvcnts) {
-                                                       elog(ERROR, "RASTER_valueCountCoverage: Unable to change allocated memory for coverage value counts");
+                                                       elog(ERROR, "RASTER_valueCountCoverage: Unable to change allocated memory for value counts of coverage");
 
                                                        if (SPI_tuptable) SPI_freetuptable(tuptable);
                                                        SPI_cursor_close(portal);
index ed627a3eee5eb0efc7268f6e742979c7426a7f91..81efac63776239135a007abcf12959ec51f69c50 100644 (file)
@@ -2836,7 +2836,7 @@ CREATE OR REPLACE FUNCTION AddRasterColumn(p_catalog_name varchar,
 
     BEGIN
 
-        RAISE DEBUG 'Parameters: catalog=%, schema=%, table=%, column=%, srid=%, pixel_types=%, out_db=%, regular_blocking=%, nodata_values=%, scale_x=%, scale_y=%, blocksize_x=%, blocksize_y=%',
+        --RAISE DEBUG 'Parameters: catalog=%, schema=%, table=%, column=%, srid=%, pixel_types=%, out_db=%, regular_blocking=%, nodata_values=%, scale_x=%, scale_y=%, blocksize_x=%, blocksize_y=%',
                      p_catalog_name, p_schema_name, p_table_name, p_column_name, p_srid, p_pixel_types, p_out_db, p_regular_blocking, p_nodata_values, p_scale_x, p_scale_y, p_blocksize_x, p_blocksize_y;
 
         -- Validate required parametersa and combinations
@@ -2886,7 +2886,7 @@ CREATE OR REPLACE FUNCTION AddRasterColumn(p_catalog_name varchar,
                 RAISE EXCEPTION 'Invalid SRID';
                 RETURN 'fail';
             END IF;
-            RAISE DEBUG 'Verified SRID = %', p_srid;
+            --RAISE DEBUG 'Verified SRID = %', p_srid;
         END IF;
 
 
@@ -2901,7 +2901,7 @@ CREATE OR REPLACE FUNCTION AddRasterColumn(p_catalog_name varchar,
             FOR pti IN array_lower(pixel_types, 1) .. array_upper(pixel_types, 1) LOOP
                 IF p_pixel_types[npti] = pixel_types[pti] THEN
                     pixel_types_found := 1;
-                    RAISE DEBUG 'Identified pixel type %', p_pixel_types[npti];
+                    --RAISE DEBUG 'Identified pixel type %', p_pixel_types[npti];
                 END IF;
             END LOOP;
 
@@ -2974,7 +2974,7 @@ CREATE OR REPLACE FUNCTION AddRasterColumn(p_catalog_name varchar,
             sql := 'SELECT nspname FROM pg_namespace '
                 || 'WHERE text(nspname) = ' || quote_literal(p_schema_name)
                 || 'LIMIT 1';
-            RAISE DEBUG '%', sql;
+            --RAISE DEBUG '%', sql;
             EXECUTE sql INTO real_schema;
 
             IF ( real_schema IS NULL ) THEN
@@ -2984,7 +2984,7 @@ CREATE OR REPLACE FUNCTION AddRasterColumn(p_catalog_name varchar,
         END IF;
 
         IF ( real_schema IS NULL ) THEN
-            RAISE DEBUG 'Detecting schema';
+            --RAISE DEBUG 'Detecting schema';
             sql := 'SELECT n.nspname AS schemaname '
                 || 'FROM pg_catalog.pg_class c '
                 || 'JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace '
@@ -2993,7 +2993,7 @@ CREATE OR REPLACE FUNCTION AddRasterColumn(p_catalog_name varchar,
                 || quote_literal('pg_catalog') || ', ' || quote_literal('pg_toast') || ')'
                 || ' AND pg_catalog.pg_table_is_visible(c.oid)'
                 || ' AND c.relname = ' || quote_literal(p_table_name);
-            RAISE DEBUG '%', sql;
+            --RAISE DEBUG '%', sql;
             EXECUTE sql INTO real_schema;
 
             IF ( real_schema IS NULL ) THEN
@@ -3008,7 +3008,7 @@ CREATE OR REPLACE FUNCTION AddRasterColumn(p_catalog_name varchar,
         sql := 'ALTER TABLE '
             || quote_ident(real_schema) || '.' || quote_ident(p_table_name)
             || ' ADD COLUMN ' || quote_ident(p_column_name) ||  ' raster ';
-        RAISE DEBUG '%', sql;
+        --RAISE DEBUG '%', sql;
         EXECUTE sql;
 
 
@@ -3018,7 +3018,7 @@ CREATE OR REPLACE FUNCTION AddRasterColumn(p_catalog_name varchar,
             || ' AND r_table_schema = ' || quote_literal(real_schema)
             || ' AND r_table_name = ' || quote_literal(p_table_name)
             || ' AND r_column = ' || quote_literal(p_column_name);
-        RAISE DEBUG '%', sql;
+        --RAISE DEBUG '%', sql;
         EXECUTE sql;
 
 
@@ -3042,7 +3042,7 @@ CREATE OR REPLACE FUNCTION AddRasterColumn(p_catalog_name varchar,
             || COALESCE(quote_literal(p_blocksize_x), 'NULL') || ','
             || COALESCE(quote_literal(p_blocksize_y), 'NULL') || ','
             || COALESCE(quote_literal(p_extent::text), 'NULL') || ')';
-        RAISE DEBUG '%', sql;
+        --RAISE DEBUG '%', sql;
         EXECUTE sql;
 
 
@@ -3053,7 +3053,7 @@ CREATE OR REPLACE FUNCTION AddRasterColumn(p_catalog_name varchar,
             || quote_ident('enforce_srid_' || p_column_name)
             || ' CHECK (ST_SRID(' || quote_ident(p_column_name)
             || ') = ' || p_srid::text || ')';
-        RAISE DEBUG '%', sql;
+        --RAISE DEBUG '%', sql;
         EXECUTE sql;
 
 
index 36f5cf10e301c9d4850c34a480dc85b0bf6e3b8a..01b28957f0141fec8ba29671e932ed273a36952c 100644 (file)
@@ -10,12 +10,6 @@ NOTICE:  The geometry's SRID (993310) is not the same as the raster's SRID (9921
 NOTICE:  The geometry's SRID (993310) is not the same as the raster's SRID (992163).  The geometry will be transformed to the raster's projection
 NOTICE:  The geometry's SRID (993310) is not the same as the raster's SRID (992163).  The geometry will be transformed to the raster's projection
 NOTICE:  The geometry's SRID (993310) is not the same as the raster's SRID (992163).  The geometry will be transformed to the raster's projection
-NOTICE:  Could not retrieve summary statistics of band of index 1. Returning NULL
-NOTICE:  Could not retrieve summary statistics of band of index 1. Returning NULL
-NOTICE:  Could not retrieve summary statistics of band of index 1. Returning NULL
-NOTICE:  Could not retrieve summary statistics of band of index 1. Returning NULL
-NOTICE:  Could not retrieve summary statistics of band of index 1. Returning NULL
-NOTICE:  Could not retrieve summary statistics of band of index 1. Returning NULL
 1.1|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.10|993310|141|87|1|1000.000|-1000.000|0.000|0.000|-175453.086|114987.661|32BF|t|0.000|t|1.000|1.000
 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
@@ -28,7 +22,7 @@ NOTICE:  Could not retrieve summary statistics of band of index 1. Returning NUL
 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|||
+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.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