PostGIS  2.2.7dev-r@@SVN_REVISION@@
static int lwpoly_to_kml2_sb ( const LWPOLY poly,
int  precision,
const char *  prefix,
stringbuffer_t sb 
)
static

Definition at line 138 of file lwout_kml.c.

References LW_FAILURE, LW_SUCCESS, LWPOLY::nrings, ptarray_to_kml2_sb(), LWPOLY::rings, and stringbuffer_aprintf().

Referenced by lwgeom_to_kml2_sb().

139 {
140  int i, rv;
141 
142  /* Open polygon */
143  if ( stringbuffer_aprintf(sb, "<%sPolygon>", prefix) < 0 ) return LW_FAILURE;
144  for ( i = 0; i < poly->nrings; i++ )
145  {
146  /* Inner or outer ring opening tags */
147  if( i )
148  rv = stringbuffer_aprintf(sb, "<%sinnerBoundaryIs><%sLinearRing><%scoordinates>", prefix, prefix, prefix);
149  else
150  rv = stringbuffer_aprintf(sb, "<%souterBoundaryIs><%sLinearRing><%scoordinates>", prefix, prefix, prefix);
151  if ( rv < 0 ) return LW_FAILURE;
152 
153  /* Coordinate array */
154  if ( ptarray_to_kml2_sb(poly->rings[i], precision, sb) == LW_FAILURE ) return LW_FAILURE;
155 
156  /* Inner or outer ring closing tags */
157  if( i )
158  rv = stringbuffer_aprintf(sb, "</%scoordinates></%sLinearRing></%sinnerBoundaryIs>", prefix, prefix, prefix);
159  else
160  rv = stringbuffer_aprintf(sb, "</%scoordinates></%sLinearRing></%souterBoundaryIs>", prefix, prefix, prefix);
161  if ( rv < 0 ) return LW_FAILURE;
162  }
163  /* Close polygon */
164  if ( stringbuffer_aprintf(sb, "</%sPolygon>", prefix) < 0 ) return LW_FAILURE;
165 
166  return LW_SUCCESS;
167 }
#define LW_SUCCESS
Definition: liblwgeom.h:65
#define LW_FAILURE
Definition: liblwgeom.h:64
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:246
POINTARRAY ** rings
Definition: liblwgeom.h:441
uint8_t precision
Definition: cu_in_twkb.c:25
int nrings
Definition: liblwgeom.h:439
static int ptarray_to_kml2_sb(const POINTARRAY *pa, int precision, stringbuffer_t *sb)
Definition: lwout_kml.c:82

Here is the call graph for this function:

Here is the caller graph for this function: