From: Jorge Arévalo Date: Fri, 6 May 2011 14:29:04 +0000 (+0000) Subject: Trailing spaces removed from raster files. X-Git-Tag: 2.0.0alpha1~1701 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f0ebd104a7ef3a2c5e19d17b924f021d92da5d6a;p=postgis Trailing spaces removed from raster files. git-svn-id: http://svn.osgeo.org/postgis/trunk@7107 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/raster/rt_core/rt_api.c b/raster/rt_core/rt_api.c index 845d1bece..2c06efee6 100644 --- a/raster/rt_core/rt_api.c +++ b/raster/rt_core/rt_api.c @@ -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); diff --git a/raster/rt_core/rt_api.h b/raster/rt_core/rt_api.h index 6a30db9fa..0f33e882c 100644 --- a/raster/rt_core/rt_api.h +++ b/raster/rt_core/rt_api.h @@ -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. @@ -118,7 +118,7 @@ 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); diff --git a/raster/rt_pg/rt_pg.c b/raster/rt_pg/rt_pg.c index d37cfc8ca..581a9ad46 100644 --- a/raster/rt_pg/rt_pg.c +++ b/raster/rt_pg/rt_pg.c @@ -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(); } diff --git a/raster/rt_pg/rt_pg.h b/raster/rt_pg/rt_pg.h index 016661938..9bffaedf2 100644 --- a/raster/rt_pg/rt_pg.h +++ b/raster/rt_pg/rt_pg.h @@ -1,4 +1,4 @@ -/* +/* * $Id$ * * WKTRaster - Raster Types for PostGIS @@ -9,17 +9,17 @@ * Copyright (C) 2009-2011 Pierre Racine * Copyright (C) 2009-2011 Mateusz Loskot * Copyright (C) 2008-2009 Sandro Santilli - * + * * 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 { \ @@ -51,13 +51,13 @@ 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) diff --git a/raster/test/core/testapi.c b/raster/test/core/testapi.c index 26bbfe3ab..6c629db67 100644 --- a/raster/test/core/testapi.c +++ b/raster/test/core/testapi.c @@ -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 - * + * * 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 +}