PostGIS  2.4.9dev-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 592 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().

593 {
594  char *ptr;
595  int i;
596  LWGEOM *subgeom;
597 
598  ptr = output;
599 
600  /* Open outmost tag */
601  ptr += sprintf(ptr, "<%sMultiGeometry", prefix);
602  if ( srs ) ptr += sprintf(ptr, " srsName=\"%s\"", srs);
603 
604  if (!col->ngeoms)
605  {
606  ptr += sprintf(ptr, "/>");
607  return (ptr-output);
608  }
609  ptr += sprintf(ptr, ">");
610 
611  for (i=0; i<col->ngeoms; i++)
612  {
613  subgeom = col->geoms[i];
614 
615  ptr += sprintf(ptr, "<%sgeometryMember>", prefix);
616  if (subgeom->type == POINTTYPE)
617  {
618  ptr += asgml2_point_buf((LWPOINT*)subgeom, 0, ptr, precision, prefix);
619  }
620  else if (subgeom->type == LINETYPE)
621  {
622  ptr += asgml2_line_buf((LWLINE*)subgeom, 0, ptr, precision, prefix);
623  }
624  else if (subgeom->type == POLYGONTYPE)
625  {
626  ptr += asgml2_poly_buf((LWPOLY*)subgeom, 0, ptr, precision, prefix);
627  }
628  else if (lwgeom_is_collection(subgeom))
629  {
630  if (subgeom->type == COLLECTIONTYPE)
631  ptr += asgml2_collection_buf((LWCOLLECTION*)subgeom, 0, ptr, precision, prefix);
632  else
633  ptr += asgml2_multi_buf((LWCOLLECTION*)subgeom, 0, ptr, precision, prefix);
634  }
635  ptr += sprintf(ptr, "</%sgeometryMember>", prefix);
636  }
637 
638  /* Close outmost tag */
639  ptr += sprintf(ptr, "</%sMultiGeometry>", prefix);
640 
641  return (ptr-output);
642 }
#define LINETYPE
Definition: liblwgeom.h:86
int lwgeom_is_collection(const LWGEOM *lwgeom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1040
#define POLYGONTYPE
Definition: liblwgeom.h:87
static size_t asgml2_multi_buf(const LWCOLLECTION *col, const char *srs, char *output, int precision, const char *prefix)
Definition: lwout_gml.c:470
LWGEOM ** geoms
Definition: liblwgeom.h:509
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:283
static size_t asgml2_poly_buf(const LWPOLY *poly, const char *srs, char *output, int precision, const char *prefix)
Definition: lwout_gml.c:382
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
static size_t asgml2_collection_buf(const LWCOLLECTION *col, const char *srs, char *output, int precision, const char *prefix)
Definition: lwout_gml.c:592
uint8_t type
Definition: liblwgeom.h:396
static size_t asgml2_line_buf(const LWLINE *line, const char *srs, char *output, int precision, const char *prefix)
Definition: lwout_gml.c:327
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
Here is the call graph for this function:
Here is the caller graph for this function: