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

George Silva georger.silva at gmail.com
Sun Jul 27 15:00:24 PDT 2008


Yes!

2 for points, lines and polygons that dont have a Z value.

George

Edward Bridges escreveu:
> Hmmm.
>
> Ok so when I added the column, the paramters I passed where:
> SELECT AddGeometryColumn('', 'point', 'coordinate', 600613, 'POINT', 0);
>
> where 0 was the result of st_dimension, so should it be:
> SELECT AddGeometryColumn('', 'point', 'coordinate', 600613, 'POINT', 2);
>
> for a point?
>
> Should it also be 2 for polygons -- given that these are the 
> dimensions of the same coordinate space?
>
> Thanks!
> Ed
>
> pcreso at pcreso.com wrote:
>> 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
>>>     
> _______________________________________________
> 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