[postgis-users] distance() for 3d points

strk at refractions.net strk at refractions.net
Sat Oct 22 02:56:40 PDT 2005


distance() is 2d only.
--strk;

On Fri, Oct 21, 2005 at 02:57:47PM -0400, Rick Schumeyer wrote:
> Does the distance() function work for 3d points, or is there a distance3d()
> function?
> 
>  
> 
> My quick tests show that distance() seems to use only the first two
> dimensions and ignore the third:
> 
>  
> 
> select AddGeometryColumn('t2','geom',-1,'POINT', 3);
> 
>  
> 
> insert into t2 (name, geom) values ('p1',GeomFromEWKT('POINT(0 0 0)'));
> 
> insert into t2 (name, geom) values ('p2',GeomFromEWKT('POINT(0 0 1)'));
> 
> insert into t2 (name, geom) values ('p3',GeomFromEWKT('POINT(0 1 1)'));
> 
> insert into t2 (name, geom) values ('p4',GeomFromEWKT('POINT(1 1 1)'));
> 
>  
> 
> select distance( geom ,GeomFromEWKT('POINT(0 0 0)')) from t2;
> 
>  
> 
>     distance     
> 
> -----------------
> 
>                0
> 
>                0
> 
>                1
> 
>  1.4142135623731
> 
>  
> 

> _______________________________________________
> 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