433{
434 char *geojson;
435 text *result;
436 int has_bbox = 0;
437 char * srs = NULL;
440 int option = PG_GETARG_INT32(2);
442
447
448
449
450
451
452
453
454
455 if (option & 2 || option & 4)
456 {
457
458 if (option & 2)
460 if (option & 4)
462
463 if (!srs)
464 {
465 elog(ERROR, "SRID SRID_DEFAULT unknown in spatial_ref_sys table");
466 PG_RETURN_NULL();
467 }
468 }
469
470 if (option & 1) has_bbox = 1;
471
474 PG_FREE_IF_COPY(g, 0);
475 if (srs) pfree(srs);
476
477 result = cstring_to_text(geojson);
479
480 PG_RETURN_TEXT_P(result);
481}
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
char * lwgeom_to_geojson(const LWGEOM *geo, char *srs, int precision, int has_bbox)
Takes a GEOMETRY and returns a GeoJson representation.
char * getSRSbySRID(FunctionCallInfo fcinfo, int32_t srid, bool short_crs)