static char *
asgeojson_multipolygon(GEOSGeom mpoly, char *srs, bbox3D *bbox, int precision)
{
    char *output;
    int size;

    size = asgeojson_multipolygon_size(mpoly, srs, bbox, precision);
    output = GDKmalloc(size);
    asgeojson_multipolygon_buf(mpoly, srs, output, bbox, precision);

    return output;
}
Пример #2
0
static char *
asgeojson_multipolygon(const LWMPOLY *mpoly, char *srs, GBOX *bbox, int precision)
{
	char *output;
	int size;

	size = asgeojson_multipolygon_size(mpoly, srs, bbox, precision);
	output = lwalloc(size);
	asgeojson_multipolygon_buf(mpoly, srs, output, bbox, precision);

	return output;
}
static size_t
asgeojson_geom_buf(GEOSGeom geom, char *output, bbox3D *bbox, int precision)
{
    int type = GEOSGeomTypeId(geom)+1;
    char *ptr=output;

    switch (type)
    {
        case wkbPoint_mdb:
            ptr += asgeojson_point_buf(geom, NULL, ptr, bbox, precision);
            break;

        case wkbLineString_mdb:
            ptr += asgeojson_line_buf(geom, NULL, ptr, bbox, precision);
            break;

        case wkbPolygon_mdb:
            ptr += asgeojson_poly_buf(geom, NULL, ptr, bbox, precision);
            break;

        case wkbMultiPoint_mdb:
            ptr += asgeojson_multipoint_buf(geom, NULL, ptr, bbox, precision);
            break;

        case wkbMultiLineString_mdb:
            ptr += asgeojson_multiline_buf(geom, NULL, ptr, bbox, precision);
            break;

        case wkbMultiPolygon_mdb:
            ptr += asgeojson_multipolygon_buf(geom, NULL, ptr, bbox, precision);
            break;

        default:
            if (bbox)
                GDKfree(bbox);
            assert(0);
    }

    return (ptr-output);
}
Пример #4
0
static size_t
asgeojson_geom_buf(const LWGEOM *geom, char *output, GBOX *bbox, int precision)
{
	int type = geom->type;
	char *ptr=output;

	switch (type)
	{
	case POINTTYPE:
		ptr += asgeojson_point_buf((LWPOINT*)geom, NULL, ptr, bbox, precision);
		break;

	case LINETYPE:
		ptr += asgeojson_line_buf((LWLINE*)geom, NULL, ptr, bbox, precision);
		break;

	case POLYGONTYPE:
		ptr += asgeojson_poly_buf((LWPOLY*)geom, NULL, ptr, bbox, precision);
		break;

	case MULTIPOINTTYPE:
		ptr += asgeojson_multipoint_buf((LWMPOINT*)geom, NULL, ptr, bbox, precision);
		break;

	case MULTILINETYPE:
		ptr += asgeojson_multiline_buf((LWMLINE*)geom, NULL, ptr, bbox, precision);
		break;

	case MULTIPOLYGONTYPE:
		ptr += asgeojson_multipolygon_buf((LWMPOLY*)geom, NULL, ptr, bbox, precision);
		break;

	default:
		if (bbox) lwfree(bbox);
		lwerror("GeoJson: geometry not supported.");
	}

	return (ptr-output);
}