86 char *input = PG_GETARG_CSTRING(0);
87 int32 geom_typmod = -1;
94 if ( (PG_NARGS()>2) && (!PG_ARGISNULL(2)) ) {
95 geom_typmod = PG_GETARG_INT32(2);
101 if (
str[0] ==
'\0' ) {
102 ereport(ERROR,(errmsg(
"parse error - invalid geometry")));
107 if( strncasecmp(
str,
"SRID=",5) == 0 )
111 while ( tmp && *tmp !=
';' )
115 if ( tmp && *(tmp+1) ==
'0' )
131 size_t hexsize = strlen(
str);
148 PG_PARSER_ERROR(lwg_parser_result);
151 lwgeom = lwg_parser_result.
geom;
158 if ( geom_typmod >= 0 )
161 POSTGIS_DEBUG(3,
"typmod and geometry were consistent");
165 POSTGIS_DEBUG(3,
"typmod was -1");
171 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_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...
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_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.