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

Definition at line 1393 of file lwout_gml.c.

References POINTARRAY::flags, FLAGS_GET_Z, getPoint2d_cp(), getPoint3dz_cp(), IS_DEGREE, 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 asgml3_line_buf(), asgml3_point_buf(), asgml3_poly_buf(), asgml3_triangle_buf(), and gbox_to_gml3().

1394 {
1395  int i;
1396  char *ptr;
1400 
1401  ptr = output;
1402 
1403  if ( ! FLAGS_GET_Z(pa->flags) )
1404  {
1405  for (i=0; i<pa->npoints; i++)
1406  {
1407  const POINT2D *pt;
1408  pt = getPoint2d_cp(pa, i);
1409 
1410  if (fabs(pt->x) < OUT_MAX_DOUBLE)
1411  sprintf(x, "%.*f", precision, pt->x);
1412  else
1413  sprintf(x, "%g", pt->x);
1415 
1416  if (fabs(pt->y) < OUT_MAX_DOUBLE)
1417  sprintf(y, "%.*f", precision, pt->y);
1418  else
1419  sprintf(y, "%g", pt->y);
1421 
1422  if ( i ) ptr += sprintf(ptr, " ");
1423  if (IS_DEGREE(opts))
1424  ptr += sprintf(ptr, "%s %s", y, x);
1425  else
1426  ptr += sprintf(ptr, "%s %s", x, y);
1427  }
1428  }
1429  else
1430  {
1431  for (i=0; i<pa->npoints; i++)
1432  {
1433  const POINT3DZ *pt;
1434  pt = getPoint3dz_cp(pa, i);
1435 
1436  if (fabs(pt->x) < OUT_MAX_DOUBLE)
1437  sprintf(x, "%.*f", precision, pt->x);
1438  else
1439  sprintf(x, "%g", pt->x);
1441 
1442  if (fabs(pt->y) < OUT_MAX_DOUBLE)
1443  sprintf(y, "%.*f", precision, pt->y);
1444  else
1445  sprintf(y, "%g", pt->y);
1447 
1448  if (fabs(pt->z) < OUT_MAX_DOUBLE)
1449  sprintf(z, "%.*f", precision, pt->z);
1450  else
1451  sprintf(z, "%g", pt->z);
1453 
1454  if ( i ) ptr += sprintf(ptr, " ");
1455  if (IS_DEGREE(opts))
1456  ptr += sprintf(ptr, "%s %s %s", y, x, z);
1457  else
1458  ptr += sprintf(ptr, "%s %s %s", x, y, z);
1459  }
1460  }
1461 
1462  return ptr-output;
1463 }
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
#define IS_DEGREE(x)
Definition: liblwgeom.h:1368
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: