PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ pointArray_toX3D3()

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 840 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().

841 {
842  int i;
843  char *ptr;
847 
848  ptr = output;
849 
850  if ( ! FLAGS_GET_Z(pa->flags) )
851  {
852  for (i=0; i<pa->npoints; i++)
853  {
855  if ( !is_closed || i < (pa->npoints - 1) )
856  {
857  POINT2D pt;
858  getPoint2d_p(pa, i, &pt);
859 
860  if (fabs(pt.x) < OUT_MAX_DOUBLE)
861  sprintf(x, "%.*f", precision, pt.x);
862  else
863  sprintf(x, "%g", pt.x);
865 
866  if (fabs(pt.y) < OUT_MAX_DOUBLE)
867  sprintf(y, "%.*f", precision, pt.y);
868  else
869  sprintf(y, "%g", pt.y);
871 
872  if ( i )
873  ptr += sprintf(ptr, " ");
874 
875  if ( ( opts & LW_X3D_FLIP_XY) )
876  ptr += sprintf(ptr, "%s %s", y, x);
877  else
878  ptr += sprintf(ptr, "%s %s", x, y);
879  }
880  }
881  }
882  else
883  {
884  for (i=0; i<pa->npoints; i++)
885  {
887  if ( !is_closed || i < (pa->npoints - 1) )
888  {
889  POINT4D pt;
890  getPoint4d_p(pa, i, &pt);
891 
892  if (fabs(pt.x) < OUT_MAX_DOUBLE)
893  sprintf(x, "%.*f", precision, pt.x);
894  else
895  sprintf(x, "%g", pt.x);
897 
898  if (fabs(pt.y) < OUT_MAX_DOUBLE)
899  sprintf(y, "%.*f", precision, pt.y);
900  else
901  sprintf(y, "%g", pt.y);
903 
904  if (fabs(pt.z) < OUT_MAX_DOUBLE)
905  sprintf(z, "%.*f", precision, pt.z);
906  else
907  sprintf(z, "%g", pt.z);
909 
910  if ( i )
911  ptr += sprintf(ptr, " ");
912 
913  if ( ( opts & LW_X3D_FLIP_XY) )
914  ptr += sprintf(ptr, "%s %s %s", y, x, z);
915  else
916  ptr += sprintf(ptr, "%s %s %s", x, y, z);
917  }
918  }
919  }
920 
921  return ptr-output;
922 }
double x
Definition: liblwgeom.h:352
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
uint8_t flags
Definition: liblwgeom.h:369
#define LW_X3D_FLIP_XY
Macros for specifying X3D options.
Definition: liblwgeom.h:1553
uint8_t precision
Definition: cu_in_twkb.c:25
double y
Definition: liblwgeom.h:328
int getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point)
Definition: lwgeom_api.c:347
#define FLAGS_GET_Z(flags)
Macros for manipulating the &#39;flags&#39; byte.
Definition: liblwgeom.h:140
double z
Definition: liblwgeom.h:352
#define OUT_MAX_DOUBLE
#define OUT_MAX_DIGS_DOUBLE
double y
Definition: liblwgeom.h:352
opts
Definition: ovdump.py:44
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)
Definition: lwgeom_api.c:122
Here is the call graph for this function:
Here is the caller graph for this function: