.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "INTERSECTTOOL 1" .TH INTERSECTTOOL 1 2023-07-25 "GeographicLib 2.3" "GeographicLib Utilities" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME IntersectTool \-\- perform rhumb line calculations .SH SYNOPSIS .IX Header "SYNOPSIS" \&\fBIntersectTool\fR [ \fB\-c\fR | \fB\-n\fR | \fB\-i\fR | \fB\-o\fR | [ \fB\-R\fR \fImaxdist\fR ] [ \fB\-e\fR \fIa\fR \fIf\fR] [ \fB\-E\fR ] [ \fB\-w\fR ] [ \fB\-p\fR \fIprec\fR ] [ \fB\-\-comment\-delimiter\fR \fIcommentdelim\fR ] [ \fB\-\-version\fR | \fB\-h\fR | \fB\-\-help\fR ] [ \fB\-\-input\-file\fR \fIinfile\fR | \fB\-\-input\-string\fR \fIinstring\fR ] [ \fB\-\-line\-separator\fR \fIlinesep\fR ] [ \fB\-\-output\-file\fR \fIoutfile\fR ] .SH DESCRIPTION .IX Header "DESCRIPTION" \&\fBIntersectTool\fR finds the intersection of two geodesics \fIX\fR and \&\fIY\fR. The geodesics may either be specified as a location and an azimuth, \fIlatX\fR \fIlonX\fR \fIaziX\fR, or as the shortest geodesic segment between two locations, \fIlatX1\fR \fIlonX1\fR and \fIlatX2\fR \fIlonX2\fR. The intersection is then specified as the displacements, \fIx\fR and \fIy\fR, along the geodesics \fIX\fR and \fIY\fR from the starting points to the intersection. In the case of the intersection of geodesic segments, the starting point is first point specified for \fIX\fR or \fIY\fR. .PP Usually this tool returns the \fIclosest\fR intersection defined as the one that minimizes the "L1" distance, |\fIx\fR| + |\fIy\fR|. However, it is possible to specify an "origin" \fIx0\fR and \fIy0\fR when determining closeness so that the intersection which minimizes |\fIx\fR \- \fIx0\fR| + |\fIy\fR \- \fIy0\fR| is returned. .PP In the case of intersecting segments the origin is taken to be the midpoints of the segments; \fIx0\fR is half the distance from \fIX1\fR to \&\fIX2\fR. In addition a flag is returned specifying whether the intersection is "within" the segments. .PP The tool also returns a "coincidence indicator" \fIc\fR. This is typically 0. However if the geodesics lie on top of one another at the point of intersection, then \fIc\fR is set to 1, if they are parallel, and \-1, if they are antiparallel. .PP \&\fBIntersectTool\fR operates in one of three modes: .IP 1. 4 With the \fB\-c\fR option (the default), \fBIntersectTool\fR accepts lines on the standard input containing \fIlatX\fR \fIlonX\fR \fIaziX\fR \fIlatY\fR \fIlonY\fR \&\fIaziY\fR, specifying two geodesic lines \fIX\fR and \fIY\fR, and prints the location of the closest intersection \fIx\fR \fIy\fR \fIc\fR on standard output. .IP 2. 4 With the \fB\-n\fR option, \fBIntersectTool\fR accepts lines on the standard input containing \fIlatX\fR \fIlonX\fR \fIaziX\fR \fIaziY\fR \fIaziY\fR, specifying a point where two geodesic lines \fIX\fR and \fIY\fR intersect, and prints the location of the next closest intersection \fIx\fR \fIy\fR \fIc\fR on standard output. .IP 3. 4 With the \fB\-i\fR option, \fBIntersectTool\fR accepts lines on the standard input containing \fIlatX1\fR \fIlonX1\fR \fIlatX2\fR \fIlonX2\fR \fIlatY1\fR \fIlonY1\fR \&\fIlatY2\fR \fIlonY2\fR, specifying two geodesic segments \fIX1\fR\-\fIX2\fR and \&\fIY1\fR\-\fIY2\fR, and prints \fIx\fR \fIy\fR \fIc\fR \fIk\fR on standard output. Here \&\fIk\fR is a flag in [\-4,4] specifying whether the intersection is within the segments (0) or not (non-zero). \fIx\fR and \fIy\fR give the distances from \fIX1\fR and \fIY1\fR respectively. \fIk\fR is set to 3 \fIkx\fR + \fIky\fR where \fIkx\fR = \-1 if \fIx\fR < 0, 0 if 0 <= \fIx\fR <= \fIsx\fR, 1 if \fIsx\fR < \&\fIx\fR, and similarly for \fIky\fR; \fIsx\fR is the length of the segment \&\fIX1\fR\-\fIX2\fR. .IP 4. 4 With the \fB\-o\fR option, \fBIntersectTool\fR accepts lines on the standard input containing \fIlatX\fR \fIlonX\fR \fIaziX\fR \fIlatY\fR \fIlonY\fR \fIaziY\fR \fIx0\fR \&\fIy0\fR, specifying two geodesic lines \fIX\fR and \fIY\fR and two offsets, and prints \fIx\fR \fIy\fR \fIc\fR on standard output where [\fIx\fR, \fIy\fR] is the intersection closest to [\fIx0\fR, \fIy0\fR]. .SH OPTIONS .IX Header "OPTIONS" .IP \fB\-c\fR 4 .IX Item "-c" find the closest intersection (see 1 above). .IP \fB\-n\fR 4 .IX Item "-n" find the intersection closest to a given intersection (see 2 above). .IP \fB\-i\fR 4 .IX Item "-i" find the intersection of two geodesic segments (see 3 above). .IP \fB\-o\fR 4 .IX Item "-o" find the closest intersection with an offset. .IP "\fB\-R\fR \fImaxdist\fR" 4 .IX Item "-R maxdist" modifies the four modes to return all the intersections within an L1 distance, \fImaxdist\fR, of the relevant origin: [0, 0] for \fB\-c\fR and \&\fB\-n\fR, the midpoints of the segments for \fB\-i\fR, and [\fIx0\fR, \fIy0\fR] for \&\fB\-o\fR. For each intersection, \fIx\fR \fIy\fR \fIc\fR \fIz\fR is printed on standard output. Here \fIz\fR is the L1 distance of the intersection from the origin and the intersections are sorted by the distances. A line "nan nan 0 nan" is added after the intersections, so that the output can be associated with the correct lines of the input. The number of intersections scales as (\fImaxdist\fR/(pi \fIa\fR))^2. .IP \fB\-C\fR 4 .IX Item "-C" check the intersections. For each computed intersection, print on \&\fBstandard error\fR a line \fIlatX\fR \fIlonX\fR \fIlatY\fR \fIlonY\fR \fIsXY\fR giving the computed positions of the intersections points on \fIX\fR and \fIY\fR and the distance between them. If \fB\-w\fR is specified, the longitude is given before the latitude. .IP "\fB\-e\fR \fIa\fR \fIf\fR" 4 .IX Item "-e a f" specify the ellipsoid via the equatorial radius, \fIa\fR and the flattening, \fIf\fR. Setting \fIf\fR = 0 results in a sphere. Specify \&\fIf\fR < 0 for a prolate ellipsoid. A simple fraction, e.g., 1/297, is allowed for \fIf\fR. By default, the WGS84 ellipsoid is used, \fIa\fR = 6378137 m, \fIf\fR = 1/298.257223563. .IP \fB\-E\fR 4 .IX Item "-E" use "exact" algorithms (based on elliptic integrals) for the geodesic calculations. These are more accurate than the (default) series expansions for |\fIf\fR| > 0.02. .IP \fB\-w\fR 4 .IX Item "-w" on input, longitude precedes latitude (except that on input this can be overridden by a hemisphere designator, \fIN\fR, \fIS\fR, \fIE\fR, \fIW\fR). .IP "\fB\-p\fR \fIprec\fR" 4 .IX Item "-p prec" set the output precision to \fIprec\fR (default 3); \fIprec\fR is the precision relative to 1 m. See "PRECISION". .IP "\fB\-\-comment\-delimiter\fR \fIcommentdelim\fR" 4 .IX Item "--comment-delimiter commentdelim" set the comment delimiter to \fIcommentdelim\fR (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). .IP \fB\-\-version\fR 4 .IX Item "--version" print version and exit. .IP \fB\-h\fR 4 .IX Item "-h" print usage and exit. .IP \fB\-\-help\fR 4 .IX Item "--help" print full documentation and exit. .IP "\fB\-\-input\-file\fR \fIinfile\fR" 4 .IX Item "--input-file infile" read input from the file \fIinfile\fR instead of from standard input; a file name of "\-" stands for standard input. .IP "\fB\-\-input\-string\fR \fIinstring\fR" 4 .IX Item "--input-string instring" read input from the string \fIinstring\fR instead of from standard input. All occurrences of the line separator character (default is a semicolon) in \fIinstring\fR are converted to newlines before the reading begins. .IP "\fB\-\-line\-separator\fR \fIlinesep\fR" 4 .IX Item "--line-separator linesep" set the line separator character to \fIlinesep\fR. By default this is a semicolon. .IP "\fB\-\-output\-file\fR \fIoutfile\fR" 4 .IX Item "--output-file outfile" write output to the file \fIoutfile\fR instead of to standard output; a file name of "\-" stands for standard output. .SH INPUT .IX Header "INPUT" \&\fBIntersectTool\fR 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, \f(CW\*(C`40d30\*(C'\fR, \&\f(CW\*(C`40d30\*(Aq\*(C'\fR, \f(CW\*(C`40:30\*(C'\fR, \f(CW\*(C`40.5d\*(C'\fR, and \f(CW40.5\fR are all equivalent. By default, latitude precedes longitude for each point (the \fB\-w\fR flag switches this convention); however either may be given first by appending (or prepending) \fIN\fR or \fIS\fR to the latitude and \fIE\fR or \&\fIW\fR to the longitude. Azimuths are measured clockwise from north; however this may be overridden with \fIE\fR or \fIW\fR. .PP For details on the allowed formats for angles, see the \f(CW\*(C`GEOGRAPHIC COORDINATES\*(C'\fR section of \fBGeoConvert\fR\|(1). .SH PRECISION .IX Header "PRECISION" \&\fIprec\fR gives precision of the output with \fIprec\fR = 0 giving 1 m precision, \fIprec\fR = 3 giving 1 mm precision, etc. \fIprec\fR is the number of digits after the decimal point for lengths. The latitude and longitude printed to standard error with the \fB\-C\fR option are given in decimal degrees with \fIprec\fR + 5 digits after the decimal point. The minimum value of \fIprec\fR is 0 and the maximum is 10. .SH ERRORS .IX Header "ERRORS" An illegal line of input will print an error message to standard output beginning with \f(CW\*(C`ERROR:\*(C'\fR and causes \fBIntersectTool\fR to return an exit code of 1. However, an error does not cause \fBIntersectTool\fR to terminate; following lines will be converted. .SH ACCURACY .IX Header "ACCURACY" This tool will give nearly full double precision accuracy for |\fIf\fR| < 0.02. If the \fB\-E\fR option is given, full accuracy is achieved for \-1/4 < f < 1/5. The tool had not been tested outside this range. .SH EXAMPLES .IX Header "EXAMPLES" A vessel leaves Plymouth 50N 4W on a geodesic path with initial heading 147.7W. When will it first cross the equator? .PP .Vb 1 \& 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 .Ve .PP Answer: after 6058km at longitude 29.7W. When will it cross the date line, longitude 180E? Here we need to use \fB\-R\fR because there a closer intersection on the prime meridian: .PP .Vb 1 \& 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 .Ve .PP We want the second result: after 19529 km at latitude 53.5S. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBGeoConvert\fR\|(1), \fBGeodSolve\fR\|(1). .PP This solution for intersections is described in C. F. F. Karney, \&\fIGeodesic intersections\fR, Technical Report, SRI International (2023); URL: . It is based on the work of S. Baseldga and J. C. Martinez-Llario, \fIIntersection and point-to-line solutions for geodesics on the ellipsoid\fR, Stud. Geophys. Geod. 62, 353\-363 (2018); DOI: ; .SH AUTHOR .IX Header "AUTHOR" \&\fBIntersectTool\fR was written by Charles Karney. .SH HISTORY .IX Header "HISTORY" \&\fBIntersectTool\fR was added to GeographicLib, , in version 2.3.