PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ geography_from_text()

Datum geography_from_text ( PG_FUNCTION_ARGS  )

Definition at line 537 of file geography_inout.c.

References geography_from_binary(), struct_lwgeom_parser_result::geom, gserialized_geography_from_lwgeom(), LW_FAILURE, LW_PARSER_CHECK_ALL, lwgeom_free(), lwgeom_parse_wkt(), PG_FUNCTION_INFO_V1(), LWGEOM::srid, and text2cstring().

Referenced by geography_as_geojson().

538 {
539  LWGEOM_PARSER_RESULT lwg_parser_result;
540  GSERIALIZED *g_ser = NULL;
541  text *wkt_text = PG_GETARG_TEXT_P(0);
542 
543  /* Extract the cstring from the varlena */
544  char *wkt = text2cstring(wkt_text);
545 
546  /* Pass the cstring to the input parser, and magic occurs! */
547  if ( lwgeom_parse_wkt(&lwg_parser_result, wkt, LW_PARSER_CHECK_ALL) == LW_FAILURE )
548  PG_PARSER_ERROR(lwg_parser_result);
549 
550  /* Error on any SRID != default */
551  srid_is_latlong(fcinfo, lwg_parser_result.geom->srid);
552 
553  /* Clean up string */
554  pfree(wkt);
555  g_ser = gserialized_geography_from_lwgeom(lwg_parser_result.geom, -1);
556 
557  /* Clean up temporary object */
558  lwgeom_free(lwg_parser_result.geom);
559 
560  PG_RETURN_POINTER(g_ser);
561 }
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1099
int32_t srid
Definition: liblwgeom.h:399
#define LW_FAILURE
Definition: liblwgeom.h:79
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:2020
char * text2cstring(const text *textptr)
GSERIALIZED * gserialized_geography_from_lwgeom(LWGEOM *lwgeom, int32 geog_typmod)
#define LW_PARSER_CHECK_ALL
Definition: liblwgeom.h:2014
Here is the call graph for this function:
Here is the caller graph for this function: