#include #include #include "wkbtest.h" #define WKBZOFFSET 0x80000000 #define WKBMOFFSET 0x40000000 // DO NOT USE THESE decoding function (except for debugging purposes) // The code is NOT maintained and is thrown together // unsupported debugging function. // given a wkb input thats a geometrycollection, returns its size and prints out // its contents // // Its really messy - dont even think about using this for anything // // you shouldnt call this function; just call decode_wkb() and it will // call this function //#define DEBUG 1 void decode_wkb_collection(char *wkb,int *size); void swap_char(char *a,char *b) { char c; c = *a; *a=*b; *b=c; } void flip_endian_double(char *d) { swap_char(d+7, d); swap_char(d+6, d+1); swap_char(d+5, d+2); swap_char(d+4, d+3); } void flip_endian_int32(char *i) { swap_char (i+3,i); swap_char (i+2,i+1); } void decode_wkb_collection(char *wkb,int *size) { int offset =0; bool flipbytes; int total_size=0,sub_size; int numb_sub,t; bool first_one = TRUE; if (wkb[0] ==0 ) //big endian { if (BYTE_ORDER == LITTLE_ENDIAN) flipbytes= 1; else flipbytes= 0; } else //little { if (BYTE_ORDER == LITTLE_ENDIAN) flipbytes= 0; else flipbytes= 1; } memcpy(&numb_sub, wkb+5,4); if (flipbytes) flip_endian_int32( (char *) & numb_sub) ; printf("GEOMETRYCOLLECTION(\n"); offset = 9; for (t=0;t