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

490 {
491  LWPOLY *poly;
492  int i, j;
493  char *ptr=output;
494 
495  ptr += sprintf(ptr, "{\"type\":\"MultiPolygon\",");
496  if (srs) ptr += asgeojson_srs_buf(ptr, srs);
497  if (bbox) ptr += asgeojson_bbox_buf(ptr, bbox, FLAGS_GET_Z(mpoly->flags), precision);
498  ptr += sprintf(ptr, "\"coordinates\":[");
499  for (i=0; i<mpoly->ngeoms; i++)
500  {
501  if (i) ptr += sprintf(ptr, ",");
502  ptr += sprintf(ptr, "[");
503  poly = mpoly->geoms[i];
504  for (j=0 ; j < poly->nrings ; j++)
505  {
506  if (j) ptr += sprintf(ptr, ",");
507  ptr += sprintf(ptr, "[");
508  ptr += pointArray_to_geojson(poly->rings[j], ptr, precision);
509  ptr += sprintf(ptr, "]");
510  }
511  ptr += sprintf(ptr, "]");
512  }
513  ptr += sprintf(ptr, "]}");
514 
515  return (ptr - output);
516 }
static size_t asgeojson_srs_buf(char *output, char *srs)
LWPOLY ** geoms
Definition: liblwgeom.h:496
uint8_t flags
Definition: liblwgeom.h:491
POINTARRAY ** rings
Definition: liblwgeom.h:457
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:455
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:140
int ngeoms
Definition: liblwgeom.h:494
Here is the call graph for this function:
Here is the caller graph for this function: