MobilityDB 1.3
Loading...
Searching...
No Matches

◆ distance_tbox_nodebox()

static double distance_tbox_nodebox ( const TBox query,
const TboxNode nodebox 
)
static

Return the lower bound for the distance between query and nodebox.

The distance between two spans s1 and s2 is

  • s1.upper - s2.lower if s1 is to the left of s2: s1.upper > s2.lower
  • s1.lower - s2.upper if s1 is to the right of s2: s1.lower > s2.upper
  • 0 if the s1 and s2 overlap Therefore, given a query box and a node box, the minimum distance between a box in the node box and the query will be
  • nodebox->left.span.lower - query->span.upper (the distance between the upper bound of the query and the minimum of the lower bounds in the node box).
  • query->span.lower - nodebox->right.span.upper (the distance between the lower bound of the query and the maximum of the upper bounds in the node box).
  • 0 otherwise.

Continuing with the example at the top of this file, if TboxNode is

left = TBOXFLOAT XT([3, 7],[2001-01-03, 2001-01-07])
right = TBOXFLOAT XT([5, 9],[2001-01-05, 2001-01-09])

the distance with a query `TBOXFLOAT XT([10, 12],[2001-01-10, 2001-01-12]) is 10 - 9 = 1 since the query is to the right of the node box condition.

Note
The distance is computed only on the value dimension. The temporal dimension is taken into account for setting the distance to infinity when the time spans of the node box and the query do not overlap.