PostGIS  2.5.0dev-r@@SVN_REVISION@@
static void ptarray_to_wkt_sb ( const POINTARRAY ptarray,
stringbuffer_t sb,
int  precision,
uint8_t  variant 
)
static

Definition at line 83 of file lwout_wkt.c.

References POINTARRAY::flags, FLAGS_NDIMS, getPoint_internal(), lwprint_double(), POINTARRAY::npoints, OUT_DOUBLE_BUFFER_SIZE, stringbuffer_append(), WKT_EXTENDED, WKT_ISO, and WKT_NO_PARENS.

Referenced by lwcircstring_to_wkt_sb(), lwline_to_wkt_sb(), lwpoint_to_wkt_sb(), lwpoly_to_wkt_sb(), and lwtriangle_to_wkt_sb().

84 {
85  /* OGC only includes X/Y */
86  uint32_t dimensions = 2;
87  uint32_t i, j;
88  char coord[OUT_DOUBLE_BUFFER_SIZE];
89 
90  /* ISO and extended formats include all dimensions */
91  if ( variant & ( WKT_ISO | WKT_EXTENDED ) )
92  dimensions = FLAGS_NDIMS(ptarray->flags);
93 
94  /* Opening paren? */
95  if ( ! (variant & WKT_NO_PARENS) )
96  stringbuffer_append(sb, "(");
97 
98  /* Digits and commas */
99  for (i = 0; i < ptarray->npoints; i++)
100  {
101  double *dbl_ptr = (double*)getPoint_internal(ptarray, i);
102 
103  /* Commas before ever coord but the first */
104  if ( i > 0 )
105  stringbuffer_append(sb, ",");
106 
107  for (j = 0; j < dimensions; j++)
108  {
109  /* Spaces before every ordinate but the first */
110  if ( j > 0 )
111  stringbuffer_append(sb, " ");
112  lwprint_double(dbl_ptr[j],
113  precision,
114  coord,
116  stringbuffer_append(sb, coord);
117  }
118  }
119 
120  /* Closing paren? */
121  if ( ! (variant & WKT_NO_PARENS) )
122  stringbuffer_append(sb, ")");
123 }
int lwprint_double(double d, int maxdd, char *buf, size_t bufsize)
Definition: lwprint.c:488
#define WKT_NO_PARENS
uint8_t variant
Definition: cu_in_twkb.c:26
unsigned int uint32_t
Definition: uthash.h:78
#define WKT_ISO
Definition: liblwgeom.h:2068
uint8_t flags
Definition: liblwgeom.h:368
uint8_t precision
Definition: cu_in_twkb.c:25
void stringbuffer_append(stringbuffer_t *s, const char *a)
Append the specified string to the stringbuffer_t.
Definition: stringbuffer.c:134
#define WKT_EXTENDED
Definition: liblwgeom.h:2070
uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
Definition: ptarray.c:1743
#define OUT_DOUBLE_BUFFER_SIZE
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:151
uint32_t npoints
Definition: liblwgeom.h:370

Here is the call graph for this function:

Here is the caller graph for this function: