PostGIS  2.1.10dev-r@@SVN_REVISION@@
Datum geography_from_text ( PG_FUNCTION_ARGS  )

Definition at line 523 of file geography_inout.c.

References struct_lwgeom_parser_result::geom, gserialized_geography_from_lwgeom(), LW_FAILURE, LW_PARSER_CHECK_ALL, lwgeom_free(), lwgeom_parse_wkt(), and text2cstring().

524 {
525  LWGEOM_PARSER_RESULT lwg_parser_result;
526  GSERIALIZED *g_ser = NULL;
527  text *wkt_text = PG_GETARG_TEXT_P(0);
528 
529  /* Extract the cstring from the varlena */
530  char *wkt = text2cstring(wkt_text);
531 
532  /* Pass the cstring to the input parser, and magic occurs! */
533  if ( lwgeom_parse_wkt(&lwg_parser_result, wkt, LW_PARSER_CHECK_ALL) == LW_FAILURE )
534  PG_PARSER_ERROR(lwg_parser_result);
535 
536  /* Clean up string */
537  pfree(wkt);
538  g_ser = gserialized_geography_from_lwgeom(lwg_parser_result.geom, -1);
539 
540  /* Clean up temporary object */
541  lwgeom_free(lwg_parser_result.geom);
542 
543  PG_RETURN_POINTER(g_ser);
544 }
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
#define LW_FAILURE
Definition: liblwgeom.h:54
int lwgeom_parse_wkt(LWGEOM_PARSER_RESULT *parser_result, char *wktstr, int parse_flags)
Parse a WKT geometry string into an LWGEOM structure.
Parser result structure: returns the result of attempting to convert (E)WKT/(E)WKB to LWGEOM...
Definition: liblwgeom.h:1713
char * text2cstring(const text *textptr)
GSERIALIZED * gserialized_geography_from_lwgeom(LWGEOM *lwgeom, int32 geog_typmod)
#define LW_PARSER_CHECK_ALL
Definition: liblwgeom.h:1707

Here is the call graph for this function: