PostGIS  2.3.7dev-r@@SVN_REVISION@@
static size_t pointArray_toGML2 ( POINTARRAY pa,
char *  buf,
int  precision 
)
static

Definition at line 662 of file lwout_gml.c.

References POINTARRAY::flags, FLAGS_GET_Z, getPoint2d_cp(), getPoint3dz_cp(), POINTARRAY::npoints, OUT_MAX_DIGS_DOUBLE, OUT_MAX_DOUBLE, OUT_MAX_DOUBLE_PRECISION, trim_trailing_zeros(), pixval::x, POINT2D::x, POINT3DZ::x, pixval::y, POINT2D::y, POINT3DZ::y, and POINT3DZ::z.

Referenced by asgml2_line_buf(), asgml2_point_buf(), asgml2_poly_buf(), and gbox_to_gml2().

663 {
664  int i;
665  char *ptr;
669 
670  ptr = output;
671 
672  if ( ! FLAGS_GET_Z(pa->flags) )
673  {
674  for (i=0; i<pa->npoints; i++)
675  {
676  const POINT2D *pt;
677  pt = getPoint2d_cp(pa, i);
678 
679  if (fabs(pt->x) < OUT_MAX_DOUBLE)
680  sprintf(x, "%.*f", precision, pt->x);
681  else
682  sprintf(x, "%g", pt->x);
684 
685  if (fabs(pt->y) < OUT_MAX_DOUBLE)
686  sprintf(y, "%.*f", precision, pt->y);
687  else
688  sprintf(y, "%g", pt->y);
690 
691  if ( i ) ptr += sprintf(ptr, " ");
692  ptr += sprintf(ptr, "%s,%s", x, y);
693  }
694  }
695  else
696  {
697  for (i=0; i<pa->npoints; i++)
698  {
699  const POINT3DZ *pt;
700  pt = getPoint3dz_cp(pa, i);
701 
702  if (fabs(pt->x) < OUT_MAX_DOUBLE)
703  sprintf(x, "%.*f", precision, pt->x);
704  else
705  sprintf(x, "%g", pt->x);
707 
708  if (fabs(pt->y) < OUT_MAX_DOUBLE)
709  sprintf(y, "%.*f", precision, pt->y);
710  else
711  sprintf(y, "%g", pt->y);
713 
714  if (fabs(pt->z) < OUT_MAX_DOUBLE)
715  sprintf(z, "%.*f", precision, pt->z);
716  else
717  sprintf(z, "%g", pt->z);
719 
720  if ( i ) ptr += sprintf(ptr, " ");
721  ptr += sprintf(ptr, "%s,%s,%s", x, y, z);
722  }
723  }
724 
725  return ptr-output;
726 }
double z
Definition: liblwgeom.h:333
double y
Definition: liblwgeom.h:333
double x
Definition: liblwgeom.h:333
int npoints
Definition: liblwgeom.h:370
#define OUT_MAX_DOUBLE_PRECISION
void trim_trailing_zeros(char *num)
Definition: lwutil.c:252
double x
Definition: liblwgeom.h:327
const POINT2D * getPoint2d_cp(const POINTARRAY *pa, int n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from...
Definition: lwgeom_api.c:485
uint8_t flags
Definition: liblwgeom.h:368
uint8_t precision
Definition: cu_in_twkb.c:25
double y
Definition: liblwgeom.h:327
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:139
tuple x
Definition: pixval.py:53
#define OUT_MAX_DOUBLE
const POINT3DZ * getPoint3dz_cp(const POINTARRAY *pa, int n)
Returns a POINT3DZ pointer into the POINTARRAY serialized_ptlist, suitable for reading from...
Definition: lwgeom_api.c:499
#define OUT_MAX_DIGS_DOUBLE
tuple y
Definition: pixval.py:54

Here is the call graph for this function:

Here is the caller graph for this function: