PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ ptarray_to_wkt_sb()

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.

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

References POINTARRAY::flags, FLAGS_NDIMS, getPoint_internal(), lwprint_double(), POINTARRAY::npoints, precision, stringbuffer_append(), variant, 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().

Here is the call graph for this function:
Here is the caller graph for this function: