PostGIS  2.1.10dev-r@@SVN_REVISION@@
static size_t asgml2_collection_buf ( const LWCOLLECTION col,
const char *  srs,
char *  output,
int  precision,
const char *  prefix 
)
static

Definition at line 568 of file lwout_gml.c.

References asgml2_line_buf(), asgml2_multi_buf(), asgml2_point_buf(), asgml2_poly_buf(), COLLECTIONTYPE, LWCOLLECTION::geoms, LINETYPE, lwgeom_is_collection(), LWCOLLECTION::ngeoms, POINTTYPE, POLYGONTYPE, and LWGEOM::type.

Referenced by asgml2_collection().

569 {
570  char *ptr;
571  int i;
572  LWGEOM *subgeom;
573 
574  ptr = output;
575 
576  /* Open outmost tag */
577  ptr += sprintf(ptr, "<%sMultiGeometry", prefix);
578  if ( srs ) ptr += sprintf(ptr, " srsName=\"%s\"", srs);
579 
580  if (!col->ngeoms) {
581  ptr += sprintf(ptr, "/>");
582  return (ptr-output);
583  }
584  ptr += sprintf(ptr, ">");
585 
586  for (i=0; i<col->ngeoms; i++)
587  {
588  subgeom = col->geoms[i];
589 
590  ptr += sprintf(ptr, "<%sgeometryMember>", prefix);
591  if (subgeom->type == POINTTYPE)
592  {
593  ptr += asgml2_point_buf((LWPOINT*)subgeom, 0, ptr, precision, prefix);
594  }
595  else if (subgeom->type == LINETYPE)
596  {
597  ptr += asgml2_line_buf((LWLINE*)subgeom, 0, ptr, precision, prefix);
598  }
599  else if (subgeom->type == POLYGONTYPE)
600  {
601  ptr += asgml2_poly_buf((LWPOLY*)subgeom, 0, ptr, precision, prefix);
602  }
603  else if (lwgeom_is_collection(subgeom))
604  {
605  if (subgeom->type == COLLECTIONTYPE)
606  ptr += asgml2_collection_buf((LWCOLLECTION*)subgeom, 0, ptr, precision, prefix);
607  else
608  ptr += asgml2_multi_buf((LWCOLLECTION*)subgeom, 0, ptr, precision, prefix);
609  }
610  ptr += sprintf(ptr, "</%sgeometryMember>", prefix);
611  }
612 
613  /* Close outmost tag */
614  ptr += sprintf(ptr, "</%sMultiGeometry>", prefix);
615 
616  return (ptr-output);
617 }
#define LINETYPE
Definition: liblwgeom.h:61
int lwgeom_is_collection(const LWGEOM *lwgeom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:947
#define POLYGONTYPE
Definition: liblwgeom.h:62
static size_t asgml2_multi_buf(const LWCOLLECTION *col, const char *srs, char *output, int precision, const char *prefix)
Definition: lwout_gml.c:447
LWGEOM ** geoms
Definition: liblwgeom.h:465
static size_t asgml2_point_buf(const LWPOINT *point, const char *srs, char *output, int precision, const char *prefix)
Definition: lwout_gml.c:263
static size_t asgml2_poly_buf(const LWPOLY *poly, const char *srs, char *output, int precision, const char *prefix)
Definition: lwout_gml.c:360
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:60
static size_t asgml2_collection_buf(const LWCOLLECTION *col, const char *srs, char *output, int precision, const char *prefix)
Definition: lwout_gml.c:568
uint8_t type
Definition: liblwgeom.h:352
static size_t asgml2_line_buf(const LWLINE *line, const char *srs, char *output, int precision, const char *prefix)
Definition: lwout_gml.c:306
#define COLLECTIONTYPE
Definition: liblwgeom.h:66

Here is the call graph for this function:

Here is the caller graph for this function: