INTERSECTTOOL(1) | GeographicLib Utilities | INTERSECTTOOL(1) |
IntersectTool -- perform rhumb line calculations
IntersectTool [ -c | -n | -i | -o | [ -R maxdist ] [ -e a f] [ -E ] [ -w ] [ -p prec ] [ --comment-delimiter commentdelim ] [ --version | -h | --help ] [ --input-file infile | --input-string instring ] [ --line-separator linesep ] [ --output-file outfile ]
IntersectTool finds the intersection of two geodesics X and Y. The geodesics may either be specified as a location and an azimuth, latX lonX aziX, or as the shortest geodesic segment between two locations, latX1 lonX1 and latX2 lonX2. The intersection is then specified as the displacements, x and y, along the geodesics X and Y from the starting points to the intersection. In the case of the intersection of geodesic segments, the starting point is first point specified for X or Y.
Usually this tool returns the closest intersection defined as the one that minimizes the "L1" distance, |x| + |y|. However, it is possible to specify an "origin" x0 and y0 when determining closeness so that the intersection which minimizes |x - x0| + |y - y0| is returned.
In the case of intersecting segments the origin is taken to be the midpoints of the segments; x0 is half the distance from X1 to X2. In addition a flag is returned specifying whether the intersection is "within" the segments.
The tool also returns a "coincidence indicator" c. This is typically 0. However if the geodesics lie on top of one another at the point of intersection, then c is set to 1, if they are parallel, and -1, if they are antiparallel.
IntersectTool operates in one of three modes:
IntersectTool measures all angles in degrees and all lengths in meters. On input angles (latitude, longitude, azimuth) 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 -w flag switches this convention); however either may be given first by appending (or prepending) N or S to the latitude and E or W to the longitude. Azimuths are measured clockwise from north; however this may be overridden with E or W.
For details on the allowed formats for angles, see the "GEOGRAPHIC COORDINATES" section of GeoConvert(1).
prec gives precision of the output with prec = 0 giving 1 m precision, prec = 3 giving 1 mm precision, etc. prec is the number of digits after the decimal point for lengths. The latitude and longitude printed to standard error with the -C option are given in decimal degrees with prec + 5 digits after the decimal point. The minimum value of prec is 0 and the maximum is 10.
An illegal line of input will print an error message to standard output beginning with "ERROR:" and causes IntersectTool to return an exit code of 1. However, an error does not cause IntersectTool to terminate; following lines will be converted.
This tool will give nearly full double precision accuracy for |f| < 0.02. If the -E option is given, full accuracy is achieved for -1/4 < f < 1/5. The tool had not been tested outside this range.
A vessel leaves Plymouth 50N 4W on a geodesic path with initial heading 147.7W. When will it first cross the equator?
echo 50N 4W 147.7W 0 0 90 | IntersectTool -c -p 0 -C 6058049 -3311253 0 0.00000 -29.74549 -0.00000 -29.74549 0
Answer: after 6058km at longitude 29.7W. When will it cross the date line, longitude 180E? Here we need to use -R because there a closer intersection on the prime meridian:
echo 50N 4W 147.7W 0 180 0 | IntersectTool -c -p 0 -C -R 2.6e7 -494582 14052230 0 14546812 53.69260 0.00000 53.69260 0.00000 0 19529110 -5932344 0 25461454 -53.51867 180.00000 -53.51867 180.00000 0 nan nan 0 nan nan nan nan nan nan
We want the second result: after 19529 km at latitude 53.5S.
GeoConvert(1), GeodSolve(1).
This solution for intersections is described in C. F. F. Karney, Geodesic intersections, Technical Report, SRI International (2023); URL: <https://arxiv.org/abs/yymm.nnnnn>. It is based on the work of S. Baseldga and J. C. Martinez-Llario, Intersection and point-to-line solutions for geodesics on the ellipsoid, Stud. Geophys. Geod. 62, 353-363 (2018); DOI: <https://doi.org/10.1007/s11200-017-1020-z>;
IntersectTool was written by Charles Karney.
IntersectTool was added to GeographicLib, <https://geographiclib.sourceforge.io>, in version 2.3.
2023-07-25 | GeographicLib 2.3 |