PostGIS  3.4.0dev-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 165 of file lwout_kml.c.

166 {
167  uint32_t i;
168  int rv;
169 
170  /* Open polygon */
171  if ( stringbuffer_aprintf(sb, "<%sPolygon>", prefix) < 0 ) return LW_FAILURE;
172  for ( i = 0; i < poly->nrings; i++ )
173  {
174  /* Inner or outer ring opening tags */
175  if( i )
176  rv = stringbuffer_aprintf(sb, "<%sinnerBoundaryIs><%sLinearRing><%scoordinates>", prefix, prefix, prefix);
177  else
178  rv = stringbuffer_aprintf(sb, "<%souterBoundaryIs><%sLinearRing><%scoordinates>", prefix, prefix, prefix);
179  if ( rv < 0 ) return LW_FAILURE;
180 
181  /* Coordinate array */
182  if ( ptarray_to_kml2_sb(poly->rings[i], precision, sb) == LW_FAILURE ) return LW_FAILURE;
183 
184  /* Inner or outer ring closing tags */
185  if( i )
186  rv = stringbuffer_aprintf(sb, "</%scoordinates></%sLinearRing></%sinnerBoundaryIs>", prefix, prefix, prefix);
187  else
188  rv = stringbuffer_aprintf(sb, "</%scoordinates></%sLinearRing></%souterBoundaryIs>", prefix, prefix, prefix);
189  if ( rv < 0 ) return LW_FAILURE;
190  }
191  /* Close polygon */
192  if ( stringbuffer_aprintf(sb, "</%sPolygon>", prefix) < 0 ) return LW_FAILURE;
193 
194  return LW_SUCCESS;
195 }
static uint8_t precision
Definition: cu_in_twkb.c:25
#define LW_FAILURE
Definition: liblwgeom.h:96
#define LW_SUCCESS
Definition: liblwgeom.h:97
static int ptarray_to_kml2_sb(const POINTARRAY *pa, int precision, stringbuffer_t *sb)
Definition: lwout_kml.c:98
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:519
uint32_t nrings
Definition: liblwgeom.h:524

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

Referenced by lwgeom_to_kml2_sb().

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