title: How to calculate distance from a point to a line segment, on a sphere?
body: <p>I have a line segment (great circle part) on earth. The line segment is defined by the coordinates of its ends. Obviously, two points define two line segments, so assume I am interested in the shorter one. </p>
  
  <p>I am given a third point, and I am looking for the (shortest) distance between the line and the point. </p>
  
  <p>All the coordinates are given in longitude\latitude (WGS 84). </p>
  
  <p>How do I calculate the distance? </p>
  
  <p>A solution in any reasonable programming language will do. </p>