GeoConvert is a command line utility for geographic coordinate conversions via GeographicLib::GeoCoords.
Examples:
Compile with "make GeoConvert" or with
g++ -g -O3 -I.. -o GeoConvert GeoConvert.cpp GeoCoords.cpp MGRS.cpp UTMUPS.cpp DMS.cpp Constants.cpp TransverseMercator.cpp PolarStereographic.cpp
Here is the usage (obtained from "GeoConvert -h")
Usage: GeoConvert [-g|-d|-u|-m|-c] [-p prec] [-z zone] [-s] [-h] Convert geographic coordinates to -g latitude and longitude (decimal degrees), default output -d latitude and longitude (degrees mins secs) -u UTM or UPS -m MGRS -c meridian convergence and scale The WGS84 model of the earth is used. Geographic coordinates are given on standard input as: Latitude and longitude (decimal degrees or degrees minutes seconds). d, ', and " are used to denote degrees, minutes, and seconds, with the least significant designator optional. Latitude is given first unless a hemisphere is specified, e.g., the following are all equivalent 33.3 44.4 E44.4 N33.3 33d18'N 44d24'E 44d24 33d18N UTM or UPS given as zone+hemisphere easting northing or easting northing zone+hemisphere. The zone is absent for a UPS specification. E.g., 38N 444140.54 3684706.36 444140.54 3684706.36 38N S 2173854.98 2985980.58 2173854.98 2985980.58 S MRGS is used to specify the center of a grid square, e.g., 38SMB4484 38SMB44140847064 -p prec (default 0) sets the precision relative to 1m. This gives the number of digits after the decimal point for UTM/UPS. The number of digits per coordinate for MGRS is 5 + prec. For decimal degrees, the number of digits after the decimal point is 5 + prec. For DMS (degree, minute, seconds) output, the number of digits after the decimal point in the seconds components is 1 + prec; if this is negative then use minutes (prec = -2 or -3) or degrees (prec <= -4) as the least significant component. Print convergence, resp. scale, with 5 + prec, resp. 7 + prec, digits after the decimal point. The minimum value of prec is -5 and the maximum is 9 for UTM/UPS, 9 for decimal degrees, 10 for DMS, 6 for MGRS, and 8 for convergence and scale. MGRS coordinates are given by truncating (instead of rounding) the coordinates to the requested precision. For example is prec = -3, the result is the 1km square enclosing the position. Convergence is the bearing of grid north given as degrees clockwise from true north. UTM/UPS and MGRS are given in zone of the input if applicable, otherwise in the standard zone. -z zone sets the zone for output. Use zone = 0 to specify UPS. -s uses the standard zone. For example, the point 79.9S 6.1E corresponds to possible MGRS coordinates 32CMS4324728161 (standard UTM zone = 32) 31CEM6066227959 (neighboring UTM zone = 31) BBZ1945517770 (neighboring UPS zone) then echo 79.9S 6.1E | GeoConvert -p -3 -m ==> 32CMS4328 echo 31CEM6066227959 | GeoConvert -p -3 -m ==> 31CEM6027 echo 31CEM6066227959 | GeoConvert -p -3 -m -s ==> 32CMS4328 echo 31CEM6066227959 | GeoConvert -p -3 -m -z 0 ==> BBZ1917 -h prints this help.
TransverseMercatorTest is a command line utility for testing GeographicLib::TransverseMercatorExact and GeographicLib::TransverseMercator.
Examples:
Compile with "make TransverseMercatorTest" or with
g++ -g -O3 -I.. -o TransverseMercatorTest TransverseMercatorTest.cpp TransverseMercatorExact.cpp Constants.cpp EllipticFunction.cpp TransverseMercator.cpp
Note that, unlike GeoConvert, TransverseMercatorTest has no facility for dealing with angles in degrees, minutes, and seconds, and no ability to change the precision of the output.
Here is the usage (obtained from "TranverseMercatorTest -h")
TransverseMercatorTest [-r] [-t|-s] Convert between geographic coordinates and transverse Mercator coordinates. Read lines with latitude and longitude (or easting and northing if -r is specified) from standard input and print latitude, longitude, easting, northing, convergence, and scale. Units are degrees and meters. By default, the WGS84 is ellipsoid is used, central meridian = 0, UTM central scale, and false easting and false northing are zero. If -r is given, the reverse projection is performed (the inputs are easting and northing). If -s is given, the sixth-order Krueger series approximation to the transverse Mercator projection is used instead of the exact projection. If -t is specified, an ellipsoid of eccentricity 0.1 is used, central scale = 1, 1/4 meridian distance = 1. In addition, the cut in the exact transverse Mercator projection at northing = 0 is removed. The domain of latitude (lat) and longitude (lon) is the union of lat in [0, 90] and lon in [0, 90] lat in (-90, 0] and lon in [81, 90] The domain of easting (x) and northing (x) is the union of x in [0, inf) and y in [0, 1] x in [1.71..., inf) and y in (-inf, 0] -s and -t are mutually exclusive (the last flag specified is the operative one). -h prints this help.
Geod is a command line utility for geodesic calculations.
Example (route from JFK Airport to Singapore Changi Airport)
Compile with "make Geod" or with
g++ -g -O3 -I.. -o Geod Geod.cpp Geodesic.cpp DMS.cpp Constants.cpp
Here is the usage (obtained from "Geod -h")
Usage: Geod [-l lat1 lon1 azi1 | -i] [-n] [-d] [-f] [-p prec] [-h] Perform geodesic calculations. The shortest path between two points on the ellipsoid at (lat1, lon1) and (lat2, lon2) is called the geodesic. Its length is s12 and the geodesic from point 1 to point 2 has azimuths azi1 and azi2 at the two end points. Geod operates in one of three modes: (1) It accepts lines on the standard input containing "lat1 lon1 azi1 s12" and prints "lat2 lon2 azi2" on standard output. This is the direct geodesic calculation. (2) Command line arguments "-l lat1 lon1 azi1" specify a geodesic line. Geod then accepts a sequence of s12 values (one per line) on standard input and prints "lat2 lon2 azi2" for each. This generates a sequence of points on a single geodesic. (3) With the -i command line argument, Geod performs the inverse geodesic calculation. It reads lines containing "lat1 lon1 lat2 lon2" and prints the corresponding values of "azi1 azi2 s12". By default, the WGS84 ellipsoid is used. With the -n option, it uses the international ellipsoid (major radius 6378388 m, inverse flattening 297). Output of angles is as decimal degrees. If -d is specified the output is as degrees, minutes, seconds. Input can be in either style. d, ', and " are used to denote degrees, minutes, and seconds, with the least significant designator optional. By default, latitude precedes longitude for each point; however on input either may be given first by appending N or S to the latitude and E or W to the longitude. s12 is always given in meters. The output lines consist of the three quantities needs to complete the specification of the geodesic. With the -f option, each line of output is a complete geodesic specification consisting of seven quantities lat1 lon1 azi1 lat2 lon2 azi2 s12 -p prec (default 3) gives the precision of the output relative to 1m. The minimum value of prec is 0 (1 m accuracy) and the maximum value is 10 (0.1 nm accuracy, but then the last digits are unreliable). -h prints this help.
CartConvert is a command line utility for geodetic to cartesian coordinate conversions via GeographicLib::Geocentric and GeographicLib::LocalCartesian.
Examples:
Compile with "make CartConvert" or with
g++ -g -O3 -I.. -o CartConvert CartConvert.cpp Geocentric.cpp LocalCartesian.cpp Constants.cpp
Note that, unlike GeoConvert, CartConvert has no facility for dealing with angles in degrees, minutes, and seconds, and no ability to change the precision of the output.
Here is the usage (obtained from "CartConvert -h")
Usage: CartConvert [-r] [-l lat0 lon0 h0] [-h] Convert geodetic coordinates to either geocentric or local cartesian coordinates. Geocentric coordinates have the origin at the center of the earth, with the z axis going thru the north pole, and the x axis thru lat = 0, lon = 0. By default, the conversion is to geocentric coordinates. Specifying -l lat0 lon0 h0 causes a local coordinate system to be used with the origin at latitude = lat0, longitude = lon0, height = h0, z normal to the ellipsoid and y due north. The WGS84 model of the earth is used. Geodetic coordinates are provided on standard input as a set of lines containing (blank separated) latitude, longitude (decimal degrees), and height (meters). For each set of geodetic coordinates, the corresponding cartesian coordinates x, y, z (meters) are printed on standard output. If -r is given the reverse transformation is performed. -h prints this help