PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ pointArray_svg_abs()

static size_t pointArray_svg_abs ( POINTARRAY pa,
char *  output,
int  close_ring,
int  precision 
)
static

Returns maximum size of rendered pointarray in bytes.

Definition at line 646 of file lwout_svg.c.

References getPoint2d_p(), POINTARRAY::npoints, OUT_MAX_DIGS_DOUBLE, OUT_MAX_DOUBLE, OUT_MAX_DOUBLE_PRECISION, trim_trailing_zeros(), pixval::x, POINT2D::x, pixval::y, and POINT2D::y.

Referenced by assvg_line_buf(), and assvg_polygon_buf().

647 {
648  int i, end;
649  char *ptr;
652  POINT2D pt;
653 
654  ptr = output;
655 
656  if (close_ring) end = pa->npoints;
657  else end = pa->npoints - 1;
658 
659  for (i=0 ; i < end ; i++)
660  {
661  getPoint2d_p(pa, i, &pt);
662 
663  if (fabs(pt.x) < OUT_MAX_DOUBLE)
664  sprintf(x, "%.*f", precision, pt.x);
665  else
666  sprintf(x, "%g", pt.x);
668 
669  /* SVG Y axis is reversed, an no need to transform 0 into -0 */
670  if (fabs(pt.y) < OUT_MAX_DOUBLE)
671  sprintf(y, "%.*f", precision, fabs(pt.y) ? pt.y * -1:pt.y);
672  else
673  sprintf(y, "%g", fabs(pt.y) ? pt.y * -1:pt.y);
675 
676  if (i == 1) ptr += sprintf(ptr, " L ");
677  else if (i) ptr += sprintf(ptr, " ");
678  ptr += sprintf(ptr,"%s %s", x, y);
679  }
680 
681  return (ptr-output);
682 }
int npoints
Definition: liblwgeom.h:371
#define OUT_MAX_DOUBLE_PRECISION
void trim_trailing_zeros(char *num)
Definition: lwutil.c:254
double x
Definition: liblwgeom.h:328
uint8_t precision
Definition: cu_in_twkb.c:25
double y
Definition: liblwgeom.h:328
int getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point)
Definition: lwgeom_api.c:347
#define OUT_MAX_DOUBLE
#define OUT_MAX_DIGS_DOUBLE
Here is the call graph for this function:
Here is the caller graph for this function: