PostGIS 3.6.2dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ nd_box_to_json()

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 362 of file gserialized_estimate.c.

363{
364 char *rv;
365 int i;
367
368 stringbuffer_append(sb, "{\"min\":[");
369 for ( i = 0; i < ndims; i++ )
370 {
371 if ( i ) stringbuffer_append(sb, ",");
372 stringbuffer_aprintf(sb, "%.6g", nd_box->min[i]);
373 }
374 stringbuffer_append(sb, "],\"max\":[");
375 for ( i = 0; i < ndims; i++ )
376 {
377 if ( i ) stringbuffer_append(sb, ",");
378 stringbuffer_aprintf(sb, "%.6g", nd_box->max[i]);
379 }
380 stringbuffer_append(sb, "]}");
381
384 return rv;
385}
stringbuffer_t * stringbuffer_create(void)
Allocate a new stringbuffer_t.
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.
char * stringbuffer_getstringcopy(stringbuffer_t *s)
Returns a newly allocated string large enough to contain the current state of the string.
void stringbuffer_destroy(stringbuffer_t *s)
Free the stringbuffer_t and all memory managed within it.
static void stringbuffer_append(stringbuffer_t *s, const char *a)
Append the specified string to the stringbuffer_t.

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().

Here is the call graph for this function:
Here is the caller graph for this function: