]> granicus.if.org Git - postgis/commitdiff
Getting pixel value at out of range coordinate should only return a warning. Was...
authorPierre Racine <Pierre.Racine@sbf.ulaval.ca>
Fri, 10 Jun 2011 19:49:29 +0000 (19:49 +0000)
committerPierre Racine <Pierre.Racine@sbf.ulaval.ca>
Fri, 10 Jun 2011 19:49:29 +0000 (19:49 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@7366 b70326c6-7e19-0410-871a-916f4a2858ee

raster/rt_core/rt_api.c
raster/test/regress/rt_pixelvalue.sql
raster/test/regress/rt_pixelvalue_expected

index 81ebeb06839958cee434b26a016f1a2fc5fd4c9f..72629f8824ac16c045d0935b26a7ca0aa12c6d89 100644 (file)
@@ -1291,7 +1291,7 @@ rt_band_get_pixel(rt_band band, uint16_t x, uint16_t y, double *result) {
     pixtype = band->pixtype;
 
     if (x >= band->width || y >= band->height) {
-        rterror("Attempting to get pixel value with out of range raster coordinates");
+        rtwarn("Attempting to get pixel value with out of range raster coordinates");
         return -1;
     }
 
@@ -1657,7 +1657,7 @@ rt_band_get_summary_stats(rt_band band, int exclude_nodata_value, double sample,
        }
 
        RASTER_DEBUGF(3, "sampling %d of %d available pixels w/ %d per set"
-               , sample_size, (band->width * band->height), sample_per); 
+               , sample_size, (band->width * band->height), sample_per);
 
        if (inc_vals) {
                values = rtalloc(sizeof(double) * sample_size);
@@ -1764,7 +1764,7 @@ rt_band_get_summary_stats(rt_band band, int exclude_nodata_value, double sample,
                }
        }
 
-       RASTER_DEBUG(3, "sampling complete"); 
+       RASTER_DEBUG(3, "sampling complete");
 
        if (k > 0) {
                if (inc_vals) {
@@ -1858,7 +1858,7 @@ rt_band_get_histogram(rt_bandstats stats,
        double elapsed = 0;
 #endif
 
-       RASTER_DEBUG(3, "starting"); 
+       RASTER_DEBUG(3, "starting");
 #if POSTGIS_DEBUG_LEVEL > 0
        start = clock();
 #endif
@@ -1933,7 +1933,7 @@ rt_band_get_histogram(rt_bandstats stats,
        if (fabs(qmax - qmin) < FLT_EPSILON)
                bin_count = 1;
 
-       RASTER_DEBUGF(3, "bin_count = %d", bin_count); 
+       RASTER_DEBUGF(3, "bin_count = %d", bin_count);
 
        /* bin count = 1, all values are in one bin */
        if (bin_count < 2) {
@@ -2104,7 +2104,7 @@ struct rt_quantile_t {
 /**
  * Compute the default set of or requested quantiles for a set of data
  * the quantile formula used is same as Excel and R default method
- * 
+ *
  * @param stats: a populated stats struct for processing
  * @param quantiles: the quantiles to be computed
  * @param quantiles_count: the number of quantiles to be computed
@@ -2126,7 +2126,7 @@ rt_band_get_quantiles(rt_bandstats stats,
        double elapsed = 0;
 #endif
 
-       RASTER_DEBUG(3, "starting"); 
+       RASTER_DEBUG(3, "starting");
 #if POSTGIS_DEBUG_LEVEL > 0
        start = clock();
 #endif
@@ -2492,7 +2492,7 @@ struct rt_reclassexpr_t {
 
 /**
  * Returns new band with values reclassified
- * 
+ *
  * @param srcband : the band who's values will be reclassified
  * @param pixtype : pixel type of the new band
  * @param hasnodata : indicates if the band has a nodata value
@@ -3476,7 +3476,7 @@ rt_raster_dump_as_wktpolygons(rt_raster raster, int nband, int * pnElements)
     /**
      * We don't need a raster mask band. Each band has a nodata value.
      **/
-#if GDALFPOLYGONIZE == 1 
+#if GDALFPOLYGONIZE == 1
     GDALFPolygonize(gdal_band, NULL, hLayer, iPixVal, NULL, NULL, NULL);
 #else
     GDALPolygonize(gdal_band, NULL, hLayer, iPixVal, NULL, NULL, NULL);
@@ -5164,7 +5164,7 @@ rt_raster_from_band(rt_raster raster, uint32_t *bandNums, int count) {
 
 /**
  * Replace band at provided index with new band
- * 
+ *
  * @param raster: raster of band to be replaced
  * @param band : new band to add to raster
  * @param index : index of band to replace (1-based)
@@ -5510,7 +5510,7 @@ rt_raster_to_gdal_mem(rt_raster raster, char *srs,
                allocBandNums = 1;
                for (i = 0; i < count; i++) bandNums[i] = i;
        }
-       
+
        /* add band(s) */
        for (i = 0; i < count; i++) {
                rtband = rt_raster_get_band(raster, bandNums[i]);
@@ -5806,7 +5806,7 @@ rt_raster_from_gdal_dataset(GDALDatasetH ds) {
                                for (x = 0; x < width; x++) {
                                        value = values[x + y * width];
 
-                                       RASTER_DEBUGF(5, "(x, y, value) = (%d, %d, %f)", x, y, value); 
+                                       RASTER_DEBUGF(5, "(x, y, value) = (%d, %d, %f)", x, y, value);
 
                                        if (rt_band_set_pixel(band, x, y, value) < 0) {
                                                rterror("rt_raster_from_gdal_dataset: Unable to save data from transformed raster\n");
@@ -6011,7 +6011,7 @@ rt_raster_transform(rt_raster raster, char *src_srs, char *dst_srs,
        GDALClose(src_ds);
        GDALDeregisterDriver(src_drv);
        GDALDestroyDriver(src_drv);
-       
+
        if (NULL == rast) {
                rterror("rt_raster_transform: Unable to transform raster\n");
                return NULL;
index deabb35b5f7dd98f7e0ad41a192e660463baae10..a892e0575692ed717597b1c2041afb7fff039a2a 100644 (file)
@@ -47,6 +47,10 @@ SELECT 'test 1.9', id
     FROM rt_band_properties_test
     WHERE st_value(st_setbandnodatavalue(rast, b1val), 1, 1, 1, FALSE) != b1val;
 
+-- Make sure we return only a warning when getting vlue with out of range pixel coordinates
+SELECT 'test 1.10', id
+    FROM rt_band_properties_test
+    WHERE NOT st_value(rast, -1, -1) IS NULL;
 
 -----------------------------------------------------------------------
 -- Test 2 - st_value(rast raster, band integer, pt geometry)
index 4a3857bf68c1d7e3595e7982e49486faed55078f..2a9de971df08d30b63b14e29f4421755c3d611bd 100644 (file)
@@ -1,3 +1,7 @@
+NOTICE:  Attempting to get pixel value with out of range raster coordinates
+NOTICE:  Attempting to get pixel value with out of range raster coordinates
+NOTICE:  Attempting to get pixel value with out of range raster coordinates
+NOTICE:  Attempting to get pixel value with out of range raster coordinates
 NOTICE:  Raster do not have a nodata value defined. Set band nodata value first. Nodata value not set. Returning original raster
 NOTICE:  Raster do not have a nodata value defined. Set band nodata value first. Nodata value not set. Returning original raster
 NOTICE:  Raster do not have a nodata value defined. Set band nodata value first. Nodata value not set. Returning original raster