PostGIS  2.4.9dev-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.

References POINTARRAY::flags, FLAGS_NDIMS, getPoint_internal(), POINTARRAY::npoints, stringbuffer_append(), stringbuffer_aprintf(), 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  int dimensions = 2;
87  int i, j;
88 
89  /* ISO and extended formats include all dimensions */
90  if ( variant & ( WKT_ISO | WKT_EXTENDED ) )
91  dimensions = FLAGS_NDIMS(ptarray->flags);
92 
93  /* Opening paren? */
94  if ( ! (variant & WKT_NO_PARENS) )
95  stringbuffer_append(sb, "(");
96 
97  /* Digits and commas */
98  for (i = 0; i < ptarray->npoints; i++)
99  {
100  double *dbl_ptr = (double*)getPoint_internal(ptarray, i);
101 
102  /* Commas before ever coord but the first */
103  if ( i > 0 )
104  stringbuffer_append(sb, ",");
105 
106  for (j = 0; j < dimensions; j++)
107  {
108  /* Spaces before every ordinate but the first */
109  if ( j > 0 )
110  stringbuffer_append(sb, " ");
111  stringbuffer_aprintf(sb, "%.*g", precision, dbl_ptr[j]);
112  }
113  }
114 
115  /* Closing paren? */
116  if ( ! (variant & WKT_NO_PARENS) )
117  stringbuffer_append(sb, ")");
118 }
#define WKT_NO_PARENS
uint8_t variant
Definition: cu_in_twkb.c:26
int npoints
Definition: liblwgeom.h:371
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
#define WKT_ISO
Definition: liblwgeom.h:2083
uint8_t flags
Definition: liblwgeom.h:369
uint8_t * getPoint_internal(const POINTARRAY *pa, int n)
Definition: ptarray.c:1753
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:2085
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:152
Here is the call graph for this function:
Here is the caller graph for this function: