def project_onto(objs, axis, min_gap_size=<NUM_LIT>):
if axis == "<STR_LIT:x>":<EOL><INDENT>axis = <NUM_LIT:0><EOL><DEDENT>if axis == "<STR_LIT:y>":<EOL><INDENT>axis = <NUM_LIT:1><EOL><DEDENT>axis_end = axis + <NUM_LIT:2><EOL>if axis == <NUM_LIT:0>:  <EOL><INDENT>objs.sort(key=lambda o: o.x0)<EOL><DEDENT>else:<EOL><INDENT>objs.sort(key=lambda o: o.y0)<EOL><DEDENT>intervals = []<EOL>groups = []<EOL>start_i = <NUM_LIT:0><EOL>start = objs[<NUM_LIT:0>].bbox[axis]<EOL>end = objs[<NUM_LIT:0>].bbox[axis_end]<EOL>for o_i, o in enumerate(chain(objs, [_inf_bbox])):<EOL><INDENT>o_start = o.bbox[axis]<EOL>o_end = o.bbox[axis_end]<EOL>if o_start > end + min_gap_size:<EOL><INDENT>intervals.append((start, end))<EOL>groups.append(objs[start_i:o_i])<EOL>start_i = o_i<EOL>start = o_start<EOL><DEDENT>if o_end > end:<EOL><INDENT>end = o_end<EOL><DEDENT><DEDENT>return intervals, groups<EOL>
Projects object bboxes onto the axis and return the
unioned intervals and groups of objects in intervals.