PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ asgml2_collection_buf()

static size_t asgml2_collection_buf ( const LWCOLLECTION col,
const char *  srs,
char *  output,
int  precision,
const char *  prefix 
)
static

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

580 {
581  char *ptr;
582  int i;
583  LWGEOM *subgeom;
584 
585  ptr = output;
586 
587  /* Open outmost tag */
588  ptr += sprintf(ptr, "<%sMultiGeometry", prefix);
589  if ( srs ) ptr += sprintf(ptr, " srsName=\"%s\"", srs);
590 
591  if (!col->ngeoms)
592  {
593  ptr += sprintf(ptr, "/>");
594  return (ptr-output);
595  }
596  ptr += sprintf(ptr, ">");
597 
598  for (i=0; i<col->ngeoms; i++)
599  {
600  subgeom = col->geoms[i];
601 
602  ptr += sprintf(ptr, "<%sgeometryMember>", prefix);
603  if (subgeom->type == POINTTYPE)
604  {
605  ptr += asgml2_point_buf((LWPOINT*)subgeom, 0, ptr, precision, prefix);
606  }
607  else if (subgeom->type == LINETYPE)
608  {
609  ptr += asgml2_line_buf((LWLINE*)subgeom, 0, ptr, precision, prefix);
610  }
611  else if (subgeom->type == POLYGONTYPE)
612  {
613  ptr += asgml2_poly_buf((LWPOLY*)subgeom, 0, ptr, precision, prefix);
614  }
615  else if (lwgeom_is_collection(subgeom))
616  {
617  if (subgeom->type == COLLECTIONTYPE)
618  ptr += asgml2_collection_buf((LWCOLLECTION*)subgeom, 0, ptr, precision, prefix);
619  else
620  ptr += asgml2_multi_buf((LWCOLLECTION*)subgeom, 0, ptr, precision, prefix);
621  }
622  ptr += sprintf(ptr, "</%sgeometryMember>", prefix);
623  }
624 
625  /* Close outmost tag */
626  ptr += sprintf(ptr, "</%sMultiGeometry>", prefix);
627 
628  return (ptr-output);
629 }
#define LINETYPE
Definition: liblwgeom.h:71
int lwgeom_is_collection(const LWGEOM *lwgeom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:991
#define POLYGONTYPE
Definition: liblwgeom.h:72
static size_t asgml2_multi_buf(const LWCOLLECTION *col, const char *srs, char *output, int precision, const char *prefix)
Definition: lwout_gml.c:457
LWGEOM ** geoms
Definition: liblwgeom.h:493
uint8_t precision
Definition: cu_in_twkb.c:25
static size_t asgml2_point_buf(const LWPOINT *point, const char *srs, char *output, int precision, const char *prefix)
Definition: lwout_gml.c:270
static size_t asgml2_poly_buf(const LWPOLY *poly, const char *srs, char *output, int precision, const char *prefix)
Definition: lwout_gml.c:369
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:70
static size_t asgml2_collection_buf(const LWCOLLECTION *col, const char *srs, char *output, int precision, const char *prefix)
Definition: lwout_gml.c:579
uint8_t type
Definition: liblwgeom.h:380
static size_t asgml2_line_buf(const LWLINE *line, const char *srs, char *output, int precision, const char *prefix)
Definition: lwout_gml.c:314
#define COLLECTIONTYPE
Definition: liblwgeom.h:76
Here is the call graph for this function:
Here is the caller graph for this function: