PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ geography_tree_distance()

int geography_tree_distance ( const GSERIALIZED g1,
const GSERIALIZED g2,
const SPHEROID s,
double  tolerance,
double *  distance 
)

Definition at line 285 of file geography_measurement_trees.c.

286 {
287  CIRC_NODE* circ_tree1 = NULL;
288  CIRC_NODE* circ_tree2 = NULL;
289  LWGEOM* lwgeom1 = NULL;
290  LWGEOM* lwgeom2 = NULL;
291  POINT4D pt1, pt2;
292 
293  lwgeom1 = lwgeom_from_gserialized(g1);
294  lwgeom2 = lwgeom_from_gserialized(g2);
295  circ_tree1 = lwgeom_calculate_circ_tree(lwgeom1);
296  circ_tree2 = lwgeom_calculate_circ_tree(lwgeom2);
297  lwgeom_startpoint(lwgeom1, &pt1);
298  lwgeom_startpoint(lwgeom2, &pt2);
299 
300  if ( CircTreePIP(circ_tree1, g1, &pt2) || CircTreePIP(circ_tree2, g2, &pt1) )
301  {
302  *distance = 0.0;
303  }
304  else
305  {
306  /* Calculate tree/tree distance */
307  *distance = circ_tree_distance_tree(circ_tree1, circ_tree2, s, tolerance);
308  }
309 
310  circ_tree_free(circ_tree1);
311  circ_tree_free(circ_tree2);
312  lwgeom_free(lwgeom1);
313  lwgeom_free(lwgeom2);
314  return LW_SUCCESS;
315 }
char * s
Definition: cu_in_wkt.c:23
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
static int CircTreePIP(const CIRC_NODE *tree1, const GSERIALIZED *g1, const POINT4D *in_point)
int lwgeom_startpoint(const LWGEOM *lwgeom, POINT4D *pt)
Definition: lwgeom.c:2122
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
#define LW_SUCCESS
Definition: liblwgeom.h:80
double circ_tree_distance_tree(const CIRC_NODE *n1, const CIRC_NODE *n2, const SPHEROID *spheroid, double threshold)
void circ_tree_free(CIRC_NODE *node)
Recurse from top of node tree and free all children.
CIRC_NODE * lwgeom_calculate_circ_tree(const LWGEOM *lwgeom)
Datum distance(PG_FUNCTION_ARGS)
Note that p1 and p2 are pointers into an independent POINTARRAY, do not free them.

References circ_tree_distance_tree(), circ_tree_free(), CircTreePIP(), distance(), LW_SUCCESS, lwgeom_calculate_circ_tree(), lwgeom_free(), lwgeom_from_gserialized(), lwgeom_startpoint(), and s.

Referenced by geography_distance(), and geography_distance_tree().

Here is the call graph for this function:
Here is the caller graph for this function: