PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ lwprint_double()

static int lwprint_double ( double  d,
int  maxdd,
char *  buf,
size_t  bufsize 
)
static

Definition at line 681 of file lwout_geojson.c.

References OUT_MAX_DOUBLE, and OUT_MAX_DOUBLE_PRECISION.

Referenced by pointArray_to_geojson().

682 {
683  double ad = fabs(d);
684  int ndd = ad < 1 ? 0 : floor(log10(ad))+1; /* non-decimal digits */
685  if (fabs(d) < OUT_MAX_DOUBLE)
686  {
687  if ( maxdd > (OUT_MAX_DOUBLE_PRECISION - ndd) ) maxdd -= ndd;
688  return snprintf(buf, bufsize, "%.*f", maxdd, d);
689  }
690  else
691  {
692  return snprintf(buf, bufsize, "%g", d);
693  }
694 }
#define OUT_MAX_DOUBLE_PRECISION
#define OUT_MAX_DOUBLE
Here is the caller graph for this function: