Ticket #1161: gidx_to_string.patch

File gidx_to_string.patch, 2.3 KB (added by bnordgren, 13 years ago)

Applies against r7784

  • libpgcommon/gserialized_gist.c

    diff --git a/libpgcommon/gserialized_gist.c b/libpgcommon/gserialized_gist.c
    index 6ff3a81..d28643a 100644
    a b  
    2222#include "gserialized_gist.h"
    2323
    2424
     25/* Generate human readable form for GIDX. */
     26#if POSTGIS_DEBUG_LEVEL > 0
     27char* gidx_to_string(GIDX *a)
     28{
     29        char *str, *rv;
     30        int i, ndims;
     31
     32        if ( a == NULL )
     33                return pstrdup("<NULLPTR>");
     34
     35        str = (char*)palloc(128);
     36        rv = str;
     37        ndims = GIDX_NDIMS(a);
     38
     39        str += sprintf(str, "GIDX(");
     40        for ( i = 0; i < ndims; i++ )
     41                str += sprintf(str, " %.12g", GIDX_GET_MIN(a,i));
     42        str += sprintf(str, ",");
     43        for ( i = 0; i < ndims; i++ )
     44                str += sprintf(str, " %.12g", GIDX_GET_MAX(a,i));
     45        str += sprintf(str, " )");
     46
     47        return rv;
     48}
     49#endif
     50
    2551
    2652/**
    2753* Given a #GSERIALIZED datum, as quickly as possible (peaking into the top
  • libpgcommon/gserialized_gist.h

    diff --git a/libpgcommon/gserialized_gist.h b/libpgcommon/gserialized_gist.h
    index 2c12bd6..72b73d3 100644
    a b GIDX* gidx_from_gbox(GBOX box);  
    5858/* Increase the size of a GIDX */
    5959void gidx_expand(GIDX *a, float d);
    6060
     61
     62/* Generate human readable form for GIDX. */
     63#if POSTGIS_DEBUG_LEVEL > 0
     64char* gidx_to_string(GIDX *a) ;
     65#endif
     66
     67
    6168/* Returns number of dimensions for this GIDX */
    6269#define GIDX_NDIMS(gidx) ((VARSIZE((gidx)) - VARHDRSZ) / (2 * sizeof(float)))
    6370/* Minimum accessor. */
  • postgis/gserialized_gist_nd.c

    diff --git a/postgis/gserialized_gist_nd.c b/postgis/gserialized_gist_nd.c
    index 6e5929b..55cebb2 100644
    a b Datum gserialized_within(PG_FUNCTION_ARGS);  
    7878typedef bool (*gidx_predicate)(GIDX *a, GIDX *b);
    7979
    8080
    81 /* Generate human readable form for GIDX. */
    82 #if POSTGIS_DEBUG_LEVEL > 0
    83 static char* gidx_to_string(GIDX *a)
    84 {
    85         char *str, *rv;
    86         int i, ndims;
    87 
    88         if ( a == NULL )
    89                 return pstrdup("<NULLPTR>");
    90 
    91         str = (char*)palloc(128);
    92         rv = str;
    93         ndims = GIDX_NDIMS(a);
    94 
    95         str += sprintf(str, "GIDX(");
    96         for ( i = 0; i < ndims; i++ )
    97                 str += sprintf(str, " %.12g", GIDX_GET_MIN(a,i));
    98         str += sprintf(str, ",");
    99         for ( i = 0; i < ndims; i++ )
    100                 str += sprintf(str, " %.12g", GIDX_GET_MAX(a,i));
    101         str += sprintf(str, " )");
    102 
    103         return rv;
    104 }
    105 #endif
    106 
    10781/* Allocate a new copy of GIDX */
    10882static GIDX* gidx_copy(GIDX *b)
    10983{