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

◆ pointArray_svg_rel()

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

Definition at line 550 of file lwout_svg.c.

551{
552 int i, end;
553 char *ptr;
554 char sx[OUT_DOUBLE_BUFFER_SIZE];
555 char sy[OUT_DOUBLE_BUFFER_SIZE];
556 const POINT2D *pt;
557
558 double f = 1.0;
559 double dx, dy, x, y, accum_x, accum_y;
560
561 ptr = output;
562
563 if (precision >= 0)
564 {
565 f = pow(10, precision);
566 }
567
568 if (close_ring) end = pa->npoints;
569 else end = pa->npoints - 1;
570
571 /* Starting point */
572 pt = getPoint2d_cp(pa, 0);
573
574 x = round(pt->x*f)/f;
575 y = round(pt->y*f)/f;
576
579 ptr += sprintf(ptr,"%s %s l", sx, sy);
580
581 /* accum */
582 accum_x = x;
583 accum_y = y;
584
585 /* All the following ones */
586 for (i=1 ; i < end ; i++)
587 {
588 // lpt = pt;
589
590 pt = getPoint2d_cp(pa, i);
591
592 x = round(pt->x*f)/f;
593 y = round(pt->y*f)/f;
594 dx = x - accum_x;
595 dy = y - accum_y;
596
599
600 accum_x += dx;
601 accum_y += dy;
602
603 ptr += sprintf(ptr," %s %s", sx, sy);
604 }
605
606 return (ptr-output);
607}
static uint8_t precision
Definition cu_in_twkb.c:25
#define OUT_DOUBLE_BUFFER_SIZE
int lwprint_double(double d, int maxdd, char *buf, size_t bufsize)
Definition lwprint.c:492
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:91
double y
Definition liblwgeom.h:376
double x
Definition liblwgeom.h:376
uint32_t npoints
Definition liblwgeom.h:413

References getPoint2d_cp(), lwprint_double(), POINTARRAY::npoints, OUT_DOUBLE_BUFFER_SIZE, precision, POINT2D::x, and POINT2D::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: