PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ asgeojson_collection()

static void asgeojson_collection ( stringbuffer_t sb,
const LWCOLLECTION col,
const geojson_opts opts 
)
static

Collection Geometry.

Definition at line 308 of file lwout_geojson.c.

309 {
310  uint32_t i, ngeoms = col->ngeoms;
311 
312  /* subgeometries don't get boxes or srs */
313  geojson_opts subopts = *opts;
314  subopts.bbox = NULL;
315  subopts.srs = NULL;
316  subopts.isCollectionElement = LW_TRUE;
317 
318  stringbuffer_append_len(sb, "{\"type\":\"GeometryCollection\",", 29);
319  asgeojson_srs(sb, opts);
320  if (col->ngeoms) asgeojson_bbox(sb, opts);
321  stringbuffer_append_len(sb, "\"geometries\":[", 14);
322 
323  if (lwgeom_is_empty((LWGEOM*)col))
324  ngeoms = 0;
325 
326  for (i=0; i<ngeoms; i++)
327  {
328  if (i) stringbuffer_append_char(sb, ',');
329  asgeojson_geometry(sb, col->geoms[i], &subopts);
330  }
331 
332  stringbuffer_append_len(sb, "]}", 2);
333  return;
334 }
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:93
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition: lwinline.h:203
static void asgeojson_srs(stringbuffer_t *sb, const geojson_opts *opts)
Definition: lwout_geojson.c:95
static void asgeojson_geometry(stringbuffer_t *sb, const LWGEOM *geom, const geojson_opts *opts)
static void asgeojson_bbox(stringbuffer_t *sb, const geojson_opts *opts)
opts
Definition: ovdump.py:45
static void stringbuffer_append_char(stringbuffer_t *s, char c)
Definition: stringbuffer.h:119
static void stringbuffer_append_len(stringbuffer_t *s, const char *a, size_t alen)
Append the specified string to the stringbuffer_t using known length.
Definition: stringbuffer.h:93
uint32_t ngeoms
Definition: liblwgeom.h:580
const char * srs
Definition: lwout_geojson.c:34
int isCollectionElement
Definition: lwout_geojson.c:38

References asgeojson_bbox(), asgeojson_geometry(), asgeojson_srs(), geojson_opts::bbox, LWCOLLECTION::geoms, geojson_opts::isCollectionElement, LW_TRUE, lwgeom_is_empty(), LWCOLLECTION::ngeoms, ovdump::opts, geojson_opts::srs, stringbuffer_append_char(), and stringbuffer_append_len().

Referenced by asgeojson_geometry().

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