PostGIS  2.2.7dev-r@@SVN_REVISION@@
static char* nd_box_to_json ( const ND_BOX nd_box,
int  ndims 
)
static

Convert an ND_BOX to a JSON string for printing.

Definition at line 370 of file gserialized_estimate.c.

References ND_BOX_T::max, ND_BOX_T::min, stringbuffer_append(), stringbuffer_aprintf(), stringbuffer_create(), stringbuffer_destroy(), and stringbuffer_getstringcopy().

Referenced by compute_gserialized_stats_mode(), estimate_join_selectivity(), estimate_selectivity(), nd_box_overlap(), and nd_stats_to_json().

371 {
372  char *rv;
373  int i;
375 
376  stringbuffer_append(sb, "{\"min\":[");
377  for ( i = 0; i < ndims; i++ )
378  {
379  if ( i ) stringbuffer_append(sb, ",");
380  stringbuffer_aprintf(sb, "%.6g", nd_box->min[i]);
381  }
382  stringbuffer_append(sb, "],\"max\":[");
383  for ( i = 0; i < ndims; i++ )
384  {
385  if ( i ) stringbuffer_append(sb, ",");
386  stringbuffer_aprintf(sb, "%.6g", nd_box->max[i]);
387  }
388  stringbuffer_append(sb, "]}");
389 
392  return rv;
393 }
stringbuffer_t * stringbuffer_create(void)
Allocate a new stringbuffer_t.
Definition: stringbuffer.c:46
char * stringbuffer_getstringcopy(stringbuffer_t *s)
Returns a newly allocated string large enough to contain the current state of the string...
Definition: stringbuffer.c:153
int stringbuffer_aprintf(stringbuffer_t *s, const char *fmt,...)
Appends a formatted string to the current string buffer, using the format and argument list provided...
Definition: stringbuffer.c:246
float4 max[ND_DIMS]
void stringbuffer_append(stringbuffer_t *s, const char *a)
Append the specified string to the stringbuffer_t.
Definition: stringbuffer.c:127
void stringbuffer_destroy(stringbuffer_t *s)
Free the stringbuffer_t and all memory managed within it.
Definition: stringbuffer.c:71
float4 min[ND_DIMS]

Here is the call graph for this function:

Here is the caller graph for this function: