PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ pointArray_toGML3()

static size_t pointArray_toGML3 ( POINTARRAY pa,
char *  buf,
int  precision,
int  opts 
)
static

Definition at line 1896 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_circstring_buf(), asgml3_compound_buf(), asgml3_curvepoly_buf(), asgml3_line_buf(), asgml3_point_buf(), asgml3_poly_buf(), asgml3_triangle_buf(), and gbox_to_gml3().

1897 {
1898  int i;
1899  char *ptr;
1903 
1904  ptr = output;
1905 
1906  if ( ! FLAGS_GET_Z(pa->flags) )
1907  {
1908  for (i=0; i<pa->npoints; i++)
1909  {
1910  const POINT2D *pt;
1911  pt = getPoint2d_cp(pa, i);
1912 
1913  if (fabs(pt->x) < OUT_MAX_DOUBLE)
1914  sprintf(x, "%.*f", precision, pt->x);
1915  else
1916  sprintf(x, "%g", pt->x);
1918 
1919  if (fabs(pt->y) < OUT_MAX_DOUBLE)
1920  sprintf(y, "%.*f", precision, pt->y);
1921  else
1922  sprintf(y, "%g", pt->y);
1924 
1925  if ( i ) ptr += sprintf(ptr, " ");
1926  if (IS_DEGREE(opts))
1927  ptr += sprintf(ptr, "%s %s", y, x);
1928  else
1929  ptr += sprintf(ptr, "%s %s", x, y);
1930  }
1931  }
1932  else
1933  {
1934  for (i=0; i<pa->npoints; i++)
1935  {
1936  const POINT3DZ *pt;
1937  pt = getPoint3dz_cp(pa, i);
1938 
1939  if (fabs(pt->x) < OUT_MAX_DOUBLE)
1940  sprintf(x, "%.*f", precision, pt->x);
1941  else
1942  sprintf(x, "%g", pt->x);
1944 
1945  if (fabs(pt->y) < OUT_MAX_DOUBLE)
1946  sprintf(y, "%.*f", precision, pt->y);
1947  else
1948  sprintf(y, "%g", pt->y);
1950 
1951  if (fabs(pt->z) < OUT_MAX_DOUBLE)
1952  sprintf(z, "%.*f", precision, pt->z);
1953  else
1954  sprintf(z, "%g", pt->z);
1956 
1957  if ( i ) ptr += sprintf(ptr, " ");
1958  if (IS_DEGREE(opts))
1959  ptr += sprintf(ptr, "%s %s %s", y, x, z);
1960  else
1961  ptr += sprintf(ptr, "%s %s %s", x, y, z);
1962  }
1963  }
1964 
1965  return ptr-output;
1966 }
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
#define IS_DEGREE(x)
Definition: liblwgeom.h:1479
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 &#39;flags&#39; byte.
Definition: liblwgeom.h:124
#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
opts
Definition: ovdump.py:44
Here is the call graph for this function:
Here is the caller graph for this function: