[postgis-devel] 3d kNN GiST?

Paul Ramsey pramsey at cleverelephant.ca
Fri Jun 13 09:12:32 PDT 2014

No, that won’t return indexed results. To do so will require actually adding a distance index op on the gist_nd indexes (the ones underlying the &&& operator)


Paul Ramsey

On June 13, 2014 at 8:37:51 AM, hubert depesz lubaczewski (depesz at gmail.com) wrote:

For my project I need fast searching for nearest neighbors in 3d space.

We use postgis geometry with POINT(x y z), but apparently <-> doesn't show 3d distance, but rather 2d. Which is kinda bummer (why isn't it even listed in docs?).

Anyway - on IRC I was said to:

CREATE OR REPLACE FUNCTION geometry_distance_centroid(geom1 geometry, geom2 geometry) RETURNS float8 AS 'SELECT ST_3DDistance($1,$2)' LANGUAGE 'sql' IMMUTABLE STRICT;

And then <-> will work with 3d, but will that also work *correctly* with gist indexes?


postgis-devel mailing list  
postgis-devel at lists.osgeo.org  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20140613/3fd46835/attachment.html>

More information about the postgis-devel mailing list