PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ lwgeom_parse_wkt()

int lwgeom_parse_wkt ( LWGEOM_PARSER_RESULT parser_result,
char *  wktstr,
int  parser_check_flags 
)
extern

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 122 of file lwin_wkt_parse.c.

123{
124 int parse_rv = 0;
125
126 /* Clean up our global parser result. */
128 /* Work-around possible bug in GNU Bison 3.0.2 resulting in wkt_yylloc
129 * members not being initialized on yyparse() as documented here:
130 * https://www.gnu.org/software/bison/manual/html_node/Location-Type.html
131 * See discussion here:
132 * http://lists.osgeo.org/pipermail/postgis-devel/2014-September/024506.html
133 */
136
137 /* Set the input text string, and parse checks. */
139 global_parser_result.parser_check_flags = parser_check_flags;
140
141 wkt_lexer_init(wktstr); /* Lexer ready */
142 parse_rv = wkt_yyparse(); /* Run the parse */
143 LWDEBUGF(4,"wkt_yyparse returned %d", parse_rv);
144 wkt_lexer_close(); /* Clean up lexer */
145
146 /* A non-zero parser return is an error. */
147 if ( parse_rv || global_parser_result.errcode )
148 {
150 {
154 }
155 else if (global_parser_result.geom)
156 {
159 }
160
161 LWDEBUGF(5, "error returned by wkt_yyparse() @ %d: [%d] '%s'",
165
166 /* Copy the global values into the return pointer */
167 *parser_result = global_parser_result;
169 return LW_FAILURE;
170 }
171
172 /* Copy the global value into the return pointer */
173 *parser_result = global_parser_result;
175 return LW_SUCCESS;
176}
#define LW_FAILURE
Definition liblwgeom.h:110
void lwgeom_free(LWGEOM *geom)
Definition lwgeom.c:1138
#define LW_SUCCESS
Definition liblwgeom.h:111
void lwgeom_parser_result_init(LWGEOM_PARSER_RESULT *parser_result)
Definition lwin_wkt.c:880
#define PARSER_ERROR_OTHER
Definition liblwgeom.h:2092
#define LWDEBUGF(level, msg,...)
Definition lwgeom_log.h:88
const char * parser_error_messages[]
Definition lwin_wkt.c:37
void wkt_lexer_close(void)
int wkt_yylex_destroy(void)
void wkt_lexer_init(char *str)
YYLTYPE wkt_yylloc
int wkt_yyparse(void)
LWGEOM_PARSER_RESULT global_parser_result

References struct_lwgeom_parser_result::errcode, struct_lwgeom_parser_result::errlocation, YYLTYPE::first_column, YYLTYPE::first_line, struct_lwgeom_parser_result::geom, global_parser_result, YYLTYPE::last_column, YYLTYPE::last_line, LW_FAILURE, LW_SUCCESS, LWDEBUGF, lwgeom_free(), 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_yylex_destroy(), wkt_yylloc, and wkt_yyparse().

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

Here is the call graph for this function:
Here is the caller graph for this function: