471 version = PG_GETARG_INT32(0);
474 elog(ERROR,
"Only GeoJSON 1 is supported");
479 if (PG_ARGISNULL(1) ) PG_RETURN_NULL();
480 g = PG_GETARG_GSERIALIZED_P(1);
486 if (PG_NARGS() >2 && !PG_ARGISNULL(2))
488 precision = PG_GETARG_INT32(2);
490 if ( precision > DBL_DIG )
492 else if ( precision < 0 ) precision = 0;
501 if (PG_NARGS() >3 && !PG_ARGISNULL(3))
502 option = PG_GETARG_INT32(3);
504 if (option & 2 || option & 4)
512 elog(ERROR,
"SRID SRID_DEFAULT unknown in spatial_ref_sys table");
517 if (option & 1) has_bbox = 1;
521 PG_FREE_IF_COPY(g, 1);
524 result = cstring2text(geojson);
527 PG_RETURN_TEXT_P(result);
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(int srid, bool short_crs)