PostGIS  3.0.6dev-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 174 of file lwout_kml.c.

175 {
176  uint32_t i;
177  int rv;
178 
179  /* Open polygon */
180  if ( stringbuffer_aprintf(sb, "<%sPolygon>", prefix) < 0 ) return LW_FAILURE;
181  for ( i = 0; i < poly->nrings; i++ )
182  {
183  /* Inner or outer ring opening tags */
184  if( i )
185  rv = stringbuffer_aprintf(sb, "<%sinnerBoundaryIs><%sLinearRing><%scoordinates>", prefix, prefix, prefix);
186  else
187  rv = stringbuffer_aprintf(sb, "<%souterBoundaryIs><%sLinearRing><%scoordinates>", prefix, prefix, prefix);
188  if ( rv < 0 ) return LW_FAILURE;
189 
190  /* Coordinate array */
191  if ( ptarray_to_kml2_sb(poly->rings[i], precision, sb) == LW_FAILURE ) return LW_FAILURE;
192 
193  /* Inner or outer ring closing tags */
194  if( i )
195  rv = stringbuffer_aprintf(sb, "</%scoordinates></%sLinearRing></%sinnerBoundaryIs>", prefix, prefix, prefix);
196  else
197  rv = stringbuffer_aprintf(sb, "</%scoordinates></%sLinearRing></%souterBoundaryIs>", prefix, prefix, prefix);
198  if ( rv < 0 ) return LW_FAILURE;
199  }
200  /* Close polygon */
201  if ( stringbuffer_aprintf(sb, "</%sPolygon>", prefix) < 0 ) return LW_FAILURE;
202 
203  return LW_SUCCESS;
204 }
static uint8_t precision
Definition: cu_in_twkb.c:25
#define LW_FAILURE
Definition: liblwgeom.h:110
#define LW_SUCCESS
Definition: liblwgeom.h:111
static int ptarray_to_kml2_sb(const POINTARRAY *pa, int precision, stringbuffer_t *sb)
Definition: lwout_kml.c:99
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:217
POINTARRAY ** rings
Definition: liblwgeom.h:505
uint32_t nrings
Definition: liblwgeom.h:510

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: