PostGIS  2.5.0beta2dev-r@@SVN_REVISION@@

◆ circ_tree_distance_tree()

double circ_tree_distance_tree ( const CIRC_NODE n1,
const CIRC_NODE n2,
const SPHEROID spheroid,
double  threshold 
)

Definition at line 581 of file lwgeodetic_tree.c.

References SPHEROID::a, SPHEROID::b, circ_tree_distance_tree_internal(), SPHEROID::radius, sphere_distance(), and spheroid_distance().

Referenced by geography_distance_cache_tolerance(), geography_tree_distance(), test_tree_circ_distance(), and test_tree_circ_distance_threshold().

582 {
583  double min_dist = FLT_MAX;
584  double max_dist = FLT_MAX;
585  GEOGRAPHIC_POINT closest1, closest2;
586  /* Quietly decrease the threshold just a little to avoid cases where */
587  /* the actual spheroid distance is larger than the sphere distance */
588  /* causing the return value to be larger than the threshold value */
589  double threshold_radians = 0.95 * threshold / spheroid->radius;
590 
591  circ_tree_distance_tree_internal(n1, n2, threshold_radians, &min_dist, &max_dist, &closest1, &closest2);
592 
593  /* Spherical case */
594  if ( spheroid->a == spheroid->b )
595  {
596  return spheroid->radius * sphere_distance(&closest1, &closest2);
597  }
598  else
599  {
600  return spheroid_distance(&closest1, &closest2, spheroid);
601  }
602 }
double sphere_distance(const GEOGRAPHIC_POINT *s, const GEOGRAPHIC_POINT *e)
Given two points on a unit sphere, calculate their distance apart in radians.
Definition: lwgeodetic.c:917
double b
Definition: liblwgeom.h:316
double radius
Definition: liblwgeom.h:320
static double circ_tree_distance_tree_internal(const CIRC_NODE *n1, const CIRC_NODE *n2, double threshold, double *min_dist, double *max_dist, GEOGRAPHIC_POINT *closest1, GEOGRAPHIC_POINT *closest2)
Point in spherical coordinates on the world.
Definition: lwgeodetic.h:47
double a
Definition: liblwgeom.h:315
double spheroid_distance(const GEOGRAPHIC_POINT *a, const GEOGRAPHIC_POINT *b, const SPHEROID *spheroid)
Computes the shortest distance along the surface of the spheroid between two points.
Definition: lwspheroid.c:186
Here is the call graph for this function:
Here is the caller graph for this function: