PostGIS  2.2.7dev-r@@SVN_REVISION@@
static size_t pointArray_toX3D3 ( POINTARRAY pa,
char *  buf,
int  precision,
int  opts,
int  is_closed 
)
static

In X3D3, coordinates are separated by a space separator.

Only output the point if it is not the last point of a closed object or it is a non-closed type

Only output the point if it is not the last point of a closed object or it is a non-closed type

Definition at line 819 of file lwout_x3d.c.

References POINTARRAY::flags, FLAGS_GET_Z, getPoint2d_p(), getPoint4d_p(), LW_X3D_FLIP_XY, POINTARRAY::npoints, OUT_MAX_DIGS_DOUBLE, OUT_MAX_DOUBLE, OUT_MAX_DOUBLE_PRECISION, trim_trailing_zeros(), pixval::x, POINT2D::x, POINT4D::x, pixval::y, POINT2D::y, POINT4D::y, and POINT4D::z.

Referenced by asx3d3_line_buf(), asx3d3_line_coords(), asx3d3_point_buf(), asx3d3_poly_buf(), and asx3d3_triangle_buf().

820 {
821  int i;
822  char *ptr;
826 
827  ptr = output;
828 
829  if ( ! FLAGS_GET_Z(pa->flags) )
830  {
831  for (i=0; i<pa->npoints; i++)
832  {
834  if ( !is_closed || i < (pa->npoints - 1) )
835  {
836  POINT2D pt;
837  getPoint2d_p(pa, i, &pt);
838 
839  if (fabs(pt.x) < OUT_MAX_DOUBLE)
840  sprintf(x, "%.*f", precision, pt.x);
841  else
842  sprintf(x, "%g", pt.x);
844 
845  if (fabs(pt.y) < OUT_MAX_DOUBLE)
846  sprintf(y, "%.*f", precision, pt.y);
847  else
848  sprintf(y, "%g", pt.y);
850 
851  if ( i )
852  ptr += sprintf(ptr, " ");
853 
854  if ( ( opts & LW_X3D_FLIP_XY) )
855  ptr += sprintf(ptr, "%s %s", y, x);
856  else
857  ptr += sprintf(ptr, "%s %s", x, y);
858  }
859  }
860  }
861  else
862  {
863  for (i=0; i<pa->npoints; i++)
864  {
866  if ( !is_closed || i < (pa->npoints - 1) )
867  {
868  POINT4D pt;
869  getPoint4d_p(pa, i, &pt);
870 
871  if (fabs(pt.x) < OUT_MAX_DOUBLE)
872  sprintf(x, "%.*f", precision, pt.x);
873  else
874  sprintf(x, "%g", pt.x);
876 
877  if (fabs(pt.y) < OUT_MAX_DOUBLE)
878  sprintf(y, "%.*f", precision, pt.y);
879  else
880  sprintf(y, "%g", pt.y);
882 
883  if (fabs(pt.z) < OUT_MAX_DOUBLE)
884  sprintf(z, "%.*f", precision, pt.z);
885  else
886  sprintf(z, "%g", pt.z);
888 
889  if ( i )
890  ptr += sprintf(ptr, " ");
891 
892  if ( ( opts & LW_X3D_FLIP_XY) )
893  ptr += sprintf(ptr, "%s %s %s", y, x, z);
894  else
895  ptr += sprintf(ptr, "%s %s %s", x, y, z);
896  }
897  }
898  }
899 
900  return ptr-output;
901 }
double x
Definition: liblwgeom.h:336
int npoints
Definition: liblwgeom.h:355
#define OUT_MAX_DOUBLE_PRECISION
void trim_trailing_zeros(char *num)
Definition: lwutil.c:224
double x
Definition: liblwgeom.h:312
uint8_t flags
Definition: liblwgeom.h:353
#define LW_X3D_FLIP_XY
Macros for specifying X3D options.
Definition: liblwgeom.h:1487
uint8_t precision
Definition: cu_in_twkb.c:25
double y
Definition: liblwgeom.h:312
int getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point)
Definition: lwgeom_api.c:448
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:124
double z
Definition: liblwgeom.h:336
tuple x
Definition: pixval.py:53
#define OUT_MAX_DOUBLE
#define OUT_MAX_DIGS_DOUBLE
double y
Definition: liblwgeom.h:336
tuple y
Definition: pixval.py:54
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)
Definition: lwgeom_api.c:231

Here is the call graph for this function:

Here is the caller graph for this function: