PostGIS  3.1.6dev-r@@SVN_REVISION@@

◆ pointArray_svg_rel()

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

Definition at line 529 of file lwout_svg.c.

530 {
531  int i, end;
532  char *ptr;
533  char sx[OUT_DOUBLE_BUFFER_SIZE];
534  char sy[OUT_DOUBLE_BUFFER_SIZE];
535  const POINT2D *pt;
536 
537  double f = 1.0;
538  double dx, dy, x, y, accum_x, accum_y;
539 
540  ptr = output;
541 
542  if (precision >= 0)
543  {
544  f = pow(10, precision);
545  }
546 
547  if (close_ring) end = pa->npoints;
548  else end = pa->npoints - 1;
549 
550  /* Starting point */
551  pt = getPoint2d_cp(pa, 0);
552 
553  x = round(pt->x*f)/f;
554  y = round(pt->y*f)/f;
555 
556  lwprint_double(x, precision, sx);
557  lwprint_double(-y, precision, sy);
558  ptr += sprintf(ptr,"%s %s l", sx, sy);
559 
560  /* accum */
561  accum_x = x;
562  accum_y = y;
563 
564  /* All the following ones */
565  for (i=1 ; i < end ; i++)
566  {
567  // lpt = pt;
568 
569  pt = getPoint2d_cp(pa, i);
570 
571  x = round(pt->x*f)/f;
572  y = round(pt->y*f)/f;
573  dx = x - accum_x;
574  dy = y - accum_y;
575 
576  lwprint_double(dx, precision, sx);
577  lwprint_double(-dy, precision, sy);
578 
579  accum_x += dx;
580  accum_y += dy;
581 
582  ptr += sprintf(ptr," %s %s", sx, sy);
583  }
584 
585  return (ptr-output);
586 }
static uint8_t precision
Definition: cu_in_twkb.c:25
#define OUT_DOUBLE_BUFFER_SIZE
int lwprint_double(double d, int maxdd, char *buf)
Definition: lwprint.c:463
static const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
Definition: lwinline.h:101
double y
Definition: liblwgeom.h:404
double x
Definition: liblwgeom.h:404
uint32_t npoints
Definition: liblwgeom.h:441

References getPoint2d_cp(), lwprint_double(), POINTARRAY::npoints, OUT_DOUBLE_BUFFER_SIZE, precision, POINT2D::x, pixval::x, POINT2D::y, and pixval::y.

Referenced by assvg_line_buf(), and assvg_polygon_buf().

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