PostGIS  2.3.7dev-r@@SVN_REVISION@@
int geography_tree_distance ( const GSERIALIZED g1,
const GSERIALIZED g2,
const SPHEROID s,
double  tolerance,
double *  distance 
)

Definition at line 276 of file geography_measurement_trees.c.

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

Referenced by geography_distance_tree().

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

Here is the call graph for this function:

Here is the caller graph for this function: