[postgis-users] ndim vs. st_dimension and enforce_dims_coordinate constraint

pcreso at pcreso.com pcreso at pcreso.com
Sun Jul 27 13:16:45 PDT 2008


The number of dimensions in this case is teh number of coordinates, if your point has 2 (X & Y) then it is 2, not 0. If it is an XYZ point, then ndim = 3.

ndim does not reere to points @ 0, lines @ 1 & polygons @ 2, but the dimensions of the coordinate space.

Cheers,

  Brent Wood


--- On Mon, 7/28/08, Edward Bridges <postgis at eqbridges.com> wrote:

> From: Edward Bridges <postgis at eqbridges.com>
> Subject: [postgis-users] ndim vs. st_dimension and enforce_dims_coordinate constraint
> To: "PostGIS Users Discussion" <postgis-users at postgis.refractions.net>
> Date: Monday, July 28, 2008, 7:30 AM
> Hello,
> 
> I have a table with a geometry column which the
> AddGeometryColumn stored 
> procedure has created a check constraint like so:
> Check constraints:
>     "enforce_dims_coordinate" CHECK
> (ndims(coordinate) = 0)
> 
> So, this uses the internal function "ndims" to
> check the dimensionality 
> of the input coordinate.
> 
> However, I'm getting a discrepancy when inserting a
> point into this 
> column since ndims and st_dimensions are returning
> conflicting 
> (apparently) values:
> 
> rover=# select * from st_dimension(
> ST_GeomFromText('POINT(1 1)'));
>  st_dimension
> --------------
>             0
> (1 row)
> 
> rover=# select * from ndims( ST_GeomFromText('POINT(1
> 1)'));
>  ndims
> -------
>      2
> (1 row)
> 
> It seems that the ndims function returns only 2, 3, or 4;
> can someone 
> please explain why the differing values and how to insert
> data into a 
> point-type geometry column (seems to work fine with
> polygon) without 
> crossing the check constraint?
> 
> Thanks,
> Ed
> 
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users



More information about the postgis-users mailing list