85{
86 char *input = PG_GETARG_CSTRING(0);
87 int32 geom_typmod = -1;
92 int32_t srid = 0;
93
94 if ( (PG_NARGS()>2) && (!PG_ARGISNULL(2)) ) {
95 geom_typmod = PG_GETARG_INT32(2);
96 }
97
99
100
101 if (
str[0] ==
'\0' ) {
102 ereport(ERROR,(errmsg("parse error - invalid geometry")));
103 PG_RETURN_NULL();
104 }
105
106
107 if( strncasecmp(
str,
"SRID=",5) == 0 )
108 {
109
111 while ( tmp && *tmp != ';' )
112 tmp++;
113
114
115 if ( tmp && *(tmp+1) == '0' )
116 {
117
118 *tmp = '\0';
119
121
122 tmp = input + 5;
123
124 srid = atoi(tmp);
125 }
126 }
127
128
130 {
131 size_t hexsize = strlen(
str);
133
135
136 if ( !lwgeom ) PG_RETURN_NULL();
137
139
144 }
145
146 else
147 {
149 {
150 PG_PARSER_ERROR(lwg_parser_result);
151 PG_RETURN_NULL();
152 }
153 lwgeom = lwg_parser_result.
geom;
158 }
159
160 if ( geom_typmod >= 0 )
161 {
163 POSTGIS_DEBUG(3, "typmod and geometry were consistent");
164 }
165 else
166 {
167 POSTGIS_DEBUG(3, "typmod was -1");
168 }
169
170
171
172
173 PG_RETURN_POINTER(ret);
174
175}
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.
int lwgeom_needs_bbox(const LWGEOM *geom)
Check whether or not a lwgeom is big enough to warrant a bounding box.
uint8_t * bytes_from_hexbytes(const char *hexbuf, size_t hexsize)
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.