30 #include "../postgis_config.h"
31 #include "lwgeom_pg.h"
36 # ifdef HAVE_LIBJSON_C
37 # include <json-c/json.h>
39 # include <json/json.h>
46 size_t len = strlen(cstring);
47 text *result = (text *) palloc(len + VARHDRSZ);
48 SET_VARSIZE(result, len + VARHDRSZ);
49 memcpy(VARDATA(result), cstring, len);
57 size_t size = VARSIZE(textptr) - VARHDRSZ;
59 memcpy(str, VARDATA(textptr), size);
74 # ifdef JSON_C_VERSION
75 const char *ver = json_c_version();
77 const char *ver =
"UNKNOWN";
80 PG_RETURN_POINTER(result);
88 elog(ERROR,
"You need JSON-C for ST_GeomFromGeoJSON");
102 geojson_input = PG_GETARG_TEXT_P(0);
109 elog(ERROR,
"lwgeom_from_geojson returned NULL");
122 PG_RETURN_POINTER(geom);
LWGEOM * lwgeom_from_geojson(const char *geojson, char **srs)
Create an LWGEOM object from a GeoJSON representation.
void lwgeom_free(LWGEOM *geom)
void * lwalloc(size_t size)
void lwgeom_set_srid(LWGEOM *geom, int srid)
Set the SRID on an LWGEOM For collections, only the parent gets an SRID, all the children get SRID_UN...
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)