This question already has an answer here:
I'm trying to calculate the shortest distance between a line (described as a pair of [lat, long]s) and a point (lat, long) accurately. I've read many Wikipedia pages, but I'm new to the topic. I've read this question, but I'm still confused, because they say that
Literally, a "straight line" will pass beneath the earth's surface.
while my line lies on the surface of the Earth. How can I calculate this?