Refactor GPX creation routines to share common code.