mirror of
https://git.osgeo.org/gitea/postgis/postgis
synced 2024-10-23 08:32:42 +00:00
document box distance KNN operator
git-svn-id: http://svn.osgeo.org/postgis/trunk@7911 b70326c6-7e19-0410-871a-916f4a2858ee
This commit is contained in:
parent
05a1752c44
commit
04eda6922a
|
@ -1064,12 +1064,13 @@ select 'LINESTRING(0 0, 1 1)'::geometry ~= 'LINESTRING(0 1, 1 0)'::geometry as e
|
|||
</refsection>
|
||||
</refentry>
|
||||
|
||||
<refentry id="geometry_gist_boxdistance_2d">
|
||||
<refentry id="geometry_distance_centroid">
|
||||
<refnamediv>
|
||||
<refname><-></refname>
|
||||
|
||||
<refpurpose>Returns the squared distance between two points. For point / point checks it's exact. For other geometry types
|
||||
only the centroid of the bounding box is considered. Useful for doing distance ordering and nearest neighbor limits.</refpurpose>
|
||||
<refpurpose>Returns the distance between two points. For point / point checks it's exact. For other geometry types
|
||||
the distance between the bounding box centroids is returned. Useful for doing distance ordering and nearest neighbor limits
|
||||
using KNN gist functionality.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
|
@ -1099,7 +1100,8 @@ select 'LINESTRING(0 0, 1 1)'::geometry ~= 'LINESTRING(0 1, 1 0)'::geometry as e
|
|||
other geometries it returns squared distance from centroid of bounding box of geometries. Useful for doing nearest neighbor approximate distance ordering.</para>
|
||||
|
||||
<note><para>This operand will make use of any indexes that may be available on the
|
||||
geometries.</para></note>
|
||||
geometries. It is different from other operators taht use spatial indexes in that the spatial index is only used when the operator
|
||||
is in the ORDER BY clause.</para></note>
|
||||
|
||||
<para>Availability: 2.0.0 only available for PostgreSQL 9.1+</para>
|
||||
|
||||
|
@ -1173,7 +1175,83 @@ Finally the hybrid:
|
|||
</refsection>
|
||||
<refsection>
|
||||
<title>See Also</title>
|
||||
<para><xref linkend="ST_DWithin" />, <xref linkend="ST_Distance" /></para>
|
||||
<para><xref linkend="ST_DWithin" />, <xref linkend="ST_Distance" />, <xref linkend="geometry_distance_box" /></para>
|
||||
</refsection>
|
||||
</refentry>
|
||||
|
||||
<refentry id="geometry_distance_box">
|
||||
<refnamediv>
|
||||
<refname><#></refname>
|
||||
|
||||
<refpurpose>Returns the distance between two points. For point / point checks it's exact. For other geometry types
|
||||
the distance between the bounding box centroids is returned. Useful for doing distance ordering and nearest neighbor limits
|
||||
using KNN gist functionality.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>double precision <function><#></function></funcdef>
|
||||
|
||||
<paramdef>
|
||||
<type>geometry </type>
|
||||
|
||||
<parameter>A</parameter>
|
||||
</paramdef>
|
||||
|
||||
<paramdef>
|
||||
<type>geometry </type>
|
||||
|
||||
<parameter>B</parameter>
|
||||
</paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsection>
|
||||
<title>Description</title>
|
||||
|
||||
<para>The <varname><#></varname> KNN GIST operator returns distance between two bounding boxes read from the spatial index if available. Useful for doing nearest neighbor approximate distance ordering.</para>
|
||||
|
||||
<note><para>This operand will make use of any indexes that may be available on the
|
||||
geometries. It is different from other operators that use spatial indexes in that the spatial index is only used when the operator
|
||||
is in the ORDER BY clause.</para></note>
|
||||
|
||||
<para>Availability: 2.0.0 only available for PostgreSQL 9.1+</para>
|
||||
|
||||
</refsection>
|
||||
|
||||
<refsection>
|
||||
<title>Examples</title>
|
||||
<programlisting>
|
||||
-- this takes 125 ms on 25,000 gist indexed street table
|
||||
<![CDATA[SELECT *
|
||||
FROM (
|
||||
SELECT b.tlid, b.mtfcc, b.geom <#> d.geom As b_dist, ST_Distance(b.geom, d.geom) As act_dist
|
||||
FROM bos_roads As b
|
||||
CROSS JOIN (SELECT geom FROM bos_roads WHERE tlid = 85732029) As d
|
||||
ORDER BY b.geom <#> d.geom, b.tlid
|
||||
LIMIT 100) As foo
|
||||
ORDER BY act_dist, tlid LIMIT 10;]]>
|
||||
|
||||
tlid | mtfcc | b_dist | act_dist
|
||||
-----------+-------+------------------+------------------
|
||||
85732027 | S1400 | 0 | 0
|
||||
85732029 | S1400 | 0 | 0
|
||||
85732031 | S1400 | 0 | 0
|
||||
85734335 | S1400 | 0 | 0
|
||||
85736037 | S1400 | 0 | 0
|
||||
624683742 | S1400 | 0 | 128.528874268666
|
||||
85719343 | S1400 | 260.839270432962 | 260.839270432962
|
||||
85741826 | S1400 | 164.759294123275 | 260.839270432962
|
||||
85732032 | S1400 | 277.75 | 311.830282365264
|
||||
85735592 | S1400 | 222.25 | 311.830282365264
|
||||
(10 rows)
|
||||
</programlisting>
|
||||
</refsection>
|
||||
<refsection>
|
||||
<title>See Also</title>
|
||||
<para><xref linkend="ST_DWithin" />, <xref linkend="ST_Distance" />, <xref linkend="geometry_distance_centroid" /></para>
|
||||
</refsection>
|
||||
</refentry>
|
||||
|
||||
|
|
Loading…
Reference in a new issue