PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwpoly_to_kml2_sb()

static int lwpoly_to_kml2_sb ( const LWPOLY poly,
int  precision,
const char *  prefix,
stringbuffer_t sb 
)
static

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

151 {
152  int i, rv;
153 
154  /* Open polygon */
155  if ( stringbuffer_aprintf(sb, "<%sPolygon>", prefix) < 0 ) return LW_FAILURE;
156  for ( i = 0; i < poly->nrings; i++ )
157  {
158  /* Inner or outer ring opening tags */
159  if( i )
160  rv = stringbuffer_aprintf(sb, "<%sinnerBoundaryIs><%sLinearRing><%scoordinates>", prefix, prefix, prefix);
161  else
162  rv = stringbuffer_aprintf(sb, "<%souterBoundaryIs><%sLinearRing><%scoordinates>", prefix, prefix, prefix);
163  if ( rv < 0 ) return LW_FAILURE;
164 
165  /* Coordinate array */
166  if ( ptarray_to_kml2_sb(poly->rings[i], precision, sb) == LW_FAILURE ) return LW_FAILURE;
167 
168  /* Inner or outer ring closing tags */
169  if( i )
170  rv = stringbuffer_aprintf(sb, "</%scoordinates></%sLinearRing></%sinnerBoundaryIs>", prefix, prefix, prefix);
171  else
172  rv = stringbuffer_aprintf(sb, "</%scoordinates></%sLinearRing></%souterBoundaryIs>", prefix, prefix, prefix);
173  if ( rv < 0 ) return LW_FAILURE;
174  }
175  /* Close polygon */
176  if ( stringbuffer_aprintf(sb, "</%sPolygon>", prefix) < 0 ) return LW_FAILURE;
177 
178  return LW_SUCCESS;
179 }
#define LW_SUCCESS
Definition: liblwgeom.h:80
#define LW_FAILURE
Definition: liblwgeom.h:79
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:253
POINTARRAY ** rings
Definition: liblwgeom.h:457
uint8_t precision
Definition: cu_in_twkb.c:25
int nrings
Definition: liblwgeom.h:455
static int ptarray_to_kml2_sb(const POINTARRAY *pa, int precision, stringbuffer_t *sb)
Definition: lwout_kml.c:94
Here is the call graph for this function:
Here is the caller graph for this function: