mirror of
https://git.osgeo.org/gitea/postgis/postgis
synced 2024-10-24 00:52:40 +00:00
-Fix for ticket 792: Clamp double to known values when pixeltype is other than double in rt_band_set_nodata, rt_band_set_pixel & rt_raster_generate_new_band
-Added function name to many error messages -Standardized the way we write "nodata" from "NODATA" to "nodata" -Moved some documentation to the header file -My editor remove a lot of trailing space and convert tab to 4 spaces. Please make your editor do the same. -Removed declarations of many unused variable git-svn-id: http://svn.osgeo.org/postgis/trunk@6920 b70326c6-7e19-0410-871a-916f4a2858ee
This commit is contained in:
parent
ca7446ba0c
commit
6b917c2436
File diff suppressed because it is too large
Load diff
|
@ -30,43 +30,43 @@
|
|||
#define RT_API_H_INCLUDED
|
||||
|
||||
/* define the systems */
|
||||
#if defined(__linux__) /* (predefined) */
|
||||
#if defined(__linux__) /* (predefined) */
|
||||
#if !defined(LINUX)
|
||||
#define LINUX
|
||||
#define LINUX
|
||||
#endif
|
||||
#if !defined(UNIX)
|
||||
#define UNIX /* make sure this is defined */
|
||||
#define UNIX /* make sure this is defined */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__) /* seems to work like Linux... */
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__) /* seems to work like Linux... */
|
||||
#if !defined(LINUX)
|
||||
#define LINUX
|
||||
#define LINUX
|
||||
#endif
|
||||
#if !defined(UNIX)
|
||||
#define UNIX /* make sure this is defined */
|
||||
#define UNIX /* make sure this is defined */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__MSDOS__)
|
||||
#if !defined(MSDOS)
|
||||
#define MSDOS /* make sure this is defined */
|
||||
#define MSDOS /* make sure this is defined */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__WIN32__) || defined(__NT__) || defined(_WIN32)
|
||||
#if !defined(WIN32)
|
||||
#define WIN32
|
||||
#define WIN32
|
||||
#endif
|
||||
#if defined(__BORLANDC__) && defined(MSDOS) /* Borland always defines MSDOS */
|
||||
#undef MSDOS
|
||||
#undef MSDOS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#if !defined(UNIX)
|
||||
#define UNIX
|
||||
#define UNIX
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -75,10 +75,10 @@
|
|||
/* does. */
|
||||
#if defined(UNIX)
|
||||
#if !defined(HAVE_STRICMP)
|
||||
#define stricmp strcasecmp
|
||||
#define stricmp strcasecmp
|
||||
#endif
|
||||
#if !defined(HAVE_STRNICMP)
|
||||
#define strnicmp strncasecmp
|
||||
#define strnicmp strncasecmp
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -112,7 +112,7 @@ typedef void (*rt_message_handler)(const char* string, ...);
|
|||
|
||||
/* Debugging macros */
|
||||
#if POSTGIS_DEBUG_LEVEL > 0
|
||||
|
||||
|
||||
/* Display a simple message at NOTICE level */
|
||||
#define RASTER_DEBUG(level, msg) \
|
||||
do { \
|
||||
|
@ -126,20 +126,20 @@ typedef void (*rt_message_handler)(const char* string, ...);
|
|||
if (POSTGIS_DEBUG_LEVEL >= level) \
|
||||
ctx->warn("[%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 RASTER_DEBUG(level, msg) \
|
||||
((void) 0)
|
||||
|
||||
|
||||
/* Empty prototype that can be optimised away by the compiler for non-debug builds */
|
||||
#define RASTER_DEBUGF(level, msg, ...) \
|
||||
((void) 0)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*- memory context -------------------------------------------------------*/
|
||||
|
||||
/* Initialize a context object
|
||||
* @param allocator memory allocator to use, 0 to use malloc
|
||||
|
@ -205,7 +205,7 @@ rt_pixtype rt_pixtype_index_from_name(rt_context ctx, const char* pixname);
|
|||
* @param width : number of pixel columns
|
||||
* @param height : number of pixel rows
|
||||
* @param pixtype : pixel type for the band
|
||||
* @param hasnodata : indicates if the band has nodata value
|
||||
* @param hasnodata : indicates if the band has nodata value
|
||||
* @param nodataval : the nodata value, will be appropriately
|
||||
* truncated to fit the pixtype size.
|
||||
* @param data : pointer to actual band data, required to
|
||||
|
@ -390,6 +390,15 @@ double rt_band_get_min_value(rt_context ctx, rt_band band);
|
|||
*/
|
||||
int rt_band_is_nodata(rt_context ctx, rt_band band);
|
||||
|
||||
/**
|
||||
* Returns TRUE if the band is only nodata values
|
||||
* @param ctx: context, for thread safety
|
||||
* @param band: the band to get info from
|
||||
* @return TRUE if the band is only nodata values, FALSE otherwise
|
||||
*/
|
||||
int rt_band_check_is_nodata(rt_context ctx, rt_band band);
|
||||
|
||||
|
||||
|
||||
/*- rt_raster --------------------------------------------------------*/
|
||||
|
||||
|
@ -509,7 +518,7 @@ int32_t rt_raster_add_band(rt_context ctx, rt_raster raster, rt_band band, int i
|
|||
*
|
||||
* @return identifier (position) for the just-added raster, or -1 on error
|
||||
*/
|
||||
int32_t rt_raster_generate_new_band(rt_context ctx, rt_raster raster, rt_pixtype pixtype,
|
||||
int32_t rt_raster_generate_new_band(rt_context ctx, rt_raster raster, rt_pixtype pixtype,
|
||||
double initialvalue, uint32_t hasnodata, double nodatavalue, int index);
|
||||
|
||||
/**
|
||||
|
@ -658,13 +667,13 @@ LWPOLY* rt_raster_get_convex_hull(rt_context ctx, rt_raster raster);
|
|||
|
||||
|
||||
/**
|
||||
* Returns a set of "geomval" value, one for each group of pixel
|
||||
* Returns a set of "geomval" value, one for each group of pixel
|
||||
* sharing the same value for the provided band.
|
||||
*
|
||||
* A "geomval " value is a complex type composed of a the wkt
|
||||
* representation of a geometry (one for each group of pixel sharing
|
||||
* A "geomval " value is a complex type composed of a the wkt
|
||||
* representation of a geometry (one for each group of pixel sharing
|
||||
* the same value) and the value associated with this geometry.
|
||||
*
|
||||
*
|
||||
* @param ctx: context for thread safety.
|
||||
* @param raster: the raster to get info from.
|
||||
* @param nband: the band to polygonize. From 1 to rt_raster_get_num_bands
|
||||
|
@ -678,7 +687,7 @@ rt_geomval
|
|||
rt_raster_dump_as_wktpolygons(rt_context ctx, rt_raster raster, int nband,
|
||||
int * pnElements);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return this raster in serialized form.
|
||||
*
|
||||
|
@ -728,5 +737,52 @@ int rt_raster_has_no_band(rt_context ctx, rt_raster raster, int nband);
|
|||
int32_t rt_raster_copy_band(rt_context ctx, rt_raster raster1,
|
||||
rt_raster raster2, int nband1, int nband2);
|
||||
|
||||
#endif /* RT_API_H_INCLUDED */
|
||||
/*- utilities -------------------------------------------------------*/
|
||||
|
||||
/* Set of functions to clamp double to int of different size
|
||||
*/
|
||||
|
||||
#define POSTGIS_RT_1BBMAX 1
|
||||
#define POSTGIS_RT_2BUIMAX 3
|
||||
#define POSTGIS_RT_4BUIMAX 15
|
||||
|
||||
uint8_t
|
||||
rt_util_clamp_to_1BB(double value);
|
||||
|
||||
uint8_t
|
||||
rt_util_clamp_to_2BUI(double value);
|
||||
|
||||
uint8_t
|
||||
rt_util_clamp_to_4BUI(double value);
|
||||
|
||||
int8_t
|
||||
rt_util_clamp_to_8BSI(double value);
|
||||
|
||||
uint8_t
|
||||
rt_util_clamp_to_8BUI(double value);
|
||||
|
||||
int16_t
|
||||
rt_util_clamp_to_16BSI(double value);
|
||||
|
||||
uint16_t
|
||||
rt_util_clamp_to_16BUI(double value);
|
||||
|
||||
int32_t
|
||||
rt_util_clamp_to_32BSI(double value);
|
||||
|
||||
uint32_t
|
||||
rt_util_clamp_to_32BUI(double value);
|
||||
|
||||
float
|
||||
rt_util_clamp_to_32F(double value);
|
||||
|
||||
int
|
||||
rt_util_display_dbl_trunc_warning(rt_context ctx,
|
||||
double initialvalue,
|
||||
int32_t checkvalint,
|
||||
uint32_t checkvaluint,
|
||||
float checkvalfloat,
|
||||
double checkvaldouble,
|
||||
rt_pixtype pixtype);
|
||||
|
||||
#endif /* RT_API_H_INCLUDED */
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,124 +1,124 @@
|
|||
WARNING: Initial pixel value for 1BB band got truncated from -1.000000 to 1
|
||||
1
|
||||
WARNING: Initial pixel value for 1BB band got clamped from -1.000000 to 0
|
||||
0
|
||||
0
|
||||
1
|
||||
WARNING: Initial pixel value for 1BB band got truncated from 2.000000 to 0
|
||||
0
|
||||
WARNING: Initial pixel value for 1BB band got truncated from 21.460000 to 1
|
||||
WARNING: Initial pixel value for 1BB band got clamped from 2.000000 to 1
|
||||
1
|
||||
WARNING: Initial pixel value for 2BUI band got truncated from -1.000000 to 3
|
||||
3
|
||||
WARNING: Initial pixel value for 1BB band got clamped from 21.460000 to 1
|
||||
1
|
||||
WARNING: Initial pixel value for 2BUI band got clamped from -1.000000 to 0
|
||||
0
|
||||
0
|
||||
3
|
||||
WARNING: Initial pixel value for 2BUI band got truncated from 4.000000 to 0
|
||||
WARNING: Initial pixel value for 2BUI band got clamped from 4.000000 to 3
|
||||
3
|
||||
WARNING: Initial pixel value for 2BUI band got clamped from 21.460000 to 3
|
||||
3
|
||||
WARNING: Initial pixel value for 4BUI band got clamped from -1.000000 to 0
|
||||
0
|
||||
WARNING: Initial pixel value for 2BUI band got truncated from 21.460000 to 1
|
||||
1
|
||||
WARNING: Initial pixel value for 4BUI band got truncated from -1.000000 to 15
|
||||
15
|
||||
0
|
||||
15
|
||||
WARNING: Initial pixel value for 4BUI band got truncated from 16.000000 to 0
|
||||
0
|
||||
WARNING: Initial pixel value for 4BUI band got truncated from 21.460000 to 5
|
||||
5
|
||||
WARNING: Initial pixel value for 8BSI band got truncated from -129.000000 to 127
|
||||
127
|
||||
WARNING: Initial pixel value for 4BUI band got clamped from 16.000000 to 15
|
||||
15
|
||||
WARNING: Initial pixel value for 4BUI band got clamped from 21.460000 to 15
|
||||
15
|
||||
WARNING: Initial pixel value for 8BSI band got clamped from -129.000000 to -128
|
||||
-128
|
||||
-128
|
||||
0
|
||||
127
|
||||
WARNING: Initial pixel value for 8BSI band got truncated from 128.000000 to -128
|
||||
-128
|
||||
WARNING: Initial pixel value for 8BSI band got clamped from 128.000000 to 127
|
||||
127
|
||||
WARNING: Initial pixel value for 8BSI band got truncated from 21.460000 to 21
|
||||
21
|
||||
WARNING: Initial pixel value for 8BSI band got truncated from 210.460000 to -46
|
||||
-46
|
||||
WARNING: Initial pixel value for 8BUI band got truncated from -1.000000 to 255
|
||||
255
|
||||
WARNING: Initial pixel value for 8BSI band got clamped from 210.460000 to 127
|
||||
127
|
||||
WARNING: Initial pixel value for 8BUI band got clamped from -1.000000 to 0
|
||||
0
|
||||
0
|
||||
255
|
||||
WARNING: Initial pixel value for 8BUI band got truncated from 256.000000 to 0
|
||||
0
|
||||
WARNING: Initial pixel value for 8BUI band got clamped from 256.000000 to 255
|
||||
255
|
||||
WARNING: Initial pixel value for 8BUI band got truncated from 21.460000 to 21
|
||||
21
|
||||
WARNING: Initial pixel value for 8BUI band got truncated from 410.460000 to 154
|
||||
154
|
||||
WARNING: Initial pixel value for 8BUI band got clamped from 410.460000 to 255
|
||||
255
|
||||
WARNING: Initial pixel value for 8BUI band got truncated from 256.000000 to 255
|
||||
255
|
||||
WARNING: Initial pixel value for 16BSI band got truncated from -32769.000000 to -32768
|
||||
WARNING: Initial pixel value for 16BSI band got clamped from -32769.000000 to -32768
|
||||
-32768
|
||||
-32768
|
||||
0
|
||||
32767
|
||||
WARNING: Initial pixel value for 16BSI band got truncated from 32768.000000 to -32768
|
||||
-32768
|
||||
WARNING: Initial pixel value for 16BSI band got clamped from 32768.000000 to 32767
|
||||
32767
|
||||
WARNING: Initial pixel value for 16BSI band got truncated from 21.460000 to 21
|
||||
21
|
||||
WARNING: Initial pixel value for 16BSI band got truncated from 210000.460000 to -32768
|
||||
-32768
|
||||
WARNING: Initial pixel value for 16BUI band got truncated from -1.000000 to 65535
|
||||
65535
|
||||
WARNING: Initial pixel value for 16BSI band got clamped from 210000.460000 to 32767
|
||||
32767
|
||||
WARNING: Initial pixel value for 16BUI band got clamped from -1.000000 to 0
|
||||
0
|
||||
0
|
||||
65535
|
||||
WARNING: Initial pixel value for 16BUI band got truncated from 65537.000000 to 1
|
||||
1
|
||||
WARNING: Initial pixel value for 16BUI band got clamped from 65537.000000 to 65535
|
||||
65535
|
||||
WARNING: Initial pixel value for 16BUI band got truncated from 21.460000 to 21
|
||||
21
|
||||
WARNING: Initial pixel value for 16BUI band got truncated from 210000.464564 to 13392
|
||||
13392
|
||||
WARNING: Initial pixel value for 32BSI band got truncated from -2147483649.000000 to -2147483648
|
||||
WARNING: Initial pixel value for 16BUI band got clamped from 210000.464564 to 65535
|
||||
65535
|
||||
WARNING: Initial pixel value for 32BSI band got clamped from -2147483649.000000 to -2147483648
|
||||
-2147483648
|
||||
-2147483648
|
||||
0
|
||||
2147483647
|
||||
WARNING: Initial pixel value for 32BSI band got truncated from 2147483648.000000 to -2147483648
|
||||
-2147483648
|
||||
WARNING: Initial pixel value for 32BSI band got clamped from 2147483648.000000 to 2147483647
|
||||
2147483647
|
||||
WARNING: Initial pixel value for 32BSI band got truncated from 21.460000 to 21
|
||||
21
|
||||
WARNING: Initial pixel value for 32BSI band got truncated from 210000.464564 to 210000
|
||||
210000
|
||||
WARNING: Initial pixel value for 32BUI band got truncated from -1.000000 to 4294967295
|
||||
4294967295
|
||||
WARNING: Initial pixel value for 32BUI band got clamped from -1.000000 to 0
|
||||
0
|
||||
0
|
||||
4294967295
|
||||
WARNING: Initial pixel value for 32BUI band got truncated from 4294967296.000000 to 0
|
||||
0
|
||||
WARNING: Initial pixel value for 32BUI band got truncated from 214294967296.000000 to 3841569792
|
||||
3841569792
|
||||
WARNING: Initial pixel value for 32BUI band got clamped from 4294967296.000000 to 4294967295
|
||||
4294967295
|
||||
WARNING: Initial pixel value for 32BUI band got clamped from 214294967296.000000 to 4294967295
|
||||
4294967295
|
||||
WARNING: Initial pixel value for 32BUI band got truncated from 21.460000 to 21
|
||||
21
|
||||
WARNING: Initial pixel value for 32BUI band got truncated from 4294967296.000000 to 0
|
||||
WARNING: Initial pixel value for 32BUI band got clamped from 4294967296.000000 to 4294967295
|
||||
4294967295
|
||||
0
|
||||
0
|
||||
WARNING: Initial pixel value for 32BF band got truncated from 4294967000.000000 to 4.29497e+9
|
||||
WARNING: Initial pixel value for 32BF band got converted from 4294967000.000000 to 4294967040.000000
|
||||
4294967040
|
||||
WARNING: Initial pixel value for 32BF band got truncated from 4294967000.000000 to 4.29497e+9
|
||||
WARNING: Initial pixel value for 32BF band got converted from 4294967000.000000 to 4294967040.000000
|
||||
4.29497e+9
|
||||
WARNING: Initial pixel value for 32BF band got truncated from 4294967295.000000 to 4.29497e+9
|
||||
WARNING: Initial pixel value for 32BF band got converted from 4294967295.000000 to 4294967296.000000
|
||||
4294967296
|
||||
WARNING: Initial pixel value for 32BF band got truncated from 4294967295.000000 to 4.29497e+9
|
||||
WARNING: Initial pixel value for 32BF band got converted from 4294967295.000000 to 4294967296.000000
|
||||
4.29497e+9
|
||||
4294967296
|
||||
4.29497e+9
|
||||
WARNING: Initial pixel value for 32BF band got truncated from 21.460000 to 21.46
|
||||
WARNING: Initial pixel value for 32BF band got converted from 21.460000 to 21.459999
|
||||
21.4599990844727
|
||||
WARNING: Initial pixel value for 32BF band got truncated from 21.460000 to 21.46
|
||||
WARNING: Initial pixel value for 32BF band got converted from 21.460000 to 21.459999
|
||||
21.46
|
||||
WARNING: Initial pixel value for 32BF band got truncated from 21003.100000 to 21003.1
|
||||
WARNING: Initial pixel value for 32BF band got converted from 21003.100000 to 21003.099609
|
||||
21003.099609375
|
||||
WARNING: Initial pixel value for 32BF band got truncated from 21003.100000 to 21003.1
|
||||
WARNING: Initial pixel value for 32BF band got converted from 21003.100000 to 21003.099609
|
||||
21003.1
|
||||
WARNING: Initial pixel value for 32BF band got truncated from 123.456000 to 123.456
|
||||
WARNING: Initial pixel value for 32BF band got converted from 123.456000 to 123.456001
|
||||
123.456001281738
|
||||
WARNING: Initial pixel value for 32BF band got truncated from 123.456000 to 123.456
|
||||
WARNING: Initial pixel value for 32BF band got converted from 123.456000 to 123.456001
|
||||
123.456
|
||||
WARNING: Initial pixel value for 32BF band got truncated from 1234.567000 to 1234.57
|
||||
WARNING: Initial pixel value for 32BF band got converted from 1234.567000 to 1234.567017
|
||||
1234.56701660156
|
||||
WARNING: Initial pixel value for 32BF band got truncated from 1234.567000 to 1234.57
|
||||
WARNING: Initial pixel value for 32BF band got converted from 1234.567000 to 1234.567017
|
||||
1234.57
|
||||
WARNING: Initial pixel value for 32BF band got truncated from 210000.464564 to 210000
|
||||
WARNING: Initial pixel value for 32BF band got converted from 210000.464564 to 210000.468750
|
||||
210000.46875
|
||||
WARNING: Initial pixel value for 32BF band got truncated from 210000.464564 to 210000
|
||||
WARNING: Initial pixel value for 32BF band got converted from 210000.464564 to 210000.468750
|
||||
210000
|
||||
-1
|
||||
0
|
||||
|
|
|
@ -11,6 +11,6 @@
|
|||
1x1 single band (32BF) no transform|t|t
|
||||
1x1 single band (64BF) no transform|t|t
|
||||
1x1 single band (64BF external) no transform|t|t
|
||||
ERROR: Invalid value 2 for pixel of type 1BB
|
||||
ERROR: Invalid value 4 for pixel of type 2BUI
|
||||
ERROR: Invalid value 16 for pixel of type 4BUI
|
||||
ERROR: rt_band_from_wkb: Invalid value 2 for pixel of type 1BB
|
||||
ERROR: rt_band_from_wkb: Invalid value 4 for pixel of type 2BUI
|
||||
ERROR: rt_band_from_wkb: Invalid value 16 for pixel of type 4BUI
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
NOTICE: y coordinate can not be NULL. Returning NULL
|
||||
NOTICE: y coordinate can not be NULL. Returning NULL
|
||||
NOTICE: y coordinate can not be NULL. Returning NULL
|
||||
NOTICE: y coordinate can not be NULL. Returning NULL
|
||||
NOTICE: x coordinate can not be NULL. Returning NULL
|
||||
NOTICE: x coordinate can not be NULL. Returning NULL
|
||||
NOTICE: x coordinate can not be NULL. Returning NULL
|
||||
NOTICE: x coordinate can not be NULL. Returning NULL
|
||||
NOTICE: Y coordinate can not be NULL when getting pixel value. Returning NULL
|
||||
NOTICE: Y coordinate can not be NULL when getting pixel value. Returning NULL
|
||||
NOTICE: Y coordinate can not be NULL when getting pixel value. Returning NULL
|
||||
NOTICE: Y coordinate can not be NULL when getting pixel value. Returning NULL
|
||||
NOTICE: X coordinate can not be NULL when getting pixel value. Returning NULL
|
||||
NOTICE: X coordinate can not be NULL when getting pixel value. Returning NULL
|
||||
NOTICE: X coordinate can not be NULL when getting pixel value. Returning NULL
|
||||
NOTICE: X coordinate can not be NULL when getting pixel value. Returning NULL
|
||||
NOTICE: Raster do not have a nodata value defined. Pixel value not set. Returning raster
|
||||
NOTICE: Raster do not have a nodata value defined. Pixel value not set. Returning raster
|
||||
NOTICE: Raster do not have a nodata value defined. Pixel value not set. Returning raster
|
||||
|
|
Loading…
Reference in a new issue