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

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

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

Here is the call graph for this function:

Here is the caller graph for this function: