PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ asgeojson_multipolygon_buf()

static size_t asgeojson_multipolygon_buf ( const LWMPOLY mpoly,
char *  srs,
char *  output,
GBOX bbox,
int  precision 
)
static

Definition at line 475 of file lwout_geojson.c.

References asgeojson_bbox_buf(), asgeojson_srs_buf(), LWMPOLY::flags, FLAGS_GET_Z, LWMPOLY::geoms, LWMPOLY::ngeoms, LWPOLY::nrings, pointArray_to_geojson(), and LWPOLY::rings.

Referenced by asgeojson_geom_buf(), and asgeojson_multipolygon().

476 {
477  LWPOLY *poly;
478  int i, j;
479  char *ptr=output;
480 
481  ptr += sprintf(ptr, "{\"type\":\"MultiPolygon\",");
482  if (srs) ptr += asgeojson_srs_buf(ptr, srs);
483  if (bbox) ptr += asgeojson_bbox_buf(ptr, bbox, FLAGS_GET_Z(mpoly->flags), precision);
484  ptr += sprintf(ptr, "\"coordinates\":[");
485  for (i=0; i<mpoly->ngeoms; i++)
486  {
487  if (i) ptr += sprintf(ptr, ",");
488  ptr += sprintf(ptr, "[");
489  poly = mpoly->geoms[i];
490  for (j=0 ; j < poly->nrings ; j++)
491  {
492  if (j) ptr += sprintf(ptr, ",");
493  ptr += sprintf(ptr, "[");
494  ptr += pointArray_to_geojson(poly->rings[j], ptr, precision);
495  ptr += sprintf(ptr, "]");
496  }
497  ptr += sprintf(ptr, "]");
498  }
499  ptr += sprintf(ptr, "]}");
500 
501  return (ptr - output);
502 }
static size_t asgeojson_srs_buf(char *output, char *srs)
Definition: lwout_geojson.c:93
LWPOLY ** geoms
Definition: liblwgeom.h:480
uint8_t flags
Definition: liblwgeom.h:475
POINTARRAY ** rings
Definition: liblwgeom.h:441
uint8_t precision
Definition: cu_in_twkb.c:25
static size_t asgeojson_bbox_buf(char *output, GBOX *bbox, int hasz, int precision)
int nrings
Definition: liblwgeom.h:439
static size_t pointArray_to_geojson(POINTARRAY *pa, char *buf, int precision)
#define FLAGS_GET_Z(flags)
Macros for manipulating the &#39;flags&#39; byte.
Definition: liblwgeom.h:124
int ngeoms
Definition: liblwgeom.h:478
Here is the call graph for this function:
Here is the caller graph for this function: