PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ 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
#define WKT_EXTENDED
Definition liblwgeom.h:2132
#define FLAGS_NDIMS(flags)
Definition liblwgeom.h:193
#define WKT_ISO
Definition liblwgeom.h:2130
#define WKT_NO_PARENS
int lwprint_double(double d, int maxdd, char *buf, size_t bufsize)
Definition lwprint.c:492
static uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
Definition lwinline.h:67
static void stringbuffer_append(stringbuffer_t *s, const char *a)
Append the specified string to the stringbuffer_t.
lwflags_t flags
Definition liblwgeom.h:417
uint32_t npoints
Definition liblwgeom.h:413

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: