PostGIS  2.1.10dev-r@@SVN_REVISION@@
int lwgeom_parse_wkt ( LWGEOM_PARSER_RESULT parser_result,
char *  wktstr,
int  parser_check_flags 
)

Parse a WKT geometry string into an LWGEOM structure.

Note that this process uses globals and is not re-entrant, so don't call it within itself (eg, from within other functions in lwin_wkt.c) or from a threaded program. Note that parser_result.wkinput picks up a reference to wktstr.

Definition at line 125 of file lwin_wkt_parse.c.

References struct_lwgeom_parser_result::errcode, struct_lwgeom_parser_result::errlocation, global_parser_result, YYLTYPE::last_column, LW_FAILURE, LW_SUCCESS, LWDEBUGF, lwgeom_parser_result_init(), struct_lwgeom_parser_result::message, struct_lwgeom_parser_result::parser_check_flags, parser_error_messages, PARSER_ERROR_OTHER, struct_lwgeom_parser_result::wkinput, wkt_lexer_close(), wkt_lexer_init(), wkt_yylloc, and wkt_yyparse().

Referenced by cu_wkb_in(), cu_wkb_malformed_in(), cu_wkt_in(), geography_from_text(), geography_in(), lwgeom_from_text(), LWGEOM_from_text(), lwgeom_from_wkt(), LWGEOM_in(), and test_wkt_in_errlocation().

126 {
127  int parse_rv = 0;
128 
129  /* Clean up our global parser result. */
131 
132  /* Set the input text string, and parse checks. */
133  global_parser_result.wkinput = wktstr;
134  global_parser_result.parser_check_flags = parser_check_flags;
135 
136  wkt_lexer_init(wktstr); /* Lexer ready */
137  parse_rv = wkt_yyparse(); /* Run the parse */
138  LWDEBUGF(4,"wkt_yyparse returned %d", parse_rv);
139  wkt_lexer_close(); /* Clean up lexer */
140 
141  /* A non-zero parser return is an error. */
142  if ( parse_rv != 0 )
143  {
145  {
149  }
150 
151  LWDEBUGF(5, "error returned by wkt_yyparse() @ %d: [%d] '%s'",
155 
156  /* Copy the global values into the return pointer */
157  *parser_result = global_parser_result;
158  return LW_FAILURE;
159  }
160 
161  /* Copy the global value into the return pointer */
162  *parser_result = global_parser_result;
163  return LW_SUCCESS;
164 }
#define LW_SUCCESS
Definition: liblwgeom.h:55
#define LW_FAILURE
Definition: liblwgeom.h:54
void wkt_lexer_init(char *str)
Definition: lwin_wkt_lex.c:636
int last_column
YYLTYPE wkt_yylloc
void wkt_lexer_close(void)
Definition: lwin_wkt_lex.c:644
const char * parser_error_messages[]
Definition: lwin_wkt.c:23
void lwgeom_parser_result_init(LWGEOM_PARSER_RESULT *parser_result)
Definition: lwin_wkt.c:819
LWGEOM_PARSER_RESULT global_parser_result
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
int wkt_yyparse(void)
#define PARSER_ERROR_OTHER
Definition: liblwgeom.h:1738

Here is the call graph for this function:

Here is the caller graph for this function: