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

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

638 {
639  int i;
640  char *ptr;
644 
645  ptr = output;
646 
647  if ( ! FLAGS_GET_Z(pa->flags) )
648  {
649  for (i=0; i<pa->npoints; i++)
650  {
651  const POINT2D *pt;
652  pt = getPoint2d_cp(pa, i);
653 
654  if (fabs(pt->x) < OUT_MAX_DOUBLE)
655  sprintf(x, "%.*f", precision, pt->x);
656  else
657  sprintf(x, "%g", pt->x);
659 
660  if (fabs(pt->y) < OUT_MAX_DOUBLE)
661  sprintf(y, "%.*f", precision, pt->y);
662  else
663  sprintf(y, "%g", pt->y);
665 
666  if ( i ) ptr += sprintf(ptr, " ");
667  ptr += sprintf(ptr, "%s,%s", x, y);
668  }
669  }
670  else
671  {
672  for (i=0; i<pa->npoints; i++)
673  {
674  const POINT3DZ *pt;
675  pt = getPoint3dz_cp(pa, i);
676 
677  if (fabs(pt->x) < OUT_MAX_DOUBLE)
678  sprintf(x, "%.*f", precision, pt->x);
679  else
680  sprintf(x, "%g", pt->x);
682 
683  if (fabs(pt->y) < OUT_MAX_DOUBLE)
684  sprintf(y, "%.*f", precision, pt->y);
685  else
686  sprintf(y, "%g", pt->y);
688 
689  if (fabs(pt->z) < OUT_MAX_DOUBLE)
690  sprintf(z, "%.*f", precision, pt->z);
691  else
692  sprintf(z, "%g", pt->z);
694 
695  if ( i ) ptr += sprintf(ptr, " ");
696  ptr += sprintf(ptr, "%s,%s,%s", x, y, z);
697  }
698  }
699 
700  return ptr-output;
701 }
double z
Definition: liblwgeom.h:290
double y
Definition: liblwgeom.h:290
double x
Definition: liblwgeom.h:290
int npoints
Definition: liblwgeom.h:327
#define OUT_MAX_DOUBLE_PRECISION
void trim_trailing_zeros(char *num)
Definition: lwutil.c:200
double x
Definition: liblwgeom.h:284
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:458
uint8_t flags
Definition: liblwgeom.h:325
double y
Definition: liblwgeom.h:284
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:106
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:472
#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: