87 char *input = PG_GETARG_CSTRING(0);
88 int32 geom_typmod = -1;
95 if ( (PG_NARGS()>2) && (!PG_ARGISNULL(2)) ) {
96 geom_typmod = PG_GETARG_INT32(2);
102 if ( str[0] ==
'\0' ) {
103 ereport(ERROR,(errmsg(
"parse error - invalid geometry")));
108 if( strncasecmp(str,
"SRID=",5) == 0 )
112 while ( tmp && *tmp !=
';' )
116 if ( tmp && *(tmp+1) ==
'0' )
132 size_t hexsize = strlen(str);
149 PG_PARSER_ERROR(lwg_parser_result);
152 lwgeom = lwg_parser_result.
geom;
159 if ( geom_typmod >= 0 )
162 POSTGIS_DEBUG(3,
"typmod and geometry were consistent");
166 POSTGIS_DEBUG(3,
"typmod was -1");
172 PG_RETURN_POINTER(ret);
GSERIALIZED * postgis_valid_typmod(GSERIALIZED *gser, int32_t typmod)
Check the consistency of the metadata we want to enforce in the typmod: srid, type and dimensionality...
#define LW_PARSER_CHECK_ALL
void lwgeom_free(LWGEOM *geom)
#define LW_PARSER_CHECK_NONE
void lwgeom_parser_result_init(LWGEOM_PARSER_RESULT *parser_result)
int lwgeom_parse_wkt(LWGEOM_PARSER_RESULT *parser_result, char *wktstr, int parse_flags)
Parse a WKT geometry string into an LWGEOM structure.
uint8_t * bytes_from_hexbytes(const char *hexbuf, size_t hexsize)
int lwgeom_needs_bbox(const LWGEOM *geom)
Check whether or not a lwgeom is big enough to warrant a bounding box.
LWGEOM * lwgeom_from_wkb(const uint8_t *wkb, const size_t wkb_size, const char check)
WKB inputs must have a declared size, to prevent malformed WKB from reading off the end of the memory...
void lwgeom_set_srid(LWGEOM *geom, int srid)
Set the SRID on an LWGEOM For collections, only the parent gets an SRID, all the children get SRID_UN...
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
void lwgeom_parser_result_free(LWGEOM_PARSER_RESULT *parser_result)
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
Parser result structure: returns the result of attempting to convert (E)WKT/(E)WKB to LWGEOM.