var layout = function () { var needed_slots; var scale; var feature_height = 20; var callback = function (){}; var feature_layout = function (new_features) { var track = this; scale = track.display().scale(); needed_slots = collition_detector(new_features); track.height(needed_slots * feature_height); callback(); return new_features; }; function collition_detector (features) { var allocated = []; var remaining = features; var needed_slots = 0; for (var i=0; i needed_slots) { needed_slots = slot; } break; } slot++; } } return needed_slots + 1; } function slot_has_space (feature, features_in_slot) { if (!features_in_slot) { return true; } for (var i=0; i= y1)) || ((x1 >= y1) && (x1 <= y2)) ) { return false; } } return true; } function sort_features_by_slot (features) { var slots = []; for (var i=0; i