MobilityDB 1.1

◆ span_level_cmp()

static int span_level_cmp ( Span centroid,
Span query,
int  level 
)
static

Determine which half a 2D-mapped span falls into, relative to the centroid and the level number.

Halves are numbered 0 and 1, and depending on whether the level number is even or odd, respectively, they will be as follows:

----+----
0 | 1
----+----

or

---------
1
---------
0
---------

where the lower bound of the span is the horizontal axis and the upper bound is the vertical axis.

Periods whose lower/upper bound is equal to the centroid bound (including their inclusive flag) may get classified into either node depending on where they happen to fall in the sorted list. This is okay as long as the inner_consistent function descends into both sides for such cases. This is better than the alternative of trying to have an exact boundary, because it keeps the tree balanced even when we have many instances of the same span value. In this way, we should never trigger the allTheSame logic.