PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ ST_DistanceRectTree()

Datum ST_DistanceRectTree ( PG_FUNCTION_ARGS  )

Definition at line 120 of file lwgeom_rectree.c.

121 {
122  GSERIALIZED *g1 = PG_GETARG_GSERIALIZED_P(0);
123  GSERIALIZED *g2 = PG_GETARG_GSERIALIZED_P(1);
124  LWGEOM *lwg1, *lwg2;
125  RECT_NODE *n1, *n2;
126 
127  /* Return NULL on empty arguments. */
129  {
130  PG_FREE_IF_COPY(g1, 0);
131  PG_FREE_IF_COPY(g2, 1);
132  PG_RETURN_NULL();
133  }
134 
135  lwg1 = lwgeom_from_gserialized(g1);
136  lwg2 = lwgeom_from_gserialized(g2);
137 
138  /* Two points? Get outa here... */
139  if (lwg1->type == POINTTYPE && lwg2->type == POINTTYPE)
140  PG_RETURN_FLOAT8(lwgeom_mindistance2d(lwg1, lwg2));
141 
142 
143  n1 = rect_tree_from_lwgeom(lwg1);
144  n2 = rect_tree_from_lwgeom(lwg2);
145  PG_RETURN_FLOAT8(rect_tree_distance_tree(n1, n2, 0.0));
146 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
Definition: g_serialized.c:179
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
double lwgeom_mindistance2d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initializing min distance calculation.
Definition: measures.c:202
RECT_NODE * rect_tree_from_lwgeom(const LWGEOM *lwgeom)
Create a tree index on top an LWGEOM.
Definition: lwtree.c:861
double rect_tree_distance_tree(RECT_NODE *n1, RECT_NODE *n2, double threshold)
Return the distance between two RECT_NODE trees.
Definition: lwtree.c:1354
uint8_t type
Definition: liblwgeom.h:399

References gserialized_is_empty(), lwgeom_from_gserialized(), lwgeom_mindistance2d(), POINTTYPE, rect_tree_distance_tree(), rect_tree_from_lwgeom(), and LWGEOM::type.

Here is the call graph for this function: