• Robin Bobcat (unregistered)

Only additional input I can give would be checking how latdiff and longdiff are calculated. If you are dealing with only North America, sure, fine, whatever. But I could see some really horrible edge cases crop up near the equator, prime meridian, or the poles.

You have a start point of, say, 90° longitude, and 15° North latitude. Your end point is 100° longitude, and 15° South latitude. If you're treating them as absolute values, then you wind up describing a straight line instead of a diagonal. (Without getting into curvature, etc.)

Falls under the aegis of 'dealing with polar coordinates' I suppose, but I am willing to bet that those edge cases aren't handled if they're not handling the rest of it well.

• (nodebb)

Even if they're signed values, you have a problem around the antimeridian (180°). For londiff, you should take the minimum between lon2 - lon1 and 360 - (lon2 - lon1). That's because the longitude difference between 170° West and 175° East is 15°, not 345°. But the formula is so wrong, it doesn't even matter how they calculate the parameters.

Keep in mind the Earth is not actually a sphere. Because it is spinning, it bulges out in the middle a bit. The equator is quite a few kilometres longer than the (approximate) circle going from the North Pole to the South Pole and back again, say coming down the Prime Meridian and going back up 180 degrees longitude.