PostGIS  2.1.10dev-r@@SVN_REVISION@@
static double box2df_distance ( const BOX2DF *  a,
const BOX2DF *  b 
)
static

Calculate the box->box distance.

Definition at line 476 of file gserialized_gist_2d.c.

References box2df_above(), box2df_below(), box2df_left(), box2df_overlaps(), box2df_right(), MAXFLOAT, and pt_distance().

Referenced by gserialized_distance_box_2d(), and gserialized_gist_distance_2d().

477 {
478  /* Check for overlap */
479  if ( box2df_overlaps(a, b) )
480  return 0.0;
481 
482  if ( box2df_left(a, b) )
483  {
484  if ( box2df_above(a, b) )
485  return pt_distance(a->xmax, a->ymin, b->xmin, b->ymax);
486  if ( box2df_below(a, b) )
487  return pt_distance(a->xmax, a->ymax, b->xmin, b->ymin);
488  else
489  return b->xmin - a->xmax;
490  }
491  if ( box2df_right(a, b) )
492  {
493  if ( box2df_above(a, b) )
494  return pt_distance(a->xmin, a->ymin, b->xmax, b->ymax);
495  if ( box2df_below(a, b) )
496  return pt_distance(a->xmin, a->ymax, b->xmax, b->ymin);
497  else
498  return a->xmin - b->xmax;
499  }
500  if ( box2df_above(a, b) )
501  {
502  if ( box2df_left(a, b) )
503  return pt_distance(a->xmax, a->ymin, b->xmin, b->ymax);
504  if ( box2df_right(a, b) )
505  return pt_distance(a->xmin, a->ymin, b->xmax, b->ymax);
506  else
507  return a->ymin - b->ymax;
508  }
509  if ( box2df_below(a, b) )
510  {
511  if ( box2df_left(a, b) )
512  return pt_distance(a->xmax, a->ymax, b->xmin, b->ymin);
513  if ( box2df_right(a, b) )
514  return pt_distance(a->xmin, a->ymax, b->xmax, b->ymin);
515  else
516  return b->ymin - a->ymax;
517  }
518 
519  return MAXFLOAT;
520 }
static bool box2df_overlaps(const BOX2DF *a, const BOX2DF *b)
static bool box2df_left(const BOX2DF *a, const BOX2DF *b)
static bool box2df_below(const BOX2DF *a, const BOX2DF *b)
static bool box2df_right(const BOX2DF *a, const BOX2DF *b)
static bool box2df_above(const BOX2DF *a, const BOX2DF *b)
static double pt_distance(double ax, double ay, double bx, double by)
#define MAXFLOAT
Largest float value.

Here is the call graph for this function:

Here is the caller graph for this function: