Commit e20f3d0a authored by Bborie Park's avatar Bborie Park

Refactored rt_band_get_min_value() to call new function...

Refactored rt_band_get_min_value() to call new function rt_pixtype_get_min_value().  Addition of function rt_util_extent_type().


git-svn-id: http://svn.osgeo.org/postgis/trunk@8011 b70326c6-7e19-0410-871a-916f4a2858ee
parent 24719b86
...@@ -7,5 +7,5 @@ ID ...@@ -7,5 +7,5 @@ ID
libtool libtool
ltmain.sh ltmain.sh
tags tags
wktraster_config.h raster_config.h
wktraster_config.h.in Makefile
...@@ -259,6 +259,21 @@ rt_util_gdal_version(const char *request) { ...@@ -259,6 +259,21 @@ rt_util_gdal_version(const char *request) {
return GDALVersionInfo(request); return GDALVersionInfo(request);
} }
/*
computed extent type
*/
rt_extenttype
rt_util_extent_type(const char *name) {
if (strcmp(name, "UNION") == 0)
return ET_UNION;
else if (strcmp(name, "FIRST") == 0)
return ET_FIRST;
else if (strcmp(name, "SECOND") == 0)
return ET_SECOND;
else
return ET_INTERSECTION;
}
/*- rt_context -------------------------------------------------------*/ /*- rt_context -------------------------------------------------------*/
/* Functions definitions */ /* Functions definitions */
...@@ -682,111 +697,144 @@ d_binptr_to_pos(const uint8_t * const ptr, const uint8_t * const end, size_t siz ...@@ -682,111 +697,144 @@ d_binptr_to_pos(const uint8_t * const ptr, const uint8_t * const end, size_t siz
int int
rt_pixtype_size(rt_pixtype pixtype) { rt_pixtype_size(rt_pixtype pixtype) {
int pixbytes = -1; int pixbytes = -1;
switch (pixtype) {
case PT_1BB:
switch (pixtype) { case PT_2BUI:
case PT_1BB: case PT_4BUI:
case PT_2BUI: case PT_8BSI:
case PT_4BUI: case PT_8BUI:
case PT_8BSI: pixbytes = 1;
case PT_8BUI: break;
pixbytes = 1; case PT_16BSI:
break; case PT_16BUI:
case PT_16BSI: pixbytes = 2;
case PT_16BUI: break;
pixbytes = 2; case PT_32BSI:
break; case PT_32BUI:
case PT_32BSI: case PT_32BF:
case PT_32BUI: pixbytes = 4;
case PT_32BF: break;
pixbytes = 4; case PT_64BF:
break; pixbytes = 8;
case PT_64BF: break;
pixbytes = 8; default:
break; rterror("rt_pixtype_size: Unknown pixeltype %d", pixtype);
default: pixbytes = -1;
rterror("rt_pixtype_size: Unknown pixeltype %d", pixtype); break;
pixbytes = -1; }
break;
}
RASTER_DEBUGF(3, "Pixel type = %s and size = %d bytes",
rt_pixtype_name(pixtype), pixbytes);
RASTER_DEBUGF(3, "Pixel type = %s and size = %d bytes",
rt_pixtype_name(pixtype), pixbytes);
return pixbytes; return pixbytes;
} }
int int
rt_pixtype_alignment(rt_pixtype pixtype) { rt_pixtype_alignment(rt_pixtype pixtype) {
return rt_pixtype_size(pixtype);
return rt_pixtype_size(pixtype);
} }
rt_pixtype rt_pixtype
rt_pixtype_index_from_name(const char* pixname) { rt_pixtype_index_from_name(const char* pixname) {
assert(pixname && strlen(pixname) > 0); assert(pixname && strlen(pixname) > 0);
if (strcmp(pixname, "1BB") == 0)
if (strcmp(pixname, "1BB") == 0) return PT_1BB;
return PT_1BB; if (strcmp(pixname, "2BUI") == 0)
if (strcmp(pixname, "2BUI") == 0) return PT_2BUI;
return PT_2BUI; if (strcmp(pixname, "4BUI") == 0)
if (strcmp(pixname, "4BUI") == 0) return PT_4BUI;
return PT_4BUI; if (strcmp(pixname, "8BSI") == 0)
if (strcmp(pixname, "8BSI") == 0) return PT_8BSI;
return PT_8BSI; if (strcmp(pixname, "8BUI") == 0)
if (strcmp(pixname, "8BUI") == 0) return PT_8BUI;
return PT_8BUI; if (strcmp(pixname, "16BSI") == 0)
if (strcmp(pixname, "16BSI") == 0) return PT_16BSI;
return PT_16BSI; if (strcmp(pixname, "16BUI") == 0)
if (strcmp(pixname, "16BUI") == 0) return PT_16BUI;
return PT_16BUI; if (strcmp(pixname, "32BSI") == 0)
if (strcmp(pixname, "32BSI") == 0) return PT_32BSI;
return PT_32BSI; if (strcmp(pixname, "32BUI") == 0)
if (strcmp(pixname, "32BUI") == 0) return PT_32BUI;
return PT_32BUI; if (strcmp(pixname, "32BF") == 0)
if (strcmp(pixname, "32BF") == 0) return PT_32BF;
return PT_32BF; if (strcmp(pixname, "64BF") == 0)
if (strcmp(pixname, "64BF") == 0) return PT_64BF;
return PT_64BF;
return PT_END; return PT_END;
} }
const char* const char*
rt_pixtype_name(rt_pixtype pixtype) { rt_pixtype_name(rt_pixtype pixtype) {
switch (pixtype) {
case PT_1BB:
return "1BB";
case PT_2BUI:
return "2BUI";
case PT_4BUI:
return "4BUI";
case PT_8BSI:
return "8BSI";
case PT_8BUI:
return "8BUI";
case PT_16BSI:
return "16BSI";
case PT_16BUI:
return "16BUI";
case PT_32BSI:
return "32BSI";
case PT_32BUI:
return "32BUI";
case PT_32BF:
return "32BF";
case PT_64BF:
return "64BF";
default:
rterror("rt_pixtype_name: Unknown pixeltype %d", pixtype);
return "Unknown";
}
}
/**
* Return minimum value possible for pixel type
switch (pixtype) { *
case PT_1BB: * @param pixtype: the pixel type to get minimum possible value for
return "1BB"; *
case PT_2BUI: * @return the minimum possible value for the pixel type.
return "2BUI"; */
case PT_4BUI: double
return "4BUI"; rt_pixtype_get_min_value(rt_pixtype pixtype) {
case PT_8BSI: switch (pixtype) {
return "8BSI"; case PT_1BB:
case PT_8BUI: case PT_2BUI:
return "8BUI"; case PT_4BUI:
case PT_16BSI: case PT_8BUI: {
return "16BSI"; return (double) CHAR_MIN;
case PT_16BUI: }
return "16BUI"; case PT_8BSI: {
case PT_32BSI: return (double) SCHAR_MIN;
return "32BSI"; }
case PT_32BUI: case PT_16BSI:
return "32BUI"; case PT_16BUI: {
case PT_32BF: return (double) SHRT_MIN;
return "32BF"; }
case PT_64BF: case PT_32BSI:
return "64BF"; case PT_32BUI: {
default: return (double) INT_MIN;
rterror("rt_pixtype_name: Unknown pixeltype %d", pixtype); }
return "Unknown"; case PT_32BF: {
} return (double) -FLT_MAX;
}
case PT_64BF: {
return (double) -DBL_MAX;
}
default: {
rterror("rt_pixtype_get_min_value: Unknown pixeltype %d", pixtype);
return (double) CHAR_MIN;
}
}
} }
/*- rt_band ----------------------------------------------------------*/ /*- rt_band ----------------------------------------------------------*/
...@@ -1446,50 +1494,9 @@ rt_band_get_nodata(rt_band band) { ...@@ -1446,50 +1494,9 @@ rt_band_get_nodata(rt_band band) {
double double
rt_band_get_min_value(rt_band band) { rt_band_get_min_value(rt_band band) {
rt_pixtype pixtype = PT_END; assert(NULL != band);
assert(NULL != band);
pixtype = band->pixtype;
switch (pixtype) { return rt_pixtype_get_min_value(band->pixtype);
case PT_1BB:
case PT_2BUI:
case PT_4BUI:
case PT_8BUI:
{
return (double)CHAR_MIN;
}
case PT_8BSI:
{
return (double)SCHAR_MIN;
}
case PT_16BSI:
case PT_16BUI:
{
return (double)SHRT_MIN;
}
case PT_32BSI:
case PT_32BUI:
{
return (double)INT_MIN;
}
case PT_32BF:
{
return (double)-FLT_MAX;
}
case PT_64BF:
{
return (double)-DBL_MAX;
}
default:
{
rterror("rt_band_get_min_value: Unknown pixeltype %d", pixtype);
return (double)CHAR_MIN;
}
}
} }
......
...@@ -274,6 +274,15 @@ const char* rt_pixtype_name(rt_pixtype pixtype); ...@@ -274,6 +274,15 @@ const char* rt_pixtype_name(rt_pixtype pixtype);
/* Return pixel type index from human-readable name */ /* Return pixel type index from human-readable name */
rt_pixtype rt_pixtype_index_from_name(const char* pixname); rt_pixtype rt_pixtype_index_from_name(const char* pixname);
/**
* Return minimum value possible for pixel type
*
* @param pixtype: the pixel type to get minimum possible value for
*
* @return the minimum possible value for the pixel type.
*/
double rt_pixtype_get_min_value(rt_pixtype pixtype);
/*- rt_band ----------------------------------------------------------*/ /*- rt_band ----------------------------------------------------------*/
/** /**
...@@ -682,8 +691,6 @@ uint16_t rt_raster_get_height(rt_raster raster); ...@@ -682,8 +691,6 @@ uint16_t rt_raster_get_height(rt_raster raster);
*/ */
int32_t rt_raster_add_band(rt_raster raster, rt_band band, int index); int32_t rt_raster_add_band(rt_raster raster, rt_band band, int index);
/** /**
* Generate a new band data and add it to a raster. * Generate a new band data and add it to a raster.
* *
...@@ -1195,6 +1202,19 @@ rt_util_pixtype_to_gdal_datatype(rt_pixtype pt); ...@@ -1195,6 +1202,19 @@ rt_util_pixtype_to_gdal_datatype(rt_pixtype pt);
const char* const char*
rt_util_gdal_version(const char *request); rt_util_gdal_version(const char *request);
/*
computed extent type
*/
typedef enum {
ET_INTERSECTION = 0,
ET_UNION,
ET_FIRST,
ET_SECOND
} rt_extenttype;
rt_extenttype
rt_util_extent_type(const char *name);
/* /*
helper macros for consistent floating point equality checks helper macros for consistent floating point equality checks
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment