</listitem>
</varlistentry>
+ <varlistentry id="ndims">
+ <term>ndims(geometry)</term>
+
+ <listitem>
+ <para>Returns number of dimensions of the geometry as
+ a small int. Values are: 2,3 or 4.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term>mem_size(geometry)</term>
Datum LWGEOM_forceRHR_poly(PG_FUNCTION_ARGS);
Datum LWGEOM_noop(PG_FUNCTION_ARGS);
Datum LWGEOM_zmflag(PG_FUNCTION_ARGS);
+Datum LWGEOM_ndims(PG_FUNCTION_ARGS);
Datum LWGEOM_makepoint(PG_FUNCTION_ARGS);
Datum LWGEOM_makepoint3dm(PG_FUNCTION_ARGS);
Datum LWGEOM_makeline_garray(PG_FUNCTION_ARGS);
PG_RETURN_INT16(ret);
}
+// Return: 2,3 or 4
+PG_FUNCTION_INFO_V1(LWGEOM_ndims);
+Datum LWGEOM_ndims(PG_FUNCTION_ARGS)
+{
+ PG_LWGEOM *in;
+ int ret;
+
+ in = (PG_LWGEOM *)PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(0));
+ ret = (TYPE_NDIMS(in->type));
+ PG_RETURN_INT16(ret);
+}
+
// lwgeom_same(lwgeom1, lwgeom2)
PG_FUNCTION_INFO_V1(LWGEOM_same);
Datum LWGEOM_same(PG_FUNCTION_ARGS)
AS '@MODULE_FILENAME@', 'LWGEOM_zmflag'
LANGUAGE 'C' WITH (iscachable,isstrict);
+CREATEFUNCTION ndims(geometry)
+ RETURNS smallint
+ AS '@MODULE_FILENAME@', 'LWGEOM_ndims'
+ LANGUAGE 'C' WITH (iscachable,isstrict);
+
------------------------------------------------------------------------
-- CONSTRUCTORS
------------------------------------------------------------------------
column_name || ''" CHECK (SRID('' || quote_ident(column_name) ||
'') = '' || new_srid || '')'' ;
+ EXECUTE ''ALTER TABLE '' ||
+#if USE_VERSION >= 73
+ quote_ident(real_schema) || ''.'' || quote_ident(table_name)
+#else
+ quote_ident(table_name)
+#endif
+ || '' ADD CONSTRAINT "enforce_dims_'' ||
+ column_name || ''" CHECK (ndims('' || quote_ident(column_name) ||
+ '') = '' || new_dim || '')'' ;
+
IF (not(new_type = ''GEOMETRY'')) THEN
EXECUTE ''ALTER TABLE '' ||
#if USE_VERSION >= 73
#endif
table_name || ''.'' || column_name ||
'' SRID:'' || new_srid ||
- '' TYPE:'' || new_type || ''\n '' ||
+ '' TYPE:'' || new_type ||
+ '' DIMS:'' || new_dim || ''\n '' ||
''geometry_column '' || fixgeomres;
END;
' LANGUAGE 'plpgsql' WITH (isstrict);