File: IntersectTool.1

package info (click to toggle)
geographiclib 2.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 7,596 kB
  • sloc: cpp: 27,762; sh: 5,463; makefile: 695; python: 12; ansic: 10
file content (300 lines) | stat: -rw-r--r-- 12,850 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
.\" -*- mode: troff; coding: utf-8 -*-
.\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45)
.\"
.\" 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
.\"
.\" Required to disable full justification in groff 1.23.0.
.if n .ds AD l
.\" ========================================================================
.\"
.IX Title "INTERSECTTOOL 1"
.TH INTERSECTTOOL 1 2025-09-30 "GeographicLib 2.6" "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 \-\- find the intersection of geodesics
.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, J. Surveying Eng. \fB150\fR(3), 04024005:1\-9
(2024), DOI: <https://doi.org/10.1061/JSUED2.SUENG\-1483>; preprint
<https://arxiv.org/abs/2308.00495>.  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. \fB62\fR, 353\-363 (2018); DOI:
<https://doi.org/10.1007/s11200\-017\-1020\-z>;
.SH AUTHOR
.IX Header "AUTHOR"
\&\fBIntersectTool\fR was written by Charles Karney.
.SH HISTORY
.IX Header "HISTORY"
\&\fBIntersectTool\fR was added to GeographicLib,
<https://geographiclib.sourceforge.io>, in version 2.3.