“…At each iteration, we compute Morton code ranges corresponding to the query window using Algorithm 1 described in Section 5.1. CreateMainMRSDQuery((x1, y1, x2, y2), ǫ) input : Query window (x 1 , y 1 , x 2 , y 2 ), Proximity threshold ǫ output : A SQL statement st st ← "SELECT id, count( * ) as ds FROM ("; 1 l ← Compute the Morton code length as (−⌊log 2 ǫ⌋); 2 foreach col in ["t0"..."t8"] do 3 (codes, codee) ← Compute Morton code range for 4 (x 1 , y 1 , x 2 , y 2 ) with respect to the offset of col; ranges ← SplitRange(codes, codee) ; 5 foreach (cs, ce) in ranges do 6 st ← st ++ "(" ++ Subquery(col, cs, ce, length) ++ ")"; …”