PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ LWGEOM_from_text()

Datum LWGEOM_from_text ( PG_FUNCTION_ARGS  )

Definition at line 750 of file lwgeom_ogc.c.

751 {
752  text *wkttext = PG_GETARG_TEXT_P(0);
753  char *wkt = text_to_cstring(wkttext);
754  LWGEOM_PARSER_RESULT lwg_parser_result;
755  GSERIALIZED *geom_result = NULL;
756  LWGEOM *lwgeom;
757 
758  POSTGIS_DEBUG(2, "LWGEOM_from_text");
759  POSTGIS_DEBUGF(3, "wkt: [%s]", wkt);
760 
761  if (lwgeom_parse_wkt(&lwg_parser_result, wkt, LW_PARSER_CHECK_ALL) == LW_FAILURE )
762  PG_PARSER_ERROR(lwg_parser_result);
763 
764  lwgeom = lwg_parser_result.geom;
765 
766  if ( lwgeom->srid != SRID_UNKNOWN )
767  {
768  elog(WARNING, "OGC WKT expected, EWKT provided - use GeomFromEWKT() for this");
769  }
770 
771  /* read user-requested SRID if any */
772  if ( PG_NARGS() > 1 )
773  lwgeom_set_srid(lwgeom, PG_GETARG_INT32(1));
774 
775  geom_result = geometry_serialize(lwgeom);
776  lwgeom_parser_result_free(&lwg_parser_result);
777 
778  PG_RETURN_POINTER(geom_result);
779 }
#define LW_PARSER_CHECK_ALL
Definition: liblwgeom.h:2115
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...
Definition: lwgeom.c:1547
#define LW_FAILURE
Definition: liblwgeom.h:96
int lwgeom_parse_wkt(LWGEOM_PARSER_RESULT *parser_result, char *wktstr, int parse_flags)
Parse a WKT geometry string into an LWGEOM structure.
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:215
void lwgeom_parser_result_free(LWGEOM_PARSER_RESULT *parser_result)
Definition: lwin_wkt.c:886
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, LW_FAILURE, LW_PARSER_CHECK_ALL, lwgeom_parse_wkt(), lwgeom_parser_result_free(), lwgeom_set_srid(), LWGEOM::srid, and SRID_UNKNOWN.

Here is the call graph for this function: