PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ pointArray_toGML2()

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:334
double y
Definition: liblwgeom.h:334
double x
Definition: liblwgeom.h:334
int npoints
Definition: liblwgeom.h:371
#define OUT_MAX_DOUBLE_PRECISION
void trim_trailing_zeros(char *num)
Definition: lwutil.c:254
double x
Definition: liblwgeom.h:328
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:373
uint8_t flags
Definition: liblwgeom.h:369
uint8_t precision
Definition: cu_in_twkb.c:25
double y
Definition: liblwgeom.h:328
#define FLAGS_GET_Z(flags)
Macros for manipulating the &#39;flags&#39; byte.
Definition: liblwgeom.h:140
#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:387
#define OUT_MAX_DIGS_DOUBLE
Here is the call graph for this function:
Here is the caller graph for this function: