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

Definition at line 649 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().

650 {
651  int i;
652  char *ptr;
656 
657  ptr = output;
658 
659  if ( ! FLAGS_GET_Z(pa->flags) )
660  {
661  for (i=0; i<pa->npoints; i++)
662  {
663  const POINT2D *pt;
664  pt = getPoint2d_cp(pa, i);
665 
666  if (fabs(pt->x) < OUT_MAX_DOUBLE)
667  sprintf(x, "%.*f", precision, pt->x);
668  else
669  sprintf(x, "%g", pt->x);
671 
672  if (fabs(pt->y) < OUT_MAX_DOUBLE)
673  sprintf(y, "%.*f", precision, pt->y);
674  else
675  sprintf(y, "%g", pt->y);
677 
678  if ( i ) ptr += sprintf(ptr, " ");
679  ptr += sprintf(ptr, "%s,%s", x, y);
680  }
681  }
682  else
683  {
684  for (i=0; i<pa->npoints; i++)
685  {
686  const POINT3DZ *pt;
687  pt = getPoint3dz_cp(pa, i);
688 
689  if (fabs(pt->x) < OUT_MAX_DOUBLE)
690  sprintf(x, "%.*f", precision, pt->x);
691  else
692  sprintf(x, "%g", pt->x);
694 
695  if (fabs(pt->y) < OUT_MAX_DOUBLE)
696  sprintf(y, "%.*f", precision, pt->y);
697  else
698  sprintf(y, "%g", pt->y);
700 
701  if (fabs(pt->z) < OUT_MAX_DOUBLE)
702  sprintf(z, "%.*f", precision, pt->z);
703  else
704  sprintf(z, "%g", pt->z);
706 
707  if ( i ) ptr += sprintf(ptr, " ");
708  ptr += sprintf(ptr, "%s,%s,%s", x, y, z);
709  }
710  }
711 
712  return ptr-output;
713 }
double z
Definition: liblwgeom.h:318
double y
Definition: liblwgeom.h:318
double x
Definition: liblwgeom.h:318
int npoints
Definition: liblwgeom.h:355
#define OUT_MAX_DOUBLE_PRECISION
void trim_trailing_zeros(char *num)
Definition: lwutil.c:224
double x
Definition: liblwgeom.h:312
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:472
uint8_t flags
Definition: liblwgeom.h:353
uint8_t precision
Definition: cu_in_twkb.c:25
double y
Definition: liblwgeom.h:312
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:124
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:486
#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: