PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ geography_from_text()

Datum geography_from_text ( PG_FUNCTION_ARGS  )

Definition at line 438 of file geography_inout.c.

439 {
440  LWGEOM_PARSER_RESULT lwg_parser_result;
441  GSERIALIZED *g_ser = NULL;
442  text *wkt_text = PG_GETARG_TEXT_P(0);
443 
444  /* Extract the cstring from the varlena */
445  char *wkt = text_to_cstring(wkt_text);
446 
447  /* Pass the cstring to the input parser, and magic occurs! */
448  if ( lwgeom_parse_wkt(&lwg_parser_result, wkt, LW_PARSER_CHECK_ALL) == LW_FAILURE )
449  PG_PARSER_ERROR(lwg_parser_result);
450 
451  /* Error on any SRID != default */
452  srid_check_latlong(lwg_parser_result.geom->srid);
453 
454  /* Clean up string */
455  pfree(wkt);
456  g_ser = gserialized_geography_from_lwgeom(lwg_parser_result.geom, -1);
457 
458  /* Clean up temporary object */
459  lwgeom_free(lwg_parser_result.geom);
460 
461  PG_RETURN_POINTER(g_ser);
462 }
GSERIALIZED * gserialized_geography_from_lwgeom(LWGEOM *lwgeom, int32 geog_typmod)
#define LW_PARSER_CHECK_ALL
Definition: liblwgeom.h:2115
#define LW_FAILURE
Definition: liblwgeom.h:96
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1155
int lwgeom_parse_wkt(LWGEOM_PARSER_RESULT *parser_result, char *wktstr, int parse_flags)
Parse a WKT geometry string into an LWGEOM structure.
int32_t srid
Definition: liblwgeom.h:460
Parser result structure: returns the result of attempting to convert (E)WKT/(E)WKB to LWGEOM.
Definition: liblwgeom.h:2122

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

Here is the call graph for this function: