Ticket #3426 (new feature)

Opened 3 years ago

Last modified 3 years ago

Accurate treatment of geodesics

Reported by: karney Owned by:
Priority: minor Milestone: 2.13 Release
Component: Util Version: 2.10
Keywords: Geodesics Cc:
State:

Description

OpenLayers 2.10 provides distVincenty and destinationVincenty which compute geodesics using Vincenty's method. However this method suffers from two problems:

* the distance calculation fails to converge from some pairs of points;
* where it converges the error is rather large (about 0.5mm).

OpenLayers also provides a function getGeodesicArea which is inaptly named because

* it treats only a sphere and not the ellipsoid;
* the edges of the polygon are not geodesics (or great circles) but rather straight lines on a cylindrical equal-area projection;
* the polygon cannot enclose a pole.

The attached patch adds distGeodesic, destinationGeodesic, and getTrueGeodesicArea which correct the problems noted about. These use the Javascript port of the geodesic functionality in GeographicLib. For a sample of the capabilities, see

 http://geographiclib.sourceforge.net/scripts/geod-calc.html

GeographicLib also provides facilities which may be useful to OpenLayers in the future (for instance it can simplify finding the intersection of geodesics).

GeographicLib using the MIT/X11 license so you are free to incorporate it into OpenLayers.

Attachments

openlayers-2.10.patch Download (4.8 KB) - added by karney 3 years ago.

Change History

Changed 3 years ago by karney

Changed 3 years ago by ahocevar

Thanks @karney for the pointer to GeographicLib and this great contribution. Unfortunately I didn't have much time to review, so just a quick comment:

One thing that comes to mind would be that instead of adding a new getTrueGeodesicArea method, it would make sense to check for the availability of GeograpicLib, use it if available, and otherwise fall back to Vincenty. Maybe this mechanism could be implemented without adding Util.distGeodesic and Util.destinationGeodesic methods. I'm saying this because we don't want to increase the size of Util.js unless inevitably needed.

Changed 3 years ago by karney

A possibility would be to distribute the GeographicLib js files with OpenLayers and then dump {dist,destination}Vincenty in favor of {dist,destination}Geodesic. This would allow you to shrink Util.js.

Note: See TracTickets for help on using tickets.