getDistFromSource function

Moving window approach to get distance from source