static size_t
asgeojson_collection_size(GEOSGeom col, char *srs, bbox3D *bbox, int precision)
{
    int i,ngeoms = GEOSGetNumGeometries(col);
    int size;
    GEOSGeom subgeom;

    size = sizeof("{'type':'GeometryCollection',");
    if (srs) size += asgeojson_srs_size(srs);
    if (bbox) size += asgeojson_bbox_size(GEOS_getWKBOutputDims(col) == 3, precision);
    size += sizeof("'geometries':");

    for (i=0; i<ngeoms; i++)
    {
        subgeom = (GEOSGeom ) GEOSGetGeometryN(col, i);
        size += asgeojson_geom_size(subgeom, NULL, precision);
    }
    size += sizeof(",") * i;
    size += sizeof("]}");

    return size;
}
Example #2
0
static size_t
asgeojson_collection_size(const LWCOLLECTION *col, char *srs, GBOX *bbox, int precision)
{
	int i;
	int size;
	LWGEOM *subgeom;

	size = sizeof("{'type':'GeometryCollection',");
	if (srs) size += asgeojson_srs_size(srs);
	if (bbox) size += asgeojson_bbox_size(FLAGS_GET_Z(col->flags), precision);
	size += sizeof("'geometries':");

	for (i=0; i<col->ngeoms; i++)
	{
		subgeom = col->geoms[i];
		size += asgeojson_geom_size(subgeom, NULL, precision);
	}
	size += sizeof(",") * i;
	size += sizeof("]}");

	return size;
}