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

◆ ptarray_to_kml2_sb()

static int ptarray_to_kml2_sb ( const POINTARRAY pa,
int  precision,
stringbuffer_t sb 
)
static

Definition at line 99 of file lwout_kml.c.

100{
101 uint32_t i, j;
102 uint32_t dims = FLAGS_GET_Z(pa->flags) ? 3 : 2;
103 POINT4D pt;
104 double *d;
105
106 for ( i = 0; i < pa->npoints; i++ )
107 {
108 getPoint4d_p(pa, i, &pt);
109 d = (double*)(&pt);
110 if ( i ) stringbuffer_append(sb," ");
111 for (j = 0; j < dims; j++)
112 {
113 if ( j ) stringbuffer_append(sb,",");
114 if( fabs(d[j]) < OUT_MAX_DOUBLE )
115 {
116 if ( stringbuffer_aprintf(sb, "%.*f", precision, d[j]) < 0 ) return LW_FAILURE;
117 }
118 else
119 {
120 if ( stringbuffer_aprintf(sb, "%g", d[j]) < 0 ) return LW_FAILURE;
121 }
123 }
124 }
125 return LW_SUCCESS;
126}
static uint8_t precision
Definition cu_in_twkb.c:25
#define LW_FAILURE
Definition liblwgeom.h:110
#define LW_SUCCESS
Definition liblwgeom.h:111
#define FLAGS_GET_Z(flags)
Definition liblwgeom.h:179
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
Definition lwgeom_api.c:125
#define OUT_MAX_DOUBLE
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.
int stringbuffer_trim_trailing_zeroes(stringbuffer_t *s)
Trims zeroes off the end of the last number in the stringbuffer.
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_GET_Z, getPoint4d_p(), LW_FAILURE, LW_SUCCESS, POINTARRAY::npoints, OUT_MAX_DOUBLE, precision, stringbuffer_append(), stringbuffer_aprintf(), and stringbuffer_trim_trailing_zeroes().

Referenced by lwline_to_kml2_sb(), lwpoint_to_kml2_sb(), lwpoly_to_kml2_sb(), and lwtriangle_to_kml2_sb().

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