30 #include "../postgis_config.h"
31 #include "lwgeom_pg.h"
35 #if defined(HAVE_LIBJSON)
43 size_t len = strlen(cstring);
44 text *result = (text *) palloc(len + VARHDRSZ);
45 SET_VARSIZE(result, len + VARHDRSZ);
46 memcpy(VARDATA(result), cstring, len);
54 size_t size = VARSIZE_ANY_EXHDR(textptr);
56 memcpy(
str, VARDATA(textptr), size);
71 # ifdef JSON_C_VERSION
72 const char *ver = json_c_version();
74 const char *ver =
"UNKNOWN";
77 PG_RETURN_POINTER(result);
85 elog(ERROR,
"You need JSON-C for ST_GeomFromGeoJSON");
100 geojson_input = PG_GETARG_TEXT_P(0);
107 elog(ERROR,
"lwgeom_from_geojson returned NULL");
121 PG_RETURN_POINTER(geom);
LWGEOM * lwgeom_from_geojson(const char *geojson, char **srs)
Create an LWGEOM object from a GeoJSON representation.
void lwgeom_set_srid(LWGEOM *geom, int32_t srid)
Set the SRID on an LWGEOM For collections, only the parent gets an SRID, all the children get SRID_UN...
void lwgeom_free(LWGEOM *geom)
void * lwalloc(size_t size)
This library is the generic geometry handling section of PostGIS.
int getSRIDbySRS(FunctionCallInfo fcinfo, const char *srs)
PG_FUNCTION_INFO_V1(postgis_libjson_version)
Datum postgis_libjson_version(PG_FUNCTION_ARGS)
Datum geom_from_geojson(PG_FUNCTION_ARGS)
static text * cstring2text(const char *cstring)
static char * text2cstring(const text *textptr)
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)