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

Definition at line 69 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().

70 {
71  /* OGC only includes X/Y */
72  int dimensions = 2;
73  int i, j;
74 
75  /* ISO and extended formats include all dimensions */
76  if ( variant & ( WKT_ISO | WKT_EXTENDED ) )
77  dimensions = FLAGS_NDIMS(ptarray->flags);
78 
79  /* Opening paren? */
80  if ( ! (variant & WKT_NO_PARENS) )
81  stringbuffer_append(sb, "(");
82 
83  /* Digits and commas */
84  for (i = 0; i < ptarray->npoints; i++)
85  {
86  double *dbl_ptr = (double*)getPoint_internal(ptarray, i);
87 
88  /* Commas before ever coord but the first */
89  if ( i > 0 )
90  stringbuffer_append(sb, ",");
91 
92  for (j = 0; j < dimensions; j++)
93  {
94  /* Spaces before every ordinate but the first */
95  if ( j > 0 )
96  stringbuffer_append(sb, " ");
97  stringbuffer_aprintf(sb, "%.*g", precision, dbl_ptr[j]);
98  }
99  }
100 
101  /* Closing paren? */
102  if ( ! (variant & WKT_NO_PARENS) )
103  stringbuffer_append(sb, ")");
104 }
#define WKT_NO_PARENS
int npoints
Definition: liblwgeom.h:327
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:247
#define WKT_ISO
Definition: liblwgeom.h:1776
uint8_t flags
Definition: liblwgeom.h:325
uint8_t * getPoint_internal(const POINTARRAY *pa, int n)
Definition: ptarray.c:1645
void stringbuffer_append(stringbuffer_t *s, const char *a)
Append the specified string to the stringbuffer_t.
Definition: stringbuffer.c:128
#define WKT_EXTENDED
Definition: liblwgeom.h:1778
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:118

Here is the call graph for this function:

Here is the caller graph for this function: