Provided by: geographiclib-tools_1.49-5_amd64

**NAME**

GeodSolve -- perform geodesic calculations

**SYNOPSIS**

GeodSolve[-i|-Llat1lon1azi1|-Dlat1lon1azi1s13|-Ilat1lon1lat3lon3] [-a] [-eaf] [-u] [-F] [-d|-:] [-w] [-b] [-f] [-pprec] [-E] [--comment-delimitercommentdelim] [--version|-h|--help] [--input-fileinfile|--input-stringinstring] [--line-separatorlinesep] [--output-fileoutfile]

**DESCRIPTION**

The shortest path between two points on the ellipsoid at (lat1,lon1) and (lat2,lon2) is called the geodesic. Its length iss12and the geodesic from point 1 to point 2 has forward azimuthsazi1andazi2at the two end points.GeodSolveoperates in one of three modes: 1. By default,GeodSolveaccepts lines on the standard input containinglat1lon1azi1s12and printslat2lon2azi2on standard output. This is the direct geodesic calculation. 2. With the-icommand line argument,GeodSolveperforms the inverse geodesic calculation. It reads lines containinglat1lon1lat2lon2and prints the corresponding values ofazi1azi2s12. 3. Command line arguments-Llat1lon1azi1specify a geodesic line.GeodSolvethen accepts a sequence ofs12values (one per line) on standard input and printslat2lon2azi2for each. This generates a sequence of points on a single geodesic. Command line arguments-Dand-Iwork similarly with the geodesic line defined in terms of a direct or inverse geodesic calculation, respectively.

**OPTIONS**

-iperform an inverse geodesic calculation (see 2 above).-Llat1lon1azi1line mode (see 3 above); generate a sequence of points along the geodesic specified bylat1lon1azi1. The-wflag can be used to swap the default order of the 2 geographic coordinates, provided that it appears before-L. (-lis an alternative, deprecated, spelling of this flag.)-Dlat1lon1azi1s13line mode (see 3 above); generate a sequence of points along the geodesic specified bylat1lon1azi1s13. The-wflag can be used to swap the default order of the 2 geographic coordinates, provided that it appears before-D. Similarly, the-aflag can be used to change the interpretation ofs13toa13, provided that it appears before-D.-Ilat1lon1lat3lon3line mode (see 3 above); generate a sequence of points along the geodesic specified bylat1lon1lat3lon3. The-wflag can be used to swap the default order of the 2 geographic coordinates, provided that it appears before-I.-atoggle the arc mode flag (it starts off); if this flag is on, then on inputandoutputs12is replaced bya12the arc length (in degrees) on the auxiliary sphere. See "AUXILIARY SPHERE".-eafspecify the ellipsoid via the equatorial radius,aand the flattening,f. Settingf= 0 results in a sphere. Specifyf< 0 for a prolate ellipsoid. A simple fraction, e.g., 1/297, is allowed forf. By default, the WGS84 ellipsoid is used,a= 6378137 m,f= 1/298.257223563.-uunroll the longitude. Normally, on output longitudes are reduced to lie in [-180deg,180deg). However with this option, the returned longitudelon2is "unrolled" so thatlon2-lon1indicates how often and in what sense the geodesic has encircled the earth. Use the-foption, to get both longitudes printed.-Ffractional mode. This only has any effect with the-Dand-Ioptions (and is otherwise ignored). The values read on standard input are interpreted as fractional distances to point 3, i.e., ass12/s13instead ofs12. If arc mode is in effect, then the values denote fractional arc length, i.e.,a12/a13.-doutput angles as degrees, minutes, seconds instead of decimal degrees.-:like-d, except use : as a separator instead of the d, ', and " delimiters.-wtoggle the longitude first flag (it starts off); if the flag is on, then on input and output, longitude precedes latitude (except that, on input, this can be overridden by a hemisphere designator,N,S,E,W).-breport thebackazimuth at point 2 instead of the forward azimuth.-ffull output; each line of output consists of 12 quantities:lat1lon1azi1lat2lon2azi2s12a12m12M12M21S12.a12is described in "AUXILIARY SPHERE". The four quantitiesm12,M12,M21, andS12are described in "ADDITIONAL QUANTITIES".-pprecset the output precision toprec(default 3);precis the precision relative to 1 m. See "PRECISION".-Euse "exact" algorithms (based on elliptic integrals) for the geodesic calculations. These are more accurate than the (default) series expansions for |f| > 0.02.--comment-delimitercommentdelimset the comment delimiter tocommentdelim(e.g., "#" or "//"). If set, the input lines will be scanned for this delimiter and, if found, the delimiter and the rest of the line will be removed prior to processing and subsequently appended to the output line (separated by a space).--versionprint version and exit.-hprint usage and exit.--helpprint full documentation and exit.--input-fileinfileread input from the fileinfileinstead of from standard input; a file name of "-" stands for standard input.--input-stringinstringread input from the stringinstringinstead of from standard input. All occurrences of the line separator character (default is a semicolon) ininstringare converted to newlines before the reading begins.--line-separatorlinesepset the line separator character tolinesep. By default this is a semicolon.--output-fileoutfilewrite output to the fileoutfileinstead of to standard output; a file name of "-" stands for standard output.

**INPUT**

GeodSolvemeasures all angles in degrees and all lengths (s12) in meters, and all areas (S12) in meters^2. On input angles (latitude, longitude, azimuth, arc length) can be as decimal degrees or degrees, minutes, seconds. For example, "40d30", "40d30'", "40:30", "40.5d", and 40.5 are all equivalent. By default, latitude precedes longitude for each point (the-wflag switches this convention); however on input either may be given first by appending (or prepending)NorSto the latitude andEorWto the longitude. Azimuths are measured clockwise from north; however this may be overridden withEorW. For details on the allowed formats for angles, see the "GEOGRAPHIC COORDINATES" section ofGeoConvert(1).

**AUXILIARY** **SPHERE**

Geodesics on the ellipsoid can be transferred to theauxiliarysphereon which the distance is measured in terms of the arc lengtha12(measured in degrees) instead ofs12. In terms ofa12, 180 degrees is the distance from one equator crossing to the next or from the minimum latitude to the maximum latitude. Geodesics witha12> 180 degrees do not correspond to shortest paths. With the-aflag,s12(on both input and output) is replaced bya12. The-aflag doesnotaffect the full output given by the-fflag (which always includes boths12anda12).

**ADDITIONAL** **QUANTITIES**

The-fflag reports four additional quantities. The reduced length of the geodesic,m12, is defined such that if the initial azimuth is perturbed by dazi1(radians) then the second point is displaced bym12dazi1in the direction perpendicular to the geodesic.m12is given in meters. On a curved surface the reduced length obeys a symmetry relation,m12+m21= 0. On a flat surface, we havem12=s12.M12andM21are geodesic scales. If two geodesics are parallel at point 1 and separated by a small distancedt, then they are separated by a distanceM12dtat point 2.M21is defined similarly (with the geodesics being parallel to one another at point 2).M12andM21are dimensionless quantities. On a flat surface, we haveM12=M21= 1. If points 1, 2, and 3 lie on a single geodesic, then the following addition rules hold: s13 = s12 + s23, a13 = a12 + a23, S13 = S12 + S23, m13 = m12 M23 + m23 M21, M13 = M12 M23 - (1 - M12 M21) m23 / m12, M31 = M32 M21 - (1 - M23 M32) m12 / m23. Finally,S12is the area between the geodesic from point 1 to point 2 and the equator; i.e., it is the area, measured counter-clockwise, of the geodesic quadrilateral with corners (lat1,lon1), (0,lon1), (0,lon2), and (lat2,lon2). It is given in meters^2.

**PRECISION**

precgives precision of the output withprec= 0 giving 1 m precision,prec= 3 giving 1 mm precision, etc.precis the number of digits after the decimal point for lengths. For decimal degrees, the number of digits after the decimal point isprec+ 5. For DMS (degree, minute, seconds) output, the number of digits after the decimal point in the seconds component isprec+ 1. The minimum value ofprecis 0 and the maximum is 10.

**ERRORS**

An illegal line of input will print an error message to standard output beginning with "ERROR:" and causesGeodSolveto return an exit code of 1. However, an error does not causeGeodSolveto terminate; following lines will be converted.

**ACCURACY**

Using the (default) series solution, GeodSolve is accurate to about 15 nm (15 nanometers) for the WGS84 ellipsoid. The approximate maximum error (expressed as a distance) for an ellipsoid with the same equatorial radius as the WGS84 ellipsoid and different values of the flattening is |f| error 0.01 25 nm 0.02 30 nm 0.05 10 um 0.1 1.5 mm 0.2 300 mm If-Eis specified, GeodSolve is accurate to about 40 nm (40 nanometers) for the WGS84 ellipsoid. The approximate maximum error (expressed as a distance) for an ellipsoid with a quarter meridian of 10000 km and different values of thea/b= 1 -fis 1-f error (nm) 1/128 387 1/64 345 1/32 269 1/16 210 1/8 115 1/4 69 1/2 36 1 15 2 25 4 96 8 318 16 985 32 2352 64 6008 128 19024

**MULTIPLE** **SOLUTIONS**

The shortest distance returned for the inverse problem is (obviously) uniquely defined. However, in a few special cases there are multiple azimuths which yield the same shortest distance. Here is a catalog of those cases:lat1= -lat2(with neither point at a pole) Ifazi1=azi2, the geodesic is unique. Otherwise there are two geodesics and the second one is obtained by setting [azi1,azi2] = [azi2,azi1], [M12,M21] = [M21,M12],S12= -S12. (This occurs when the longitude difference is near +/-180 for oblate ellipsoids.)lon2=lon1+/- 180 (with neither point at a pole) Ifazi1= 0 or +/-180, the geodesic is unique. Otherwise there are two geodesics and the second one is obtained by setting [azi1,azi2] = [-azi1,-azi2],S12= -S12. (This occurs whenlat2is near -lat1for prolate ellipsoids.) Points 1 and 2 at opposite poles There are infinitely many geodesics which can be generated by setting [azi1,azi2] = [azi1,azi2] + [d,-d], for arbitraryd. (For spheres, this prescription applies when points 1 and 2 are antipodal.)s12= 0 (coincident points) There are infinitely many geodesics which can be generated by setting [azi1,azi2] = [azi1,azi2] + [d,d], for arbitraryd.

**EXAMPLES**

Route from JFK Airport to Singapore Changi Airport: echo 40:38:23N 073:46:44W 01:21:33N 103:59:22E | GeodSolve -i -: -p 0 003:18:29.9 177:29:09.2 15347628 Equally spaced waypoints on the route: for ((i = 0; i <= 10; ++i)); do echo ${i}e-1; done | GeodSolve -I 40:38:23N 073:46:44W 01:21:33N 103:59:22E -F -: -p 0 40:38:23.0N 073:46:44.0W 003:18:29.9 54:24:51.3N 072:25:39.6W 004:18:44.1 68:07:37.7N 069:40:42.9W 006:44:25.4 81:38:00.4N 058:37:53.9W 017:28:52.7 83:43:26.0N 080:37:16.9E 156:26:00.4 70:20:29.2N 097:01:29.4E 172:31:56.4 56:38:36.0N 100:14:47.6E 175:26:10.5 42:52:37.1N 101:43:37.2E 176:34:28.6 29:03:57.0N 102:39:34.8E 177:07:35.2 15:13:18.6N 103:22:08.0E 177:23:44.7 01:21:33.0N 103:59:22.0E 177:29:09.2

**SEE** **ALSO**

GeoConvert(1). An online version of this utility is availbable at <https://geographiclib.sourceforge.io/cgi-bin/GeodSolve>. The algorithms are described in C. F. F. Karney,Algorithmsforgeodesics, J. Geodesy 87, 43-55 (2013); DOI: <https://doi.org/10.1007/s00190-012-0578-z>; addenda: <https://geographiclib.sourceforge.io/geod-addenda.html>. The Wikipedia page, Geodesics on an ellipsoid, <https://en.wikipedia.org/wiki/Geodesics_on_an_ellipsoid>.

**AUTHOR**

GeodSolvewas written by Charles Karney.

**HISTORY**

GeodSolvewas added to GeographicLib, <https://geographiclib.sourceforge.io>, in 2009-03. Prior to version 1.30, it was calledGeod. (The name was changed to avoid a conflict with thegeodutility inproj.4.)