]> granicus.if.org Git - postgis/commitdiff
Chip now handles data with different datasizes (datum_size)
authorDavid Blasby <dblasby@gmail.com>
Wed, 21 Nov 2001 19:39:09 +0000 (19:39 +0000)
committerDavid Blasby <dblasby@gmail.com>
Wed, 21 Nov 2001 19:39:09 +0000 (19:39 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@109 b70326c6-7e19-0410-871a-916f4a2858ee

postgis.h
postgis_chip.c

index 1d02fbc1e35e40c8fb2f6627dec219a88a4870c2..4bfd2d4497c8965d4a3310472a95ff9d2aa2e242 100644 (file)
--- a/postgis.h
+++ b/postgis.h
@@ -192,14 +192,17 @@ typedef struct {
        char            future[8]; // for future expantion 
        
        int32   datatype;        // 1 = float32 (XDR), 2 = unsigned int (XDR), 3 = RGBA, 4 = signed integer (XDR)
-                                        // 11 = float32(NDR), 22 = unsigned int (NDR), 44 = signed integer (NDR)
+                                        // 101 = float32(NDR), 102 = unsigned int (NDR), 104 = signed integer (NDR)
+                                       // 6 = signed 16 bit (XDR), 7 = unsigned 16 bit(XDR), 8 = unsigned 8(XDR/NDR)
+                                       // 106 = signed 16 bit (NDR), 107 = unsigned 16 bit (NDR), 108 = unsigned 8 (XDR/NDR) 
        int32   height;
        int32   width;
        int32   compression;    // 0 = no compression
                // this is provided for convenience, it should be set to 
                //  sizeof(chip) bytes into the struct because the serialized form is:
                //    <header><data>
-       unsigned int *data;             // data[0] = bottm left, data[width] = 1st pixel, 2nd row
+       void *data;             // data[0] = bottm left, data[width] = 1st pixel, 2nd row
+                                               // THIS MAY NOT ACTUALLY BE 32 bit data!!! watch out!
 } CHIP;
 
 
index 58acdf1eb79fe1d0421d5d49bdbc2625d561d59d..bee6ad61174e418148ced302dd6dbb5e3ac7a578 100644 (file)
@@ -29,6 +29,7 @@ Datum CHIP_in(PG_FUNCTION_ARGS)
        int                     size;
        int                     t;
        int                     input_str_len;
+       int                     datum_size;
 
 //printf("chip_in called\n");
 
@@ -88,7 +89,18 @@ Datum CHIP_in(PG_FUNCTION_ARGS)
                elog(ERROR,"CHIP_in parser - bad data (endian flag != 1)!");
                PG_RETURN_NULL();       
        }
-       if (result->size != (sizeof(CHIP) + 4 * result->width*result->height) )
+       datum_size = 4;
+
+       if ( (result->datatype == 6) || (result->datatype == 7) || (result->datatype == 106) || (result->datatype == 107) )
+       {
+               datum_size = 2;
+       }
+       if ( (result->datatype == 8) || (result->datatype == 108) )
+       {
+               datum_size=1;
+       }
+
+       if (result->size != (sizeof(CHIP) + datum_size * result->width*result->height) )
        {
                elog(ERROR,"CHIP_in parser - bad data (actual size != computed size)!");
                PG_RETURN_NULL();
@@ -177,9 +189,6 @@ Datum compression_chip(PG_FUNCTION_ARGS)
 }
 
 
-
-
-
 PG_FUNCTION_INFO_V1(height_chip);
 Datum height_chip(PG_FUNCTION_ARGS)
 {