A sentence from a high school textbook :
'Originally, matches on Boxing Day were played against local rivals to avoid teams and their fans having to travel long distances after Christmas Day.'
What is the grammatical usage (or should I call it) of 'having' in this sentence?