]> granicus.if.org Git - postgis/commitdiff
Trailing spaces removed from raster files.
authorJorge Arévalo <jorge.arevalo at deimos-space.com>
Fri, 6 May 2011 14:29:04 +0000 (14:29 +0000)
committerJorge Arévalo <jorge.arevalo at deimos-space.com>
Fri, 6 May 2011 14:29:04 +0000 (14:29 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@7107 b70326c6-7e19-0410-871a-916f4a2858ee

raster/rt_core/rt_api.c
raster/rt_core/rt_api.h
raster/rt_pg/rt_pg.c
raster/rt_pg/rt_pg.h
raster/test/core/testapi.c
raster/test/core/testwkb.c

index 845d1bece816d7abf7d2aaa6d253573e2e5b45d1..2c06efee69ad01b90c715fc0d6d3df4aa1c95219 100644 (file)
@@ -179,17 +179,17 @@ default_rt_error_handler(const char *fmt, va_list ap) {
 
     va_end(ap);
 }
-       
+
 void
 default_rt_warning_handler(const char *fmt, va_list ap) {
-       
+
     static const char *label = "WARNING: ";
     char newfmt[1024] = {0};
     snprintf(newfmt, 1024, "%s%s\n", label, fmt);
     newfmt[1023] = '\0';
-       
+
     vprintf(newfmt, ap);
-       
+
     va_end(ap);
 }
 
@@ -201,7 +201,7 @@ default_rt_info_handler(const char *fmt, va_list ap) {
     char newfmt[1024] = {0};
     snprintf(newfmt, 1024, "%s%s\n", label, fmt);
     newfmt[1023] = '\0';
-       
+
     vprintf(newfmt, ap);
 
     va_end(ap);
@@ -246,7 +246,7 @@ rt_install_default_allocators(void)
     ctx_t.dealloc = default_rt_deallocator;
     ctx_t.err = default_rt_error_handler;
     ctx_t.info = default_rt_info_handler;
-    ctx_t.warn = default_rt_warning_handler;    
+    ctx_t.warn = default_rt_warning_handler;
 }
 
 
@@ -256,7 +256,7 @@ rt_install_default_allocators(void)
  */
 void
 rt_set_handlers(rt_allocator allocator, rt_reallocator reallocator,
-        rt_deallocator deallocator, rt_message_handler error_handler, 
+        rt_deallocator deallocator, rt_message_handler error_handler,
         rt_message_handler info_handler, rt_message_handler warning_handler) {
 
     ctx_t.alloc = allocator;
@@ -269,13 +269,13 @@ rt_set_handlers(rt_allocator allocator, rt_reallocator reallocator,
 }
 
 
-       
+
 /**
  * Initialisation allocators
  *
- * These are used the first time any of the allocators are called to enable 
- * executables/libraries that link into raster to be able to set up their own 
- * allocators. This is mainly useful for older PostgreSQL versions that don't 
+ * These are used the first time any of the allocators are called to enable
+ * executables/libraries that link into raster to be able to set up their own
+ * allocators. This is mainly useful for older PostgreSQL versions that don't
  * have functions that are called upon startup.
  **/
 void *
@@ -285,16 +285,16 @@ init_rt_allocator(size_t size)
 
     return ctx_t.alloc(size);
 }
-       
+
 void
 init_rt_deallocator(void *mem)
 {
     rt_init_allocators();
-       
+
     ctx_t.dealloc(mem);
 }
 
-       
+
 void *
 init_rt_reallocator(void *mem, size_t size)
 {
@@ -302,24 +302,24 @@ init_rt_reallocator(void *mem, size_t size)
 
     return ctx_t.realloc(mem, size);
 }
-       
+
 void
 init_rt_inforeporter(const char *fmt, va_list ap)
 {
     rt_init_allocators();
-       
+
     (*ctx_t.info)(fmt, ap);
 }
-       
+
 void
 init_rt_warnreporter(const char *fmt, va_list ap)
 {
     rt_init_allocators();
-       
+
     (*ctx_t.warn)(fmt, ap);
 }
 
-    
+
 void
 init_rt_errorreporter(const char *fmt, va_list ap)
 {
@@ -332,10 +332,10 @@ init_rt_errorreporter(const char *fmt, va_list ap)
 
 
 /**
- * Raster core memory management functions. 
- * 
+ * Raster core memory management functions.
+ *
  * They use the functions defined by the caller.
- */ 
+ */
 void *
 rtalloc(size_t size) {
     void * mem = ctx_t.alloc(size);
@@ -412,7 +412,7 @@ rt_util_display_dbl_trunc_warning(double initialvalue,
                                   rt_pixtype pixtype) {
     int result = 0;
 
-    
+
 
     switch (pixtype)
     {
@@ -488,10 +488,10 @@ d_binary_to_hex(const uint8_t * const raw, uint32_t size, uint32_t *hexsize) {
     char* hex = NULL;
     uint32_t i = 0;
 
-    
+
     assert(NULL != raw);
     assert(NULL != hexsize);
-    
+
 
     *hexsize = size * 2; /* hex is 2 times bytes */
     hex = (char*) rtalloc((*hexsize) + 1);
@@ -515,10 +515,10 @@ d_print_binary_hex(const char* msg, const uint8_t * const raw, uint32_t size) {
     char* hex = NULL;
     uint32_t hexsize = 0;
 
-    
+
     assert(NULL != msg);
     assert(NULL != raw);
-    
+
 
     hex = d_binary_to_hex(raw, size, &hexsize);
     if (NULL != hex) {
@@ -551,8 +551,8 @@ d_binptr_to_pos(const uint8_t * const ptr, const uint8_t * const end, size_t siz
 int
 rt_pixtype_size(rt_pixtype pixtype) {
     int pixbytes = -1;
-    
-    
+
+
 
     switch (pixtype) {
         case PT_1BB:
@@ -589,14 +589,14 @@ rt_pixtype_size(rt_pixtype pixtype) {
 
 int
 rt_pixtype_alignment(rt_pixtype pixtype) {
-    
+
     return rt_pixtype_size(pixtype);
 }
 
 rt_pixtype
 rt_pixtype_index_from_name(const char* pixname) {
     assert(pixname && strlen(pixname) > 0);
-    
+
 
     if (strcmp(pixname, "1BB") == 0)
         return PT_1BB;
@@ -625,8 +625,8 @@ rt_pixtype_index_from_name(const char* pixname) {
 
 const char*
 rt_pixtype_name(rt_pixtype pixtype) {
-    
-    
+
+
 
     switch (pixtype) {
         case PT_1BB:
@@ -688,7 +688,7 @@ rt_band_new_inline(uint16_t width, uint16_t height,
         uint8_t* data) {
     rt_band band = NULL;
 
-    
+
     assert(NULL != data);
 
     band = rtalloc(sizeof (struct rt_band_t));
@@ -719,8 +719,8 @@ rt_band_new_offline(uint16_t width, uint16_t height,
         rt_pixtype pixtype, uint32_t hasnodata, double nodataval,
         uint8_t bandNum, const char* path) {
     rt_band band = NULL;
-    
+
+
     assert(NULL != path);
 
     band = rtalloc(sizeof (struct rt_band_t));
@@ -757,17 +757,17 @@ rt_band_new_offline(uint16_t width, uint16_t height,
 
 int
 rt_band_is_offline(rt_band band) {
-    
+
     assert(NULL != band);
-    
+
 
     return band->offline;
 }
 
 void
 rt_band_destroy(rt_band band) {
-    
-    
+
+
     RASTER_DEBUGF(3, "Destroying rt_band @ %p", band);
 
     /* band->data content is externally owned */
@@ -779,9 +779,9 @@ rt_band_destroy(rt_band band) {
 
 const char*
 rt_band_get_ext_path(rt_band band) {
-    
+
     assert(NULL != band);
-    
+
 
     if (!band->offline) {
         RASTER_DEBUG(3, "rt_band_get_ext_path: non-offline band doesn't have "
@@ -793,9 +793,9 @@ rt_band_get_ext_path(rt_band band) {
 
 uint8_t
 rt_band_get_ext_band_num(rt_band band) {
-    
+
     assert(NULL != band);
-    
+
 
     if (!band->offline) {
         RASTER_DEBUG(3, "rt_band_get_ext_path: non-offline band doesn't have "
@@ -807,9 +807,9 @@ rt_band_get_ext_band_num(rt_band band) {
 
 void *
 rt_band_get_data(rt_band band) {
-    
+
     assert(NULL != band);
-    
+
 
     if (band->offline) {
         RASTER_DEBUG(3, "rt_band_get_data: "
@@ -821,27 +821,27 @@ rt_band_get_data(rt_band band) {
 
 rt_pixtype
 rt_band_get_pixtype(rt_band band) {
-    
+
     assert(NULL != band);
-    
+
 
     return band->pixtype;
 }
 
 uint16_t
 rt_band_get_width(rt_band band) {
-    
+
     assert(NULL != band);
-    
+
 
     return band->width;
 }
 
 uint16_t
 rt_band_get_height(rt_band band) {
-    
+
     assert(NULL != band);
-    
+
 
     return band->height;
 }
@@ -866,7 +866,7 @@ setBits(char* ch, double val, int bits, int bitOffset) {
     char mask = 0xFF >> (8 - bits);
     char ival = val;
 
-    
+
     assert(8 - bitOffset >= bits);
 
     RASTER_DEBUGF(4, "ival:%d bits:%d mask:%hhx bitoffset:%d\n",
@@ -906,34 +906,34 @@ setBits(char* ch, double val, int bits, int bitOffset) {
 
 int
 rt_band_get_hasnodata_flag(rt_band band) {
-    
+
     assert(NULL != band);
-    
+
 
     return band->hasnodata;
 }
 
 void
 rt_band_set_hasnodata_flag(rt_band band, int flag) {
-    
+
     assert(NULL != band);
-    
+
 
     band->hasnodata = (flag) ? 1 : 0;
 }
 
 void
 rt_band_set_isnodata_flag(rt_band band, int flag) {
-    
+
     assert(NULL != band);
-    
+
 
     band->isnodata = (flag) ? 1 : 0;
 }
 
 int
 rt_band_get_isnodata_flag(rt_band band) {
-    
+
     assert(NULL != band);
 
     return band->isnodata;
@@ -949,8 +949,8 @@ rt_band_set_nodata(rt_band band, double val) {
     float checkvalfloat = 0;
     double checkvaldouble = 0;
 
-    
-    
+
+
     assert(NULL != band);
 
     pixtype = band->pixtype;
@@ -1073,8 +1073,8 @@ rt_band_set_pixel(rt_band band, uint16_t x, uint16_t y,
 
     double checkval = 0;
 
-    
-    
+
+
     assert(NULL != band);
 
     pixtype = band->pixtype;
@@ -1205,8 +1205,8 @@ rt_band_get_pixel(rt_band band, uint16_t x, uint16_t y, double *result) {
     uint8_t* data = NULL;
     uint32_t offset = 0;
 
-    
-    
+
+
     assert(NULL != band);
 
     pixtype = band->pixtype;
@@ -1322,8 +1322,8 @@ rt_band_get_pixel(rt_band band, uint16_t x, uint16_t y, double *result) {
 
 double
 rt_band_get_nodata(rt_band band) {
-    
-    
+
+
     assert(NULL != band);
 
     if (!band->hasnodata)
@@ -1337,16 +1337,16 @@ double
 rt_band_get_min_value(rt_band band) {
     rt_pixtype pixtype = PT_END;
 
-    
-    
+
+
     assert(NULL != band);
 
     pixtype = band->pixtype;
 
     switch (pixtype) {
-        case PT_1BB: 
-        case PT_2BUI: 
-        case PT_4BUI: 
+        case PT_1BB:
+        case PT_2BUI:
+        case PT_4BUI:
         case PT_8BUI:
         {
             return (double)CHAR_MIN;
@@ -1355,12 +1355,12 @@ rt_band_get_min_value(rt_band band) {
         {
             return (double)SCHAR_MIN;
         }
-        case PT_16BSI: 
+        case PT_16BSI:
         case PT_16BUI:
         {
             return (double)SHRT_MIN;
         }
-        case PT_32BSI: 
+        case PT_32BSI:
         case PT_32BUI:
         {
             return (double)INT_MIN;
@@ -1389,8 +1389,8 @@ rt_band_check_is_nodata(rt_band band)
     double pxValue = band->nodataval;
     double dEpsilon = 0.0;
 
-    
-    
+
+
     assert(NULL != band);
 
     /* Check if band has nodata value */
@@ -1488,8 +1488,8 @@ rt_raster
 rt_raster_new(uint16_t width, uint16_t height) {
     rt_raster ret = NULL;
 
-    
-    
+
+
     ret = (rt_raster) rtalloc(sizeof (struct rt_raster_t));
     if (!ret) {
         rterror("rt_raster_new: Out of virtual memory creating an rt_raster");
@@ -1519,8 +1519,8 @@ rt_raster_new(uint16_t width, uint16_t height) {
 
 void
 rt_raster_destroy(rt_raster raster) {
-    
-    
+
+
     RASTER_DEBUGF(3, "Destroying rt_raster @ %p", raster);
 
     if (raster->bands) {
@@ -1531,7 +1531,7 @@ rt_raster_destroy(rt_raster raster) {
 
 uint16_t
 rt_raster_get_width(rt_raster raster) {
-    
+
     assert(NULL != raster);
 
     return raster->width;
@@ -1539,7 +1539,7 @@ rt_raster_get_width(rt_raster raster) {
 
 uint16_t
 rt_raster_get_height(rt_raster raster) {
-    
+
     assert(NULL != raster);
 
     return raster->height;
@@ -1548,8 +1548,8 @@ rt_raster_get_height(rt_raster raster) {
 void
 rt_raster_set_scale(rt_raster raster,
         double scaleX, double scaleY) {
-    
-    
+
+
     assert(NULL != raster);
 
     raster->scaleX = scaleX;
@@ -1558,8 +1558,8 @@ rt_raster_set_scale(rt_raster raster,
 
 double
 rt_raster_get_x_scale(rt_raster raster) {
-    
-    
+
+
     assert(NULL != raster);
 
     return raster->scaleX;
@@ -1567,8 +1567,8 @@ rt_raster_get_x_scale(rt_raster raster) {
 
 double
 rt_raster_get_y_scale(rt_raster raster) {
-    
-    
+
+
     assert(NULL != raster);
 
     return raster->scaleY;
@@ -1577,8 +1577,8 @@ rt_raster_get_y_scale(rt_raster raster) {
 void
 rt_raster_set_skews(rt_raster raster,
         double skewX, double skewY) {
-    
-    
+
+
     assert(NULL != raster);
 
     raster->skewX = skewX;
@@ -1587,8 +1587,8 @@ rt_raster_set_skews(rt_raster raster,
 
 double
 rt_raster_get_x_skew(rt_raster raster) {
-    
-    
+
+
     assert(NULL != raster);
 
     return raster->skewX;
@@ -1596,8 +1596,8 @@ rt_raster_get_x_skew(rt_raster raster) {
 
 double
 rt_raster_get_y_skew(rt_raster raster) {
-    
-    
+
+
     assert(NULL != raster);
 
     return raster->skewY;
@@ -1605,8 +1605,8 @@ rt_raster_get_y_skew(rt_raster raster) {
 
 void
 rt_raster_set_offsets(rt_raster raster, double x, double y) {
-    
-    
+
+
     assert(NULL != raster);
 
     raster->ipX = x;
@@ -1615,8 +1615,8 @@ rt_raster_set_offsets(rt_raster raster, double x, double y) {
 
 double
 rt_raster_get_x_offset(rt_raster raster) {
-    
-    
+
+
     assert(NULL != raster);
 
     return raster->ipX;
@@ -1624,8 +1624,8 @@ rt_raster_get_x_offset(rt_raster raster) {
 
 double
 rt_raster_get_y_offset(rt_raster raster) {
-    
-    
+
+
     assert(NULL != raster);
 
     return raster->ipY;
@@ -1633,8 +1633,8 @@ rt_raster_get_y_offset(rt_raster raster) {
 
 int32_t
 rt_raster_get_srid(rt_raster raster) {
-    
-    
+
+
     assert(NULL != raster);
 
     return raster->srid;
@@ -1642,8 +1642,8 @@ rt_raster_get_srid(rt_raster raster) {
 
 void
 rt_raster_set_srid(rt_raster raster, int32_t srid) {
-    
-    
+
+
     assert(NULL != raster);
 
     raster->srid = srid;
@@ -1651,8 +1651,8 @@ rt_raster_set_srid(rt_raster raster, int32_t srid) {
 
 int
 rt_raster_get_num_bands(rt_raster raster) {
-    
-    
+
+
     assert(NULL != raster);
 
     return raster->numBands;
@@ -1660,8 +1660,8 @@ rt_raster_get_num_bands(rt_raster raster) {
 
 rt_band
 rt_raster_get_band(rt_raster raster, int n) {
-    
-    
+
+
     assert(NULL != raster);
 
     if (n >= raster->numBands || n < 0) return 0;
@@ -1675,8 +1675,8 @@ rt_raster_add_band(rt_raster raster, rt_band band, int index) {
     rt_band tmpband = NULL;
     uint16_t i = 0;
 
-    
-    
+
+
     assert(NULL != raster);
 
     RASTER_DEBUGF(3, "Adding band %p to raster %p", band, raster);
@@ -1748,8 +1748,8 @@ rt_raster_generate_new_band(rt_raster raster, rt_pixtype pixtype,
     double checkvaldouble = 0;
     float checkvalfloat = 0;
     int i;
-    
-    
+
+
     assert(NULL != raster);
 
     /* Make sure index is in a valid range */
@@ -1910,8 +1910,8 @@ void
 rt_raster_cell_to_geopoint(rt_raster raster,
         double x, double y,
         double* x1, double* y1) {
-    
-    
+
+
     assert(NULL != raster);
     assert(NULL != x1);
     assert(NULL != y1);
@@ -1965,8 +1965,8 @@ rt_raster_dump_as_wktpolygons(rt_raster raster, int nband,
     double dBandNoData = 0.0;
 
     /* Checkings */
-    
-    
+
+
     assert(NULL != raster);
     assert(nband > 0 && nband <= rt_raster_get_num_bands(raster));
 
@@ -2269,7 +2269,7 @@ rt_raster_dump_as_wktpolygons(rt_raster raster, int nband,
         GDALClose(memdataset);
         GDALDeregisterDriver(gdal_drv);
         GDALDestroyDriver(gdal_drv);
-       
+
         OGR_Fld_Destroy(hFldDfn);
         OGR_DS_DeleteLayer(memdatasource, 0);
         OGRReleaseDataSource(memdatasource);
@@ -2302,7 +2302,7 @@ rt_raster_dump_as_wktpolygons(rt_raster raster, int nband,
        RASTER_DEBUGF(4, "Feature %d, Polygon: %s", j, pols[j].geom);
        RASTER_DEBUGF(4, "Feature %d, value: %f", j, pols[j].val);
        RASTER_DEBUGF(4, "Feature %d, srid: %d", j, pols[j].srid);
-       
+
                /**
          * We can't use deallocator from rt_context, because it comes from
          * postgresql backend, that uses pfree. This function needs a
@@ -2312,7 +2312,7 @@ rt_raster_dump_as_wktpolygons(rt_raster raster, int nband,
          //rtdealloc(pszSrcText);
         free(pszSrcText);
         pszSrcText = NULL;
-        
+
         OGR_F_Destroy(hFeature);
     }
 
@@ -2341,8 +2341,8 @@ rt_raster_get_convex_hull(rt_raster raster) {
     LWPOLY* ret = NULL;
     POINT4D p4d;
 
-    
-    
+
+
     assert(NULL != raster);
 
     RASTER_DEBUGF(3, "rt_raster_get_convex_hull: raster is %dx%d",
@@ -2700,8 +2700,8 @@ rt_band_from_wkb(uint16_t width, uint16_t height,
     unsigned long sz = 0;
     uint32_t v = 0;
 
-    
-    
+
+
     assert(NULL != ptr);
     assert(NULL != end);
 
@@ -2940,8 +2940,8 @@ rt_raster_from_wkb(const uint8_t* wkb, uint32_t wkbsize) {
     uint16_t version = 0;
     uint16_t i = 0;
 
-    
-    
+
+
     assert(NULL != ptr);
 
     /* Check that wkbsize is >= sizeof(rt_raster_serialized) */
@@ -3066,8 +3066,8 @@ rt_raster_from_hexwkb(const char* hexwkb,
     uint32_t wkbsize = 0;
     uint32_t i = 0;
 
-    
-    
+
+
     assert(NULL != hexwkb);
 
     RASTER_DEBUGF(3, "rt_raster_from_hexwkb: input wkb: %s", hexwkb);
@@ -3100,8 +3100,8 @@ rt_raster_wkb_size(rt_raster raster) {
     uint32_t size = RT_WKB_HDR_SZ;
     uint16_t i = 0;
 
-    
-    
+
+
     assert(NULL != raster);
 
     RASTER_DEBUGF(3, "rt_raster_wkb_size: computing size for %d bands",
@@ -3151,8 +3151,8 @@ rt_raster_to_wkb(rt_raster raster, uint32_t *wkbsize) {
     uint16_t i = 0;
     uint8_t littleEndian = isMachineLittleEndian();
 
-    
-    
+
+
     assert(NULL != raster);
     assert(NULL != wkbsize);
 
@@ -3324,8 +3324,8 @@ rt_raster_to_hexwkb(rt_raster raster, uint32_t *hexwkbsize) {
     uint32_t i = 0;
     uint32_t wkbsize = 0;
 
-    
-    
+
+
     assert(NULL != raster);
     assert(NULL != hexwkbsize);
 
@@ -3362,8 +3362,8 @@ rt_raster_serialized_size(rt_raster raster) {
     uint32_t size = sizeof (struct rt_raster_serialized_t);
     uint16_t i = 0;
 
-    
-    
+
+
     assert(NULL != raster);
 
     RASTER_DEBUGF(3, "Serialized size with just header:%d - now adding size of %d bands",
@@ -3418,7 +3418,7 @@ rt_raster_serialize(rt_raster raster) {
     uint8_t* ptr = NULL;
     uint16_t i = 0;
 
-    
+
     assert(NULL != raster);
 
     ret = (uint8_t*) rtalloc(size);
@@ -3612,8 +3612,8 @@ rt_raster_deserialize(void* serialized) {
     uint16_t i = 0;
     uint8_t littleEndian = isMachineLittleEndian();
 
-    
-    
+
+
     assert(NULL != serialized);
 
     RASTER_DEBUG(2, "rt_raster_deserialize: Entering...");
@@ -3774,8 +3774,7 @@ rt_raster_deserialize(void* serialized) {
 #if POSTGIS_DEBUG_LEVEL > 0
         const uint8_t *padbeg = ptr;
 #endif
-        while (0 != ((ptr - beg) % 8))
- {
+        while (0 != ((ptr - beg) % 8)){
             ++ptr;
         }
 
@@ -3789,14 +3788,14 @@ rt_raster_deserialize(void* serialized) {
 }
 
 int rt_raster_is_empty(rt_raster raster) {
-    
-    
+
+
     return (NULL == raster || raster->height <= 0 || raster->width <= 0);
 }
 
 int rt_raster_has_no_band(rt_raster raster, int nband) {
-    
-    
+
+
     return (NULL == raster || raster->numBands < nband);
 }
 
@@ -3804,8 +3803,8 @@ int32_t rt_raster_copy_band(rt_raster torast,
         rt_raster fromrast, int fromindex, int toindex)
 {
     rt_band newband = NULL;
-    
-    
+
+
     assert(NULL != torast);
     assert(NULL != fromrast);
 
index 6a30db9fa703ae4b2421e9d2f21182ca11202784..0f33e882caa28543d0a3ad7fc2171bb4dc7f974a 100644 (file)
@@ -99,7 +99,7 @@
  * This library is the generic raster handling section of PostGIS. The raster
  * objects, constructors, destructors, and a set of spatial processing functions
  * are implemented here.
- * 
+ *
  * The library is designed for use in non-PostGIS applications if necessary. The
  * units tests at test/core (and the future loader/dumper programs) are examples
  * of non-PostGIS applications using rt_core.
 typedef struct rt_raster_t* rt_raster;
 typedef struct rt_band_t* rt_band;
 typedef struct rt_geomval_t* rt_geomval;
+
 /**
 * Global functions for memory/logging handlers.
 */
@@ -153,7 +153,7 @@ extern void rt_install_default_allocators(void);
 
 
 /**
- * Wrappers used for managing memory. They simply call the functions defined by 
+ * Wrappers used for managing memory. They simply call the functions defined by
  * the caller
  **/
 extern void* rtalloc(size_t size);
@@ -215,7 +215,7 @@ void default_rt_info_handler(const char * fmt, va_list ap);
 /*- memory context -------------------------------------------------------*/
 
 void rt_set_handlers(rt_allocator allocator, rt_reallocator reallocator,
-        rt_deallocator deallocator, rt_message_handler error_handler, 
+        rt_deallocator deallocator, rt_message_handler error_handler,
         rt_message_handler info_handler, rt_message_handler warning_handler);
 
 
index d37cfc8ca6338b2703ff04e206de23f2a5f81c0c..581a9ad4676e9ae5635c2cf1320bf7aefa422813 100644 (file)
@@ -65,14 +65,14 @@ static char *strtoupper(char *str);
 
 /***************************************************************
  * Some rules for returning NOTICE or ERROR...
- * 
+ *
  * Send an ERROR like:
  *
  * elog(ERROR, "RASTER_out: Could not deserialize raster");
- * 
+ *
  * only when:
  *
- * -something wrong happen with memory, 
+ * -something wrong happen with memory,
  * -a function got an invalid argument ('3BUI' as pixel type) so that no row can
  * be processed
  *
@@ -83,7 +83,7 @@ static char *strtoupper(char *str);
  * when arguments (e.g. x, y, band) are NULL or out of range so that some or
  * most rows can be processed anyway
  *
- * in this case, 
+ * in this case,
  * for SET functions or function normally returning a modified raster, return
  * the original raster
  * for GET functions, return NULL
@@ -181,7 +181,7 @@ Datum RASTER_copyband(PG_FUNCTION_ARGS);
 Datum RASTER_mapAlgebra(PG_FUNCTION_ARGS);
 
 
-/* Replace function taken from 
+/* Replace function taken from
  * http://ubuntuforums.org/showthread.php?s=aa6f015109fd7e4c7e30d2fd8b717497&t=141670&page=3
  */
 /* ---------------------------------------------------------------------------
@@ -298,7 +298,7 @@ Datum RASTER_in(PG_FUNCTION_ARGS)
 }
 
 /**
- * Given a RASTER structure, convert it to Hex and put it in a string 
+ * Given a RASTER structure, convert it to Hex and put it in a string
  */
 PG_FUNCTION_INFO_V1(RASTER_out);
 Datum RASTER_out(PG_FUNCTION_ARGS)
@@ -307,7 +307,7 @@ Datum RASTER_out(PG_FUNCTION_ARGS)
     rt_raster raster = NULL;
     uint32_t hexwkbsize = 0;
     char *hexwkb = NULL;
-    
+
     pgraster = (rt_pgraster *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 
     raster = rt_raster_deserialize(pgraster);
@@ -457,7 +457,7 @@ Datum RASTER_convex_hull(PG_FUNCTION_ARGS)
         SET_VARSIZE(pglwgeom, VARHDRSZ+sz);
 #endif
     }
-    
+
     /* Free raster and lwgeom memory */
     rt_raster_destroy(raster);
     lwfree(convexhull);
@@ -540,7 +540,7 @@ Datum RASTER_dumpAsWKTPolygons(PG_FUNCTION_ARGS)
         }
 
         POSTGIS_RT_DEBUGF(3, "raster dump, %d elements returned", nElements);
-        
+
         /* Store needed information */
         funcctx->user_fctx = geomval;
 
@@ -850,7 +850,7 @@ Datum RASTER_getNumBands(PG_FUNCTION_ARGS)
 
     rt_raster_destroy(raster);
     PG_FREE_IF_COPY(pgraster, 0);
-    
+
     PG_RETURN_INT32(num_bands);
 }
 
@@ -875,7 +875,7 @@ Datum RASTER_getXScale(PG_FUNCTION_ARGS)
 
     rt_raster_destroy(raster);
     PG_FREE_IF_COPY(pgraster, 0);
-    
+
     PG_RETURN_FLOAT8(xsize);
 }
 
@@ -901,7 +901,7 @@ Datum RASTER_getYScale(PG_FUNCTION_ARGS)
     rt_raster_destroy(raster);
 
     PG_FREE_IF_COPY(pgraster, 0);
-    
+
     PG_RETURN_FLOAT8(ysize);
 }
 
@@ -931,7 +931,7 @@ Datum RASTER_setScale(PG_FUNCTION_ARGS)
     SET_VARSIZE(pgraster, pgraster->size);
 
     rt_raster_destroy(raster);
-    
+
     PG_RETURN_POINTER(pgraster);
 }
 
@@ -988,7 +988,7 @@ Datum RASTER_getXSkew(PG_FUNCTION_ARGS)
     rt_raster_destroy(raster);
 
     PG_FREE_IF_COPY(pgraster, 0);
-    
+
     PG_RETURN_FLOAT8(xskew);
 }
 
@@ -1014,7 +1014,7 @@ Datum RASTER_getYSkew(PG_FUNCTION_ARGS)
     rt_raster_destroy(raster);
 
     PG_FREE_IF_COPY(pgraster, 0);
-    
+
     PG_RETURN_FLOAT8(yskew);
 }
 
@@ -1044,7 +1044,7 @@ Datum RASTER_setSkew(PG_FUNCTION_ARGS)
     SET_VARSIZE(pgraster, pgraster->size);
 
     rt_raster_destroy(raster);
-    
+
     PG_RETURN_POINTER(pgraster);
 }
 
@@ -1075,7 +1075,7 @@ Datum RASTER_setSkewXY(PG_FUNCTION_ARGS)
     SET_VARSIZE(pgraster, pgraster->size);
 
     rt_raster_destroy(raster);
-    
+
     PG_RETURN_POINTER(pgraster);
 }
 
@@ -1098,9 +1098,9 @@ Datum RASTER_getXUpperLeft(PG_FUNCTION_ARGS)
 
     xul = rt_raster_get_x_offset(raster);
 
-    rt_raster_destroy(raster);    
+    rt_raster_destroy(raster);
     PG_FREE_IF_COPY(pgraster, 0);
-    
+
     PG_RETURN_FLOAT8(xul);
 }
 
@@ -1351,7 +1351,7 @@ Datum RASTER_getBandNoDataValue(PG_FUNCTION_ARGS)
 
     rt_raster_destroy(raster);
     PG_FREE_IF_COPY(pgraster, 0);
-    
+
     PG_RETURN_FLOAT4(nodata);
 }
 
@@ -1578,7 +1578,7 @@ Datum RASTER_getBandPath(PG_FUNCTION_ARGS)
     }
 
     result = (text *) palloc(VARHDRSZ + strlen(bandpath) + 1);
-    
+
     SET_VARSIZE(result, VARHDRSZ + strlen(bandpath) + 1);
 
     strcpy((char *) VARDATA(result), bandpath);
@@ -1653,7 +1653,7 @@ Datum RASTER_getPixelValue(PG_FUNCTION_ARGS)
 
     rt_raster_destroy(raster);
     PG_FREE_IF_COPY(pgraster, 0);
+
     PG_RETURN_FLOAT8(pixvalue);
 }
 
@@ -1701,7 +1701,7 @@ Datum RASTER_setPixelValue(PG_FUNCTION_ARGS)
                 "Value not set. Returning original raster");
         skipset = TRUE;
     }
-    else 
+    else
         y = PG_GETARG_INT32(3);
 
     POSTGIS_RT_DEBUGF(3, "Pixel coordinates (%d, %d)", x, y);
@@ -2070,7 +2070,7 @@ Datum RASTER_mapAlgebra(PG_FUNCTION_ARGS)
 
 
     POSTGIS_RT_DEBUG(3, "RASTER_mapAlgebra: Creating new empty raster...");
-    
+
     /**
      * Create a new empty raster with having the same georeference as the
      * provided raster
@@ -2137,7 +2137,7 @@ Datum RASTER_mapAlgebra(PG_FUNCTION_ARGS)
         rt_raster_destroy(raster);
 
         pgraster = rt_raster_serialize(newrast);
-        if (NULL == pgraster) {        
+        if (NULL == pgraster) {
             elog(ERROR, "RASTER_mapAlgebra: Could not serialize raster. "
                     "Returning NULL");
             PG_RETURN_NULL();
@@ -2145,7 +2145,7 @@ Datum RASTER_mapAlgebra(PG_FUNCTION_ARGS)
 
         SET_VARSIZE(pgraster, pgraster->size);
         rt_raster_destroy(newrast);
-        
+
         PG_RETURN_POINTER(pgraster);
     }
 
@@ -2164,17 +2164,17 @@ Datum RASTER_mapAlgebra(PG_FUNCTION_ARGS)
         }
 
         SET_VARSIZE(pgraster, pgraster->size);
-        
+
         rt_raster_destroy(newrast);
-        
-        PG_RETURN_POINTER(pgraster); 
+
+        PG_RETURN_POINTER(pgraster);
     }
-    
+
      /*
      * Get NODATA value
      */
     POSTGIS_RT_DEBUG(3, "RASTER_mapAlgebra: Getting NODATA value for band...");
-    
+
     if (rt_band_get_hasnodata_flag(band)) {
         newnodatavalue = rt_band_get_nodata(band);
     }
@@ -2228,7 +2228,7 @@ Datum RASTER_mapAlgebra(PG_FUNCTION_ARGS)
         strncpy(initexpr, "SELECT ", strlen("SELECT "));
         strncpy(initexpr + strlen("SELECT "), strtoupper(expression),
             strlen(expression));
-        initexpr[len] = '\0';        
+        initexpr[len] = '\0';
 
         POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebra: Expression is %s", initexpr);
 
@@ -2237,7 +2237,7 @@ Datum RASTER_mapAlgebra(PG_FUNCTION_ARGS)
         //expression = NULL;
     }
 
-   
+
 
     /**
      * Optimization: If a nodatavalueexpr is provided, recompute the initial
@@ -2268,7 +2268,7 @@ Datum RASTER_mapAlgebra(PG_FUNCTION_ARGS)
         else {
             newexpr = initndvexpr;
         }
-            
+
         POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebra: initndvexpr = %s", newexpr);
 
         /* Eval the NODATA expression to get new NODATA. Connect with SPI manager
@@ -2291,7 +2291,7 @@ Datum RASTER_mapAlgebra(PG_FUNCTION_ARGS)
                 SPI_freetuptable(tuptable);
 
             /* Disconnect from SPI manager */
-            SPI_finish();        
+            SPI_finish();
 
             PG_RETURN_NULL();
         }
@@ -2314,11 +2314,11 @@ Datum RASTER_mapAlgebra(PG_FUNCTION_ARGS)
 
         POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebra: new initial value = %f",
             newinitialvalue);
-        
+
     }
 
-   
-    
+
+
     /**
      * Optimization: If the raster is only filled with nodata values return
      * right now a raster filled with the nodatavalueexpr
@@ -2378,7 +2378,7 @@ Datum RASTER_mapAlgebra(PG_FUNCTION_ARGS)
         pgraster = rt_raster_serialize(newrast);
         if (NULL == pgraster) {
             elog(ERROR, "RASTER_mapAlgebra: Could not serialize raster. "
-                    "Returning NULL");            
+                    "Returning NULL");
             PG_RETURN_NULL();
         }
 
@@ -2412,7 +2412,7 @@ Datum RASTER_mapAlgebra(PG_FUNCTION_ARGS)
             /* Free memory allocated out of the current context */
             if (SPI_tuptable)
                 SPI_freetuptable(tuptable);
-            
+
             SPI_finish();
             PG_RETURN_NULL();
         }
@@ -2467,7 +2467,7 @@ Datum RASTER_mapAlgebra(PG_FUNCTION_ARGS)
         if (NULL == pgraster) {
             elog(ERROR, "RASTER_mapAlgebra: Could not serialize raster. "
                     "Returning NULL");
-            
+
             PG_RETURN_NULL();
         }
 
@@ -2496,8 +2496,8 @@ Datum RASTER_mapAlgebra(PG_FUNCTION_ARGS)
         pgraster = rt_raster_serialize(newrast);
         if (NULL == pgraster) {
             elog(ERROR, "RASTER_mapAlgebra: Could not serialize raster. "
-                    "Returning NULL");            
-            
+                    "Returning NULL");
+
             PG_RETURN_NULL();
         }
 
@@ -2540,7 +2540,7 @@ Datum RASTER_mapAlgebra(PG_FUNCTION_ARGS)
 
                         ret = SPI_execute(newexpr, FALSE, 0);
 
-                        if (ret != SPI_OK_SELECT || SPI_tuptable == NULL || 
+                        if (ret != SPI_OK_SELECT || SPI_tuptable == NULL ||
                                 SPI_processed != 1) {
                             elog(ERROR, "RASTER_mapAlgebra: Invalid construction"
                                     " for expression. Aborting");
@@ -2548,7 +2548,7 @@ Datum RASTER_mapAlgebra(PG_FUNCTION_ARGS)
                             pfree(newexpr);
                             if (SPI_tuptable)
                                 SPI_freetuptable(tuptable);
-                            
+
                             SPI_finish();
                             PG_RETURN_NULL();
                         }
index 0166619386bbcd86b41aba74994aa4e472040355..9bffaedf21a5c29d5540f756e9b7a95f722bf205 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * $Id$
  *
  * WKTRaster - Raster Types for PostGIS
@@ -9,17 +9,17 @@
  * Copyright (C) 2009-2011 Pierre Racine <pierre.racine@sbf.ulaval.ca>
  * Copyright (C) 2009-2011 Mateusz Loskot <mateusz@loskot.net>
  * Copyright (C) 2008-2009 Sandro Santilli <strk@keybit.net>
- * 
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
@@ -37,7 +37,7 @@
 
 /* Debugging macros */
 #if POSTGIS_DEBUG_LEVEL > 0
+
 /* Display a simple message at NOTICE level */
 #define POSTGIS_RT_DEBUG(level, msg) \
     do { \
         if (POSTGIS_DEBUG_LEVEL >= level) \
         ereport(NOTICE, (errmsg_internal("[%s:%s:%d] " msg, __FILE__, __func__, __LINE__, __VA_ARGS__))); \
     } while (0);
+
 #else
 
 /* Empty prototype that can be optimised away by the compiler for non-debug builds */
 #define POSTGIS_RT_DEBUG(level, msg) \
     ((void) 0)
+
 /* Empty prototype that can be optimised away by the compiler for non-debug builds */
 #define POSTGIS_RT_DEBUGF(level, msg, ...) \
     ((void) 0)
index 26bbfe3abd6b8dcd67138e3379aafb0bca808a64..6c629db67cda396d998da84c03d153f7446e4b9b 100644 (file)
@@ -57,11 +57,11 @@ fillRasterToPolygonize(int hasnodata, double nodatavalue)
     uint16_t width = 2;
     uint16_t height = 2;
     */
-    
+
     /* Second test raster */
     uint16_t width = 9;
     uint16_t height = 9;
-    
+
     /* Third test raster */
     /*
     uint16_t width = 5;
@@ -69,7 +69,7 @@ fillRasterToPolygonize(int hasnodata, double nodatavalue)
     */
 
     rt_raster raster = rt_raster_new(width, height);
-    
+
     /* Fill raster. Option 1: simple raster */
     /*
     rt_band band = addBand(raster, PT_32BSI, 0, 0);
@@ -79,11 +79,11 @@ fillRasterToPolygonize(int hasnodata, double nodatavalue)
     rt_band_set_pixel(band, 1, 0, 1);
     rt_band_set_pixel(band, 1, 1, 1);
     */
-    
 
-    /* Fill raster. Option 2: 9x9, 1 band */    
+
+    /* Fill raster. Option 2: 9x9, 1 band */
     rt_band band = addBand(raster, PT_32BUI, hasnodata, nodatavalue);
-    
+
     {
         int x, y;
         for (x = 0; x < rt_band_get_width(band); ++x)
@@ -119,13 +119,13 @@ fillRasterToPolygonize(int hasnodata, double nodatavalue)
     rt_band_set_pixel(band, 3, 7, 1);
     rt_band_set_pixel(band, 4, 7, 1);
     rt_band_set_pixel(band, 5, 7, 2);
-    
+
 
 
     /* Fill raster. Option 3: 5x5, 1 band */
     /*
     rt_band band = addBand(raster, PT_8BUI, 1, 255);
-    
+
     rt_band_set_pixel(band, 0, 0, 253);
     rt_band_set_pixel(band, 1, 0, 254);
     rt_band_set_pixel(band, 2, 0, 253);
@@ -152,9 +152,9 @@ fillRasterToPolygonize(int hasnodata, double nodatavalue)
     rt_band_set_pixel(band, 3, 4, 254);
     rt_band_set_pixel(band, 4, 4, 254);
     */
-     
+
     rt_raster_add_band(raster, band, 100);
-    
+
     return raster;
 }
 
@@ -296,17 +296,17 @@ static void testBand4BUI(rt_band band)
     CHECK(!failure);
     CHECK_EQUALS(val, 2);
 
-    failure = rt_band_set_nodata(band, 4); 
+    failure = rt_band_set_nodata(band, 4);
     val = rt_band_get_nodata(band);
     CHECK(!failure);
     CHECK_EQUALS(val, 4);
 
-    failure = rt_band_set_nodata(band, 8); 
+    failure = rt_band_set_nodata(band, 8);
     val = rt_band_get_nodata(band);
     CHECK(!failure);
     CHECK_EQUALS(val, 8);
 
-    failure = rt_band_set_nodata(band, 15); 
+    failure = rt_band_set_nodata(band, 15);
     val = rt_band_get_nodata(band);
     CHECK(!failure);
     CHECK_EQUALS(val, 15);
@@ -323,7 +323,7 @@ static void testBand4BUI(rt_band band)
 
     {
         int x, y;
-        
+
         for (x=0; x<rt_band_get_width(band); ++x)
         {
             for (y=0; y<rt_band_get_height(band); ++y)
@@ -360,7 +360,7 @@ static void testBand4BUI(rt_band band)
 static void testBand8BUI(rt_band band)
 {
     double val;
-    int failure; 
+    int failure;
 
     failure = rt_band_set_nodata(band, 1);
     CHECK(!failure);
@@ -377,27 +377,27 @@ static void testBand8BUI(rt_band band)
     val = rt_band_get_nodata(band);
     CHECK_EQUALS(val, 2);
 
-    failure = rt_band_set_nodata(band, 4); 
+    failure = rt_band_set_nodata(band, 4);
     CHECK(!failure);
     val = rt_band_get_nodata(band);
     CHECK_EQUALS(val, 4);
 
-    failure = rt_band_set_nodata(band, 8); 
+    failure = rt_band_set_nodata(band, 8);
     CHECK(!failure);
     val = rt_band_get_nodata(band);
     CHECK_EQUALS(val, 8);
 
-    failure = rt_band_set_nodata(band, 15); 
+    failure = rt_band_set_nodata(band, 15);
     CHECK(!failure);
     val = rt_band_get_nodata(band);
     CHECK_EQUALS(val, 15);
 
-    failure = rt_band_set_nodata(band, 31);  
+    failure = rt_band_set_nodata(band, 31);
     CHECK(!failure);
     val = rt_band_get_nodata(band);
     CHECK_EQUALS(val, 31);
 
-    failure = rt_band_set_nodata(band, 255);  
+    failure = rt_band_set_nodata(band, 255);
     CHECK(!failure);
     val = rt_band_get_nodata(band);
     CHECK_EQUALS(val, 255);
@@ -414,13 +414,13 @@ static void testBand8BUI(rt_band band)
         {
             for (y=0; y<rt_band_get_height(band); ++y)
             {
-                failure = rt_band_set_pixel(band, x, y, 31);  
+                failure = rt_band_set_pixel(band, x, y, 31);
                 CHECK(!failure);
                 failure = rt_band_get_pixel(band, x, y, &val);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 31);
 
-                failure = rt_band_set_pixel(band, x, y, 255);  
+                failure = rt_band_set_pixel(band, x, y, 255);
                 CHECK(!failure);
                 failure = rt_band_get_pixel(band, x, y, &val);
                 CHECK(!failure);
@@ -456,49 +456,49 @@ static void testBand8BSI(rt_band band)
     val = rt_band_get_nodata(band);
     CHECK_EQUALS(val, 2);
 
-    failure = rt_band_set_nodata(band, 4); 
+    failure = rt_band_set_nodata(band, 4);
     CHECK(!failure);
     val = rt_band_get_nodata(band);
     CHECK_EQUALS(val, 4);
 
-    failure = rt_band_set_nodata(band, 8); 
+    failure = rt_band_set_nodata(band, 8);
     CHECK(!failure);
     val = rt_band_get_nodata(band);
     CHECK_EQUALS(val, 8);
 
-    failure = rt_band_set_nodata(band, 15); 
+    failure = rt_band_set_nodata(band, 15);
     val = rt_band_get_nodata(band);
     CHECK_EQUALS(val, 15);
 
-    failure = rt_band_set_nodata(band, 31);  
+    failure = rt_band_set_nodata(band, 31);
     CHECK(!failure);
     val = rt_band_get_nodata(band);
     CHECK_EQUALS(val, 31);
 
-    failure = rt_band_set_nodata(band, -127);  
+    failure = rt_band_set_nodata(band, -127);
     CHECK(!failure);
     val = rt_band_get_nodata(band);
     CHECK_EQUALS(val, -127);
 
-    failure = rt_band_set_nodata(band, 127);  
+    failure = rt_band_set_nodata(band, 127);
     CHECK(!failure);
     val = rt_band_get_nodata(band);
     CHECK_EQUALS(val, 127);
 
     /* out of range (-127..127) */
-    failure = rt_band_set_nodata(band, -129);  
+    failure = rt_band_set_nodata(band, -129);
     CHECK(failure);
 
     /* out of range (-127..127) */
-    failure = rt_band_set_nodata(band, 129);  
+    failure = rt_band_set_nodata(band, 129);
     CHECK(failure);
 
     /* out of range (-127..127) */
-    failure = rt_band_set_pixel(band, 0, 0, -129);  
+    failure = rt_band_set_pixel(band, 0, 0, -129);
     CHECK(failure);
 
     /* out of range (-127..127) */
-    failure = rt_band_set_pixel(band, 0, 0, 129);  
+    failure = rt_band_set_pixel(band, 0, 0, 129);
     CHECK(failure);
 
 
@@ -508,7 +508,7 @@ static void testBand8BSI(rt_band band)
         {
             for (y=0; y<rt_band_get_height(band); ++y)
             {
-                failure = rt_band_set_pixel(band, x, y, 31);  
+                failure = rt_band_set_pixel(band, x, y, 31);
                 CHECK(!failure);
                 failure = rt_band_get_pixel(band, x, y, &val);
                 CHECK(!failure);
@@ -552,17 +552,17 @@ static void testBand16BUI(rt_band band)
     val = rt_band_get_nodata(band);
     CHECK_EQUALS(val, 0);
 
-    failure = rt_band_set_nodata(band, 31);  
+    failure = rt_band_set_nodata(band, 31);
     CHECK(!failure);
     val = rt_band_get_nodata(band);
     CHECK_EQUALS(val, 31);
 
-    failure = rt_band_set_nodata(band, 255);  
+    failure = rt_band_set_nodata(band, 255);
     CHECK(!failure);
     val = rt_band_get_nodata(band);
     CHECK_EQUALS(val, 255);
 
-    failure = rt_band_set_nodata(band, 65535);   
+    failure = rt_band_set_nodata(band, 65535);
     CHECK(!failure);
     val = rt_band_get_nodata(band);
     //printf("set 65535 on %s band gets %g back\n", pixtypeName, val);
@@ -585,13 +585,13 @@ static void testBand16BUI(rt_band band)
         {
             for (y=0; y<rt_band_get_height(band); ++y)
             {
-                failure = rt_band_set_pixel(band, x, y, 255);  
+                failure = rt_band_set_pixel(band, x, y, 255);
                 CHECK(!failure);
                 failure = rt_band_get_pixel(band, x, y, &val);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 255);
 
-                failure = rt_band_set_pixel(band, x, y, 65535);   
+                failure = rt_band_set_pixel(band, x, y, 65535);
                 CHECK(!failure);
                 failure = rt_band_get_pixel(band, x, y, &val);
                 CHECK(!failure);
@@ -616,23 +616,23 @@ static void testBand16BSI(rt_band band)
     val = rt_band_get_nodata(band);
     CHECK_EQUALS(val, 0);
 
-    failure = rt_band_set_nodata(band, 31);  
+    failure = rt_band_set_nodata(band, 31);
     CHECK(!failure);
     val = rt_band_get_nodata(band);
     CHECK_EQUALS(val, 31);
 
-    failure = rt_band_set_nodata(band, 255);  
+    failure = rt_band_set_nodata(band, 255);
     CHECK(!failure);
     val = rt_band_get_nodata(band);
     CHECK_EQUALS(val, 255);
 
-    failure = rt_band_set_nodata(band, -32767);   
+    failure = rt_band_set_nodata(band, -32767);
     CHECK(!failure);
     val = rt_band_get_nodata(band);
     //printf("set 65535 on %s band gets %g back\n", pixtypeName, val);
     CHECK_EQUALS(val, -32767);
 
-    failure = rt_band_set_nodata(band, 32767);   
+    failure = rt_band_set_nodata(band, 32767);
     CHECK(!failure);
     val = rt_band_get_nodata(band);
     //printf("set 65535 on %s band gets %g back\n", pixtypeName, val);
@@ -647,15 +647,15 @@ static void testBand16BSI(rt_band band)
     CHECK(failure);
 
     /* out of range (-32767..32767) */
-    failure = rt_band_set_pixel(band, 0, 0, -32769); 
+    failure = rt_band_set_pixel(band, 0, 0, -32769);
     CHECK(failure);
 
     /* out of range (-32767..32767) */
-    failure = rt_band_set_pixel(band, 0, 0, 32769); 
+    failure = rt_band_set_pixel(band, 0, 0, 32769);
     CHECK(failure);
 
     /* out of dimensions range */
-    failure = rt_band_set_pixel(band, rt_band_get_width(band), 0, 0); 
+    failure = rt_band_set_pixel(band, rt_band_get_width(band), 0, 0);
     CHECK(failure);
 
     {
@@ -664,19 +664,19 @@ static void testBand16BSI(rt_band band)
         {
             for (y=0; y<rt_band_get_height(band); ++y)
             {
-                failure = rt_band_set_pixel(band, x, y, 255);  
+                failure = rt_band_set_pixel(band, x, y, 255);
                 CHECK(!failure);
                 failure = rt_band_get_pixel(band, x, y, &val);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 255);
 
-                failure = rt_band_set_pixel(band, x, y, -32767);   
+                failure = rt_band_set_pixel(band, x, y, -32767);
                 CHECK(!failure);
                 failure = rt_band_get_pixel(band, x, y, &val);
                 CHECK(!failure);
                 CHECK_EQUALS(val, -32767);
 
-                failure = rt_band_set_pixel(band, x, y, 32767);   
+                failure = rt_band_set_pixel(band, x, y, 32767);
                 CHECK(!failure);
                 failure = rt_band_get_pixel(band, x, y, &val);
                 CHECK(!failure);
@@ -701,7 +701,7 @@ static void testBand32BUI(rt_band band)
     val = rt_band_get_nodata(band);
     CHECK_EQUALS(val, 0);
 
-    failure = rt_band_set_nodata(band, 65535);   
+    failure = rt_band_set_nodata(band, 65535);
     CHECK(!failure);
     val = rt_band_get_nodata(band);
     CHECK_EQUALS(val, 65535);
@@ -742,13 +742,13 @@ static void testBand32BUI(rt_band band)
                 CHECK(!failure);
                 CHECK_EQUALS(val, 0);
 
-                failure = rt_band_set_pixel(band, x, y, 65535);   
+                failure = rt_band_set_pixel(band, x, y, 65535);
                 CHECK(!failure);
                 failure = rt_band_get_pixel(band, x, y, &val);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 65535);
 
-                failure = rt_band_set_pixel(band, x, y, 4294967295UL); 
+                failure = rt_band_set_pixel(band, x, y, 4294967295UL);
                 CHECK(!failure);
                 failure = rt_band_get_pixel(band, x, y, &val);
                 CHECK(!failure);
@@ -773,7 +773,7 @@ static void testBand32BSI(rt_band band)
     val = rt_band_get_nodata(band);
     CHECK_EQUALS(val, 0);
 
-    failure = rt_band_set_nodata(band, 65535);   
+    failure = rt_band_set_nodata(band, 65535);
     CHECK(!failure);
     val = rt_band_get_nodata(band);
     CHECK_EQUALS(val, 65535);
@@ -789,7 +789,7 @@ static void testBand32BSI(rt_band band)
     CHECK(failure);
 
     /* out of value range */
-    failure = rt_band_set_pixel(band, 0, 0, 2147483648UL);  
+    failure = rt_band_set_pixel(band, 0, 0, 2147483648UL);
     CHECK(failure);
 
     /* out of dimensions range */
@@ -815,13 +815,13 @@ static void testBand32BSI(rt_band band)
                 CHECK(!failure);
                 CHECK_EQUALS(val, 0);
 
-                failure = rt_band_set_pixel(band, x, y, 65535);   
+                failure = rt_band_set_pixel(band, x, y, 65535);
                 CHECK(!failure);
                 failure = rt_band_get_pixel(band, x, y, &val);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 65535);
 
-                failure = rt_band_set_pixel(band, x, y, 2147483647); 
+                failure = rt_band_set_pixel(band, x, y, 2147483647);
                 CHECK(!failure);
                 failure = rt_band_get_pixel(band, x, y, &val);
                 CHECK(!failure);
@@ -852,7 +852,7 @@ static void testBand32BF(rt_band band)
     //printf("set 65535.56 on %s band gets %g back\n", pixtypeName, val);
     CHECK_EQUALS_DOUBLE(val, 65535.5);
 
-    failure = rt_band_set_nodata(band, 0.006); 
+    failure = rt_band_set_nodata(band, 0.006);
     CHECK(!failure);
     val = rt_band_get_nodata(band);
     CHECK_EQUALS_DOUBLE(val, 0.0060000000521540); /* XXX: Alternatively, use CHECK_EQUALS_DOUBLE_EX */
@@ -881,7 +881,7 @@ static void testBand32BF(rt_band band)
                 CHECK(!failure);
                 CHECK_EQUALS_DOUBLE(val, 65535.5);
 
-                failure = rt_band_set_pixel(band, x, y, 0.006); 
+                failure = rt_band_set_pixel(band, x, y, 0.006);
                 CHECK(!failure);
                 failure = rt_band_get_pixel(band, x, y, &val);
                 CHECK(!failure);
@@ -907,12 +907,12 @@ static void testBand64BF(rt_band band)
     val = rt_band_get_nodata(band);
     CHECK_EQUALS(val, 0);
 
-    failure = rt_band_set_nodata(band, 65535.56);   
+    failure = rt_band_set_nodata(band, 65535.56);
     CHECK(!failure);
     val = rt_band_get_nodata(band);
     CHECK_EQUALS(val, 65535.56);
 
-    failure = rt_band_set_nodata(band, 0.006); 
+    failure = rt_band_set_nodata(band, 0.006);
     CHECK(!failure);
     val = rt_band_get_nodata(band);
     CHECK_EQUALS(val, 0.006);
@@ -935,13 +935,13 @@ static void testBand64BF(rt_band band)
                 CHECK(!failure);
                 CHECK_EQUALS(val, 0);
 
-                failure = rt_band_set_pixel(band, x, y, 65535.56);   
+                failure = rt_band_set_pixel(band, x, y, 65535.56);
                 CHECK(!failure);
                 failure = rt_band_get_pixel(band, x, y, &val);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 65535.56);
 
-                failure = rt_band_set_pixel(band, x, y, 0.006); 
+                failure = rt_band_set_pixel(band, x, y, 0.006);
                 CHECK(!failure);
                 failure = rt_band_get_pixel(band, x, y, &val);
                 CHECK(!failure);
@@ -983,23 +983,23 @@ main()
 
     raster = rt_raster_new(256, 256);
     assert(raster); /* or we're out of virtual memory */
-       
+
        printf("Checking empty and hasnoband functions...\n");
        { /* Check isEmpty and hasnoband */
                CHECK(!rt_raster_is_empty(raster));
-               
+
                /* Create a dummy empty raster to test the opposite
                 * to the previous sentence
                 */
                rt_raster emptyraster = rt_raster_new(0, 0);
                CHECK(rt_raster_is_empty(emptyraster));
                rt_raster_destroy(emptyraster);
-               
+
                /* Once we add a band to this raster, we'll check the opposite */
                CHECK(rt_raster_has_no_band(raster, 1));
        }
 
-       
+
        printf("Checking raster properties...\n");
     { /* Check scale */
         float scale;
@@ -1127,7 +1127,7 @@ main()
 
         typedef struct rt_geomval_t* rt_geomval;
         int nPols = 0;
-        
+
         rt_geomval gv = (rt_geomval) rt_raster_dump_as_wktpolygons(rt, 1, &nPols);
 
         CHECK_EQUALS_DOUBLE(gv[0].val, 1.0);
@@ -1137,23 +1137,23 @@ main()
                CHECK(!strcmp(gv[1].geom, "POLYGON ((3 3,3 6,6 6,6 3,3 3))"));
 
         CHECK_EQUALS_DOUBLE(gv[2].val, 2.0);
-        CHECK(!strcmp(gv[2].geom, "POLYGON ((5 1,5 3,6 3,6 6,5 6,5 8,6 8,6 7,7 7,7 6,8 6,8 3,7 3,7 2,6 2,6 1,5 1))"));   
+        CHECK(!strcmp(gv[2].geom, "POLYGON ((5 1,5 3,6 3,6 6,5 6,5 8,6 8,6 7,7 7,7 6,8 6,8 3,7 3,7 2,6 2,6 1,5 1))"));
 
                CHECK_EQUALS_DOUBLE(gv[3].val, 0.0);
                CHECK(!strcmp(gv[3].geom, "POLYGON ((0 0,0 9,9 9,9 0,0 0),(6 7,6 8,3 8,3 7,2 7,2 6,1 6,1 3,2 3,2 2,3 2,3 1,6 1,6 2,7 2,7 3,8 3,8 6,7 6,7 7,6 7))"));
-               
-        
+
+
         rt_raster_destroy(rt);
 
-       
+
                /* Second test: NODATA value = 1 */
         rt = fillRasterToPolygonize(1, 1.0);
-                               
+
                /* We can check rt_raster_has_no_band here too */
                CHECK(!rt_raster_has_no_band(rt, 1));
 
         nPols = 0;
-        
+
         gv = (rt_geomval) rt_raster_dump_as_wktpolygons(rt, 1, &nPols);
 
 
@@ -1161,20 +1161,20 @@ main()
                CHECK(!strcmp(gv[0].geom, "POLYGON ((3 3,3 6,6 6,6 3,3 3))"));
 
         CHECK_EQUALS_DOUBLE(gv[1].val, 2.0);
-        CHECK(!strcmp(gv[1].geom, "POLYGON ((5 1,5 3,6 3,6 6,5 6,5 8,6 8,6 7,7 7,7 6,8 6,8 3,7 3,7 2,6 2,6 1,5 1))"));   
+        CHECK(!strcmp(gv[1].geom, "POLYGON ((5 1,5 3,6 3,6 6,5 6,5 8,6 8,6 7,7 7,7 6,8 6,8 3,7 3,7 2,6 2,6 1,5 1))"));
 
                CHECK_EQUALS_DOUBLE(gv[2].val, 0.0);
                CHECK(!strcmp(gv[2].geom, "POLYGON ((0 0,0 9,9 9,9 0,0 0),(6 7,6 8,3 8,3 7,2 7,2 6,1 6,1 3,2 3,2 2,3 2,3 1,6 1,6 2,7 2,7 3,8 3,8 6,7 6,7 7,6 7))"));
         rt_raster_destroy(rt);
+
                /* Third test: NODATA value = 2 */
         rt = fillRasterToPolygonize(1, 2.0);
-                               
+
                /* We can check rt_raster_has_no_band here too */
                CHECK(!rt_raster_has_no_band(rt, 1));
 
         nPols = 0;
-        
+
         gv = (rt_geomval) rt_raster_dump_as_wktpolygons(rt, 1, &nPols);
 
         CHECK_EQUALS_DOUBLE(gv[0].val, 1.0);
@@ -1186,34 +1186,34 @@ main()
                CHECK_EQUALS_DOUBLE(gv[2].val, 0.0);
                CHECK(!strcmp(gv[2].geom, "POLYGON ((0 0,0 9,9 9,9 0,0 0),(6 7,6 8,3 8,3 7,2 7,2 6,1 6,1 3,2 3,2 2,3 2,3 1,6 1,6 2,7 2,7 3,8 3,8 6,7 6,7 7,6 7))"));
         rt_raster_destroy(rt);
+
 
                /* Fourth test: NODATA value = 0 */
         rt = fillRasterToPolygonize(1, 0.0);
-                               
+
                /* We can check rt_raster_has_no_band here too */
                CHECK(!rt_raster_has_no_band(rt, 1));
 
         nPols = 0;
-        
+
         gv = (rt_geomval) rt_raster_dump_as_wktpolygons(rt, 1, &nPols);
-               
+
         CHECK_EQUALS_DOUBLE(gv[0].val, 1.0);
         CHECK(!strcmp(gv[0].geom, "POLYGON ((3 1,3 2,2 2,2 3,1 3,1 6,2 6,2 7,3 7,3 8,5 8,5 6,3 6,3 3,4 3,5 3,5 1,3 1))"));
-        
+
                CHECK_EQUALS_DOUBLE(gv[1].val, 2.0);
-        CHECK(!strcmp(gv[1].geom, "POLYGON ((5 1,5 3,6 3,6 6,5 6,5 8,6 8,6 7,7 7,7 6,8 6,8 3,7 3,7 2,6 2,6 1,5 1))"));   
+        CHECK(!strcmp(gv[1].geom, "POLYGON ((5 1,5 3,6 3,6 6,5 6,5 8,6 8,6 7,7 7,7 6,8 6,8 3,7 3,7 2,6 2,6 1,5 1))"));
 
                rt_raster_destroy(rt);
+
                /* Last test: There is no NODATA value (all values are valid) */
         rt = fillRasterToPolygonize(0, 1.0);
-               
+
                /* We can check rt_raster_has_no_band here too */
                CHECK(!rt_raster_has_no_band(rt, 1));
 
         nPols = 0;
-        
+
         gv = (rt_geomval) rt_raster_dump_as_wktpolygons(rt, 1, &nPols);
 
         CHECK_EQUALS_DOUBLE(gv[0].val, 1.0);
@@ -1223,7 +1223,7 @@ main()
                CHECK(!strcmp(gv[1].geom, "POLYGON ((3 3,3 6,6 6,6 3,3 3))"));
 
         CHECK_EQUALS_DOUBLE(gv[2].val, 2.0);
-        CHECK(!strcmp(gv[2].geom, "POLYGON ((5 1,5 3,6 3,6 6,5 6,5 8,6 8,6 7,7 7,7 6,8 6,8 3,7 3,7 2,6 2,6 1,5 1))"));   
+        CHECK(!strcmp(gv[2].geom, "POLYGON ((5 1,5 3,6 3,6 6,5 6,5 8,6 8,6 7,7 7,7 6,8 6,8 3,7 3,7 2,6 2,6 1,5 1))"));
 
                CHECK_EQUALS_DOUBLE(gv[3].val, 0.0);
                CHECK(!strcmp(gv[3].geom, "POLYGON ((0 0,0 9,9 9,9 0,0 0),(6 7,6 8,3 8,3 7,2 7,2 6,1 6,1 3,2 3,2 2,3 2,3 1,6 1,6 2,7 2,7 3,8 3,8 6,7 6,7 7,6 7))"));
index 42a1468262df0d81871022a478a926dc984da375..d7f03e87b6d5768dfb077b9172e2c01b61a67893 100644 (file)
@@ -1,21 +1,21 @@
-/* 
+/*
  * $Id$
  *
  * WKTRaster - Raster Types for PostGIS
  * http://www.postgis.org/support/wiki/index.php?WKTRasterHomePage
  *
  * Copyright (C) 2009  Sandro Santilli <strk@keybit.net>
- * 
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
@@ -87,7 +87,7 @@ main()
 */
     free((/*no const*/ void*)out);
 
-    { 
+    {
         void *serialized;
         rt_raster rast2;
 
@@ -246,7 +246,7 @@ main()
     {
         double val;
         int failure;
-        
+
         rt_band band = rt_raster_get_band(raster, 0);
         CHECK(band);
         CHECK_EQUALS(rt_band_get_pixtype(band), PT_8BSI);
@@ -289,7 +289,7 @@ main()
 
     free((/*no const*/ void*)out);
 
-    { 
+    {
         void *serialized;
         rt_raster rast2;
 
@@ -298,7 +298,7 @@ main()
 
         rt_raster_destroy(rast2);
         free(serialized);
-    
+
     }
 
     rt_raster_destroy(raster);
@@ -351,7 +351,7 @@ main()
         CHECK(!rt_band_is_offline(band));
         CHECK(!rt_band_get_hasnodata_flag(band));
         CHECK_EQUALS(rt_band_get_nodata(band), -1);
-        
+
         failure = rt_band_get_pixel(band, 0, 0, &val);
         CHECK(!failure);
         CHECK_EQUALS(val, -1);
@@ -359,19 +359,19 @@ main()
         failure = rt_band_get_pixel(band, 1, 0, &val);
         CHECK(!failure);
         CHECK_EQUALS(val, 0);
-        
+
         failure = rt_band_get_pixel(band, 2, 0, &val);
         CHECK(!failure);
         CHECK_EQUALS(val, -16);
-        
+
         failure = rt_band_get_pixel(band, 0, 1, &val);
         CHECK(!failure);
         CHECK_EQUALS(val, 127);
-        
+
         failure = rt_band_get_pixel(band, 1, 1, &val);
         CHECK(!failure);
         CHECK_EQUALS(val, 10);
-        
+
         failure = rt_band_get_pixel(band, 2, 1, &val);
         CHECK(!failure);
         CHECK_EQUALS(val, 2);
@@ -444,19 +444,19 @@ main()
         failure = rt_band_get_pixel(band, 1, 0, &val);
         CHECK(!failure);
         CHECK_EQUALS(val, 0);
-        
+
         failure = rt_band_get_pixel(band, 2, 0, &val);
         CHECK(!failure);
         CHECK_EQUALS(val, -16);
-        
+
         failure = rt_band_get_pixel(band, 0, 1, &val);
         CHECK(!failure);
         CHECK_EQUALS(val, 127);
-        
+
         failure = rt_band_get_pixel(band, 1, 1, &val);
         CHECK(!failure);
         CHECK_EQUALS(val, 10);
-        
+
         failure = rt_band_get_pixel(band, 2, 1, &val);
         CHECK(!failure);
         CHECK_EQUALS(val, 2);
@@ -494,7 +494,7 @@ main()
 "FFFF"             /* nodata value (-1) */
 "03"               /* ext band num == 3 */
 /* ext band path == /tmp/t.tif */
-"2F746D702F742E74696600" 
+"2F746D702F742E74696600"
     ;
 
     raster = rt_raster_from_hexwkb(hexwkb, strlen(hexwkb));
@@ -586,7 +586,7 @@ main()
         failure = rt_band_get_pixel(band, 1, 0, &val);
         CHECK(!failure);
         CHECK_EQUALS(val, 436);
-        
+
         failure = rt_band_get_pixel(band, 2, 0, &val);
         CHECK(!failure);
         CHECK_EQUALS(val, 431);
@@ -605,7 +605,7 @@ main()
 */
     free((/*no const*/ void*)out);
 
-    { 
+    {
         void *serialized;
         rt_raster rast2;
 
@@ -622,7 +622,7 @@ main()
     /* 5x5, little endian, 3 x band 8BUI (RGB),               */
     /* nodata 0, srid -1                                      */
     /* Test case completes regress/bug_test_car5.sql          */
-    /* Test case repeated 4 times to mimic 4 tiles insertion  */ 
+    /* Test case repeated 4 times to mimic 4 tiles insertion  */
     /* ------------------------------------------------------ */
     for (i = 0; i < 5; ++i)
     {
@@ -681,20 +681,20 @@ main()
         failure = rt_band_get_pixel(band, 1, 0, &val);
         CHECK(!failure);
         CHECK_EQUALS(val, 254);
-        
+
         failure = rt_band_get_pixel(band, 2, 0, &val);
         CHECK(!failure);
         CHECK_EQUALS(val, 253);
-        
+
         failure = rt_band_get_pixel(band, 3, 0, &val);
         CHECK(!failure);
         CHECK_EQUALS(val, 254);
-        
+
         failure = rt_band_get_pixel(band, 4, 0, &val);
         CHECK(!failure);
         CHECK_EQUALS(val, 254);
     }
-    
+
     {
         /* Test 2nd band */
         double val;
@@ -713,20 +713,20 @@ main()
         failure = rt_band_get_pixel(band, 1, 0, &val);
         CHECK(!failure);
         CHECK_EQUALS(val, 98);
-        
+
         failure = rt_band_get_pixel(band, 2, 0, &val);
         CHECK(!failure);
         CHECK_EQUALS(val, 122);
-        
+
         failure = rt_band_get_pixel(band, 3, 0, &val);
         CHECK(!failure);
         CHECK_EQUALS(val, 173);
-        
+
         failure = rt_band_get_pixel(band, 4, 0, &val);
         CHECK(!failure);
         CHECK_EQUALS(val, 209);
     }
-    
+
     {
         /* Test 3rd band */
         double val;
@@ -745,15 +745,15 @@ main()
         failure = rt_band_get_pixel(band, 1, 0, &val);
         CHECK(!failure);
         CHECK_EQUALS(val, 86);
-        
+
         failure = rt_band_get_pixel(band, 2, 0, &val);
         CHECK(!failure);
         CHECK_EQUALS(val, 100);
-        
+
         failure = rt_band_get_pixel(band, 3, 0, &val);
         CHECK(!failure);
         CHECK_EQUALS(val, 135);
-        
+
         failure = rt_band_get_pixel(band, 4, 0, &val);
         CHECK(!failure);
         CHECK_EQUALS(val, 161);
@@ -768,7 +768,7 @@ main()
 */
 
     free((/*no const*/ void*)out);
-    { 
+    {
         void *serialized;
         rt_raster rast2;
 
@@ -779,7 +779,7 @@ main()
         free(serialized);
     }
     rt_raster_destroy(raster);
-    
+
     } /* for-loop running car5 tests */
 
     /* ------------------------------------------------------ */
@@ -807,4 +807,4 @@ lwgeom_init_allocators(void)
 void rt_init_allocators(void)
 {
     rt_install_default_allocators();
-}
\ No newline at end of file
+}