[GIS] Computing distance between two spherical Mercator points

distanceopenstreetmappointweb-mercator

I am computing the Mercator points according to the top answer at Convert latitude/longitude point to a pixels (x,y) on Mercator projection.

Now that I have two Mercator points on a spherical projection, how do I compute the distance between them?

For some background, what I am attempting to do is implement the answer at How to calculate the optimal zoom-level to display two or more points on a map and am stuck at step #2 where I need to compute the distance.

Best Answer

As mentioned by @mkkenedy in a comment on the question: once you've converted your latitude/longitude coordinates to Mercator coordinates, they are on a Euclidean plane, where you can use the Pythagorean theorem.

Specifically, if your Mercator coordinates are (x1, y1) and (x2, y2), the distance is:

sqrt((x2-x1)^2 + (y2-y1)^2)