PostGIS  2.1.10dev-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 775 of file lwout_x3d.c.

References POINTARRAY::flags, FLAGS_GET_Z, getPoint2d_p(), getPoint4d_p(), 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().

776 {
777  int i;
778  char *ptr;
782 
783  ptr = output;
784 
785  if ( ! FLAGS_GET_Z(pa->flags) )
786  {
787  for (i=0; i<pa->npoints; i++)
788  {
790  if ( !is_closed || i < (pa->npoints - 1) )
791  {
792  POINT2D pt;
793  getPoint2d_p(pa, i, &pt);
794 
795  if (fabs(pt.x) < OUT_MAX_DOUBLE)
796  sprintf(x, "%.*f", precision, pt.x);
797  else
798  sprintf(x, "%g", pt.x);
800 
801  if (fabs(pt.y) < OUT_MAX_DOUBLE)
802  sprintf(y, "%.*f", precision, pt.y);
803  else
804  sprintf(y, "%g", pt.y);
806 
807  if ( i )
808  ptr += sprintf(ptr, " ");
809  ptr += sprintf(ptr, "%s %s", x, y);
810  }
811  }
812  }
813  else
814  {
815  for (i=0; i<pa->npoints; i++)
816  {
818  if ( !is_closed || i < (pa->npoints - 1) )
819  {
820  POINT4D pt;
821  getPoint4d_p(pa, i, &pt);
822 
823  if (fabs(pt.x) < OUT_MAX_DOUBLE)
824  sprintf(x, "%.*f", precision, pt.x);
825  else
826  sprintf(x, "%g", pt.x);
828 
829  if (fabs(pt.y) < OUT_MAX_DOUBLE)
830  sprintf(y, "%.*f", precision, pt.y);
831  else
832  sprintf(y, "%g", pt.y);
834 
835  if (fabs(pt.z) < OUT_MAX_DOUBLE)
836  sprintf(z, "%.*f", precision, pt.z);
837  else
838  sprintf(z, "%g", pt.z);
840 
841  if ( i )
842  ptr += sprintf(ptr, " ");
843 
844  ptr += sprintf(ptr, "%s %s %s", x, y, z);
845  }
846  }
847  }
848 
849  return ptr-output;
850 }
double x
Definition: liblwgeom.h:308
int npoints
Definition: liblwgeom.h:327
#define OUT_MAX_DOUBLE_PRECISION
void trim_trailing_zeros(char *num)
Definition: lwutil.c:200
double x
Definition: liblwgeom.h:284
uint8_t flags
Definition: liblwgeom.h:325
double y
Definition: liblwgeom.h:284
int getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point)
Definition: lwgeom_api.c:434
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:106
double z
Definition: liblwgeom.h:308
tuple x
Definition: pixval.py:53
#define OUT_MAX_DOUBLE
#define OUT_MAX_DIGS_DOUBLE
double y
Definition: liblwgeom.h:308
tuple y
Definition: pixval.py:54
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)
Definition: lwgeom_api.c:217

Here is the call graph for this function:

Here is the caller graph for this function: