PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ pointArray_toGML3()

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

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

1910 {
1911  int i;
1912  char *ptr;
1916 
1917  ptr = output;
1918 
1919  if ( ! FLAGS_GET_Z(pa->flags) )
1920  {
1921  for (i=0; i<pa->npoints; i++)
1922  {
1923  const POINT2D *pt;
1924  pt = getPoint2d_cp(pa, i);
1925 
1926  if (fabs(pt->x) < OUT_MAX_DOUBLE)
1927  sprintf(x, "%.*f", precision, pt->x);
1928  else
1929  sprintf(x, "%g", pt->x);
1931 
1932  if (fabs(pt->y) < OUT_MAX_DOUBLE)
1933  sprintf(y, "%.*f", precision, pt->y);
1934  else
1935  sprintf(y, "%g", pt->y);
1937 
1938  if ( i ) ptr += sprintf(ptr, " ");
1939  if (IS_DEGREE(opts))
1940  ptr += sprintf(ptr, "%s %s", y, x);
1941  else
1942  ptr += sprintf(ptr, "%s %s", x, y);
1943  }
1944  }
1945  else
1946  {
1947  for (i=0; i<pa->npoints; i++)
1948  {
1949  const POINT3DZ *pt;
1950  pt = getPoint3dz_cp(pa, i);
1951 
1952  if (fabs(pt->x) < OUT_MAX_DOUBLE)
1953  sprintf(x, "%.*f", precision, pt->x);
1954  else
1955  sprintf(x, "%g", pt->x);
1957 
1958  if (fabs(pt->y) < OUT_MAX_DOUBLE)
1959  sprintf(y, "%.*f", precision, pt->y);
1960  else
1961  sprintf(y, "%g", pt->y);
1963 
1964  if (fabs(pt->z) < OUT_MAX_DOUBLE)
1965  sprintf(z, "%.*f", precision, pt->z);
1966  else
1967  sprintf(z, "%g", pt->z);
1969 
1970  if ( i ) ptr += sprintf(ptr, " ");
1971  if (IS_DEGREE(opts))
1972  ptr += sprintf(ptr, "%s %s %s", y, x, z);
1973  else
1974  ptr += sprintf(ptr, "%s %s %s", x, y, z);
1975  }
1976  }
1977 
1978  return ptr-output;
1979 }
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
#define IS_DEGREE(x)
Definition: liblwgeom.h:1545
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
opts
Definition: ovdump.py:44
Here is the call graph for this function:
Here is the caller graph for this function: