static size_t asgeojson_collection_buf(GEOSGeom col, char *srs, char *output, bbox3D *bbox, int precision) { int i, ngeoms = GEOSGetNumGeometries(col); char *ptr=output; GEOSGeom subgeom; ptr += sprintf(ptr, "{\"type\":\"GeometryCollection\","); if (srs) ptr += asgeojson_srs_buf(ptr, srs); if (ngeoms && bbox) ptr += asgeojson_bbox_buf(ptr, bbox, GEOS_getWKBOutputDims(col) == 3, precision); ptr += sprintf(ptr, "\"geometries\":["); for (i=0; i<ngeoms; i++) { if (i) ptr += sprintf(ptr, ","); subgeom = (GEOSGeom ) GEOSGetGeometryN(col, i); ptr += asgeojson_geom_buf(subgeom, ptr, NULL, precision); } ptr += sprintf(ptr, "]}"); return (ptr - output); }
static size_t asgeojson_collection_buf(const LWCOLLECTION *col, char *srs, char *output, GBOX *bbox, int precision) { int i; char *ptr=output; LWGEOM *subgeom; ptr += sprintf(ptr, "{\"type\":\"GeometryCollection\","); if (srs) ptr += asgeojson_srs_buf(ptr, srs); if (col->ngeoms && bbox) ptr += asgeojson_bbox_buf(ptr, bbox, FLAGS_GET_Z(col->flags), precision); ptr += sprintf(ptr, "\"geometries\":["); for (i=0; i<col->ngeoms; i++) { if (i) ptr += sprintf(ptr, ","); subgeom = col->geoms[i]; ptr += asgeojson_geom_buf(subgeom, ptr, NULL, precision); } ptr += sprintf(ptr, "]}"); return (ptr - output); }