Have you tried using Google?
The maths to calculate the distance between two pairs of lat long coordinates is fairly straight forward and easily found online. As Chris says there are several flows within
http://flows.nodered.org that should help you in how to structure the flow.
One thing you will need to do is store the values of one pair of lat, longs and trigger the calculation when the other pair arrives.
There are examples of doing this in the forum.