PostGIS  2.5.2dev-r@@SVN_REVISION@@

◆ ptarray_to_x3d3_sb()

static int ptarray_to_x3d3_sb ( POINTARRAY pa,
int  precision,
int  opts,
int  is_closed,
stringbuffer_t sb 
)
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 502 of file lwout_x3d.c.

References POINTARRAY::flags, FLAGS_GET_Z, getPoint2d_p(), getPoint4d_p(), LW_SUCCESS, LW_X3D_FLIP_XY, lwprint_double(), POINTARRAY::npoints, OUT_DOUBLE_BUFFER_SIZE, stringbuffer_append(), stringbuffer_aprintf(), pixval::x, POINT2D::x, POINT4D::x, pixval::y, POINT2D::y, POINT4D::y, and POINT4D::z.

Referenced by asx3d3_line_coords_sb(), asx3d3_line_sb(), asx3d3_point_sb(), asx3d3_poly_sb(), and asx3d3_triangle_sb().

503 {
504  uint32_t i;
507  char z[OUT_DOUBLE_BUFFER_SIZE];
508 
509  if ( ! FLAGS_GET_Z(pa->flags) )
510  {
511  for (i=0; i<pa->npoints; i++)
512  {
514  if ( !is_closed || i < (pa->npoints - 1) )
515  {
516  POINT2D pt;
517  getPoint2d_p(pa, i, &pt);
518 
523 
524  if ( i ) stringbuffer_append(sb," ");
525 
526  if ( ( opts & LW_X3D_FLIP_XY) )
527  stringbuffer_aprintf(sb, "%s %s", y, x);
528  else
529  stringbuffer_aprintf(sb, "%s %s", x, y);
530  }
531  }
532  }
533  else
534  {
535  for (i=0; i<pa->npoints; i++)
536  {
538  if ( !is_closed || i < (pa->npoints - 1) )
539  {
540  POINT4D pt;
541  getPoint4d_p(pa, i, &pt);
542 
549 
550  if ( i ) stringbuffer_append(sb," ");
551 
552  if ( ( opts & LW_X3D_FLIP_XY) )
553  stringbuffer_aprintf(sb, "%s %s %s", y, x, z);
554  else
555  stringbuffer_aprintf(sb, "%s %s %s", x, y, z);
556  }
557  }
558  }
559 
560  return LW_SUCCESS;
561 }
double x
Definition: liblwgeom.h:354
int lwprint_double(double d, int maxdd, char *buf, size_t bufsize)
Definition: lwprint.c:490
#define LW_SUCCESS
Definition: liblwgeom.h:79
int stringbuffer_aprintf(stringbuffer_t *s, const char *fmt,...)
Appends a formatted string to the current string buffer, using the format and argument list provided...
Definition: stringbuffer.c:253
unsigned int uint32_t
Definition: uthash.h:78
double x
Definition: liblwgeom.h:330
uint8_t flags
Definition: liblwgeom.h:371
#define LW_X3D_FLIP_XY
Macros for specifying X3D options.
Definition: liblwgeom.h:1559
uint8_t precision
Definition: cu_in_twkb.c:25
double y
Definition: liblwgeom.h:330
#define FLAGS_GET_Z(flags)
Macros for manipulating the &#39;flags&#39; byte.
Definition: liblwgeom.h:139
double z
Definition: liblwgeom.h:354
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
Definition: lwgeom_api.c:113
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
Definition: lwgeom_api.c:338
void stringbuffer_append(stringbuffer_t *s, const char *a)
Append the specified string to the stringbuffer_t.
Definition: stringbuffer.c:134
#define OUT_DOUBLE_BUFFER_SIZE
double y
Definition: liblwgeom.h:354
opts
Definition: ovdump.py:44
uint32_t npoints
Definition: liblwgeom.h:373
Here is the call graph for this function:
Here is the caller graph for this function: