Check the consistency of the metadata we want to enforce in the typmod: srid, type and dimensionality.
If things are inconsistent, shut down the query.
123 POSTGIS_DEBUG(2,
"Entered function");
126 if (typmod < 0)
return gser;
128 POSTGIS_DEBUGF(3,
"Got geom(type = %d, srid = %d, hasz = %d, hasm = %d)", geom_type, geom_srid, geom_z, geom_m);
129 POSTGIS_DEBUGF(3,
"Got typmod(type = %d, srid = %d, hasz = %d, hasm = %d)", typmod_type, typmod_srid, typmod_z, typmod_m);
153 if ( typmod_srid > 0 && typmod_srid != geom_srid )
156 errcode(ERRCODE_INVALID_PARAMETER_VALUE),
157 errmsg(
"Geometry SRID (%d) does not match column SRID (%d)", geom_srid, typmod_srid) ));
161 if ( typmod_type > 0 &&
168 (typmod_type != geom_type)) )
171 errcode(ERRCODE_INVALID_PARAMETER_VALUE),
172 errmsg(
"Geometry type (%s) does not match column type (%s)",
lwtype_name(geom_type),
lwtype_name(typmod_type)) ));
176 if ( typmod_z && ! geom_z )
179 errcode(ERRCODE_INVALID_PARAMETER_VALUE),
180 errmsg(
"Column has Z dimension but geometry does not" )));
184 if ( geom_z && ! typmod_z )
187 errcode(ERRCODE_INVALID_PARAMETER_VALUE),
188 errmsg(
"Geometry has Z dimension but column does not" )));
192 if ( typmod_m && ! geom_m )
195 errcode(ERRCODE_INVALID_PARAMETER_VALUE),
196 errmsg(
"Column has M dimension but geometry does not" )));
200 if ( geom_m && ! typmod_m )
203 errcode(ERRCODE_INVALID_PARAMETER_VALUE),
204 errmsg(
"Geometry has M dimension but column does not" )));
int32_t gserialized_get_srid(const GSERIALIZED *s)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
int gserialized_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
int gserialized_is_geodetic(const GSERIALIZED *gser)
Check if a GSERIALIZED is a geography.
int gserialized_has_m(const GSERIALIZED *gser)
Check if a GSERIALIZED has an M ordinate.
uint32_t gserialized_get_type(const GSERIALIZED *s)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
#define TYPMOD_GET_SRID(typmod)
Macros for manipulating the 'typemod' int.
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
#define TYPMOD_GET_M(typmod)
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
#define TYPMOD_GET_TYPE(typmod)
LWPOINT * lwpoint_construct_empty(int srid, char hasz, char hasm)
#define TYPMOD_GET_Z(typmod)
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)