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

◆ gserialized_typmod_in()

static uint32 gserialized_typmod_in ( ArrayType *  arr,
int  is_geography 
)
static

Definition at line 210 of file gserialized_typmod.c.

211{
212 int32 typmod = 0;
213 Datum *elem_values;
214 int n = 0;
215 int i = 0;
216
217 if (ARR_ELEMTYPE(arr) != CSTRINGOID)
218 ereport(ERROR,
219 (errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
220 errmsg("typmod array must be type cstring[]")));
221
222 if (ARR_NDIM(arr) != 1)
223 ereport(ERROR,
224 (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
225 errmsg("typmod array must be one-dimensional")));
226
227 if (ARR_HASNULL(arr))
228 ereport(ERROR,
229 (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
230 errmsg("typmod array must not contain nulls")));
231
232 deconstruct_array(arr,
233 CSTRINGOID, -2, false, 'c', /* hardwire cstring representation details */
234 &elem_values, NULL, &n);
235
236 /* Set the SRID to the default value first */
237 if (is_geography)
239 else
241
242 for (i = 0; i < n; i++)
243 {
244 if ( i == 0 ) /* TYPE */
245 {
246 char *s = DatumGetCString(elem_values[i]);
247 uint8_t type = 0;
248 int z = 0;
249 int m = 0;
250
251 if ( geometry_type_from_string(s, &type, &z, &m) == LW_FAILURE )
252 {
253 ereport(ERROR,
254 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
255 errmsg("Invalid geometry type modifier: %s", s)));
256 }
257 else
258 {
259 TYPMOD_SET_TYPE(typmod, type);
260 if ( z )
261 TYPMOD_SET_Z(typmod);
262 if ( m )
263 TYPMOD_SET_M(typmod);
264 }
265 }
266 if ( i == 1 ) /* SRID */
267 {
268 int32_t srid = pg_atoi(DatumGetCString(elem_values[i]), sizeof(int32), '\0');
269 srid = clamp_srid(srid);
270 POSTGIS_DEBUGF(3, "srid: %d", srid);
271 if ( srid != SRID_UNKNOWN )
272 {
273 TYPMOD_SET_SRID(typmod, srid);
274 }
275 }
276 }
277
278 pfree(elem_values);
279
280 return typmod;
281}
char * s
Definition cu_in_wkt.c:23
#define TYPMOD_SET_SRID(typmod, srid)
Definition liblwgeom.h:207
#define LW_FAILURE
Definition liblwgeom.h:110
int geometry_type_from_string(const char *str, uint8_t *type, int *z, int *m)
Utility function to get type number from string.
Definition lwutil.c:489
#define TYPMOD_SET_TYPE(typmod, type)
Definition liblwgeom.h:209
#define SRID_DEFAULT
Definition liblwgeom.h:239
#define TYPMOD_SET_M(typmod)
Definition liblwgeom.h:213
#define SRID_UNKNOWN
Unknown SRID value.
Definition liblwgeom.h:229
#define TYPMOD_SET_Z(typmod)
Definition liblwgeom.h:211
int32_t clamp_srid(int32_t srid)
Return a valid SRID from an arbitrary integer Raises a notice if what comes out is different from wha...
Definition lwutil.c:333
unsigned int int32
Definition shpopen.c:273

References clamp_srid(), geometry_type_from_string(), LW_FAILURE, s, SRID_DEFAULT, SRID_UNKNOWN, TYPMOD_SET_M, TYPMOD_SET_SRID, TYPMOD_SET_TYPE, and TYPMOD_SET_Z.

Referenced by geography_typmod_in(), and geometry_typmod_in().

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