drolbr / Overpass-API

A database engine to query the OpenStreetMap data.
http://overpass-api.de
GNU Affero General Public License v3.0
693 stars 90 forks source link

length() should use WGS-84 Ellipsoid #632

Open bepfitz opened 2 years ago

bepfitz commented 2 years ago

The computation of lengths (geometry.cc) uses great circles on a sphere (great_circle_dist). It should account for Earth coordinates to refer to an ellipsoid, e.g. using WGS-84. The deviation for road segments in Germany is in my opinion on the order of 2%.

drolbr commented 2 years ago

Short answer: the underlying earth model of Overpass API is a sphere with 40.000 km circumference. Thus, length() works as intended.

Long answer: There are three substantially different degrees of exactitude: the flat world if one thinks in terms of a map, various global models resembling potatoes (including WGS84 and the sphere), and finally what you get in the field.

If I look out of the window I see a steep street. Note that neither OSM nor WGS84 have knowledge about local elevation, and that elevation changes length as well. Then we have not even started to talk about potential inaccuracies in OSM coordinates.

OSM aims at layman, and it is easier to explain a sphere than to explain an ellipsoid. The extra exactitude is not worth the effort. In addition, a sphere has simpler math than an ellipsoid in an environment where every saved trigonometry function call means to enable a couple more people per day to use the service.

Nonetheless, I would be interested to get a detailed explanation how and where the length measurements differ to what extent between sphere and ellipsoid. A quick hack when properly understanding the difference could be to re-choose the circumference such that the differences are proven to be minimized.