GeographicLib 2.5
|
Geodesic intersections More...
#include <GeographicLib/Intersect.hpp>
Public Types | |
typedef std::pair< Math::real, Math::real > | Point |
Public Member Functions | |
Constructor | |
Intersect (const Geodesic &geod) | |
Finding intersections | |
Point | Closest (Math::real latX, Math::real lonX, Math::real aziX, Math::real latY, Math::real lonY, Math::real aziY, const Point &p0=Point(0, 0), int *c=nullptr) const |
Point | Closest (const GeodesicLine &lineX, const GeodesicLine &lineY, const Point &p0=Point(0, 0), int *c=nullptr) const |
Point | Segment (Math::real latX1, Math::real lonX1, Math::real latX2, Math::real lonX2, Math::real latY1, Math::real lonY1, Math::real latY2, Math::real lonY2, int &segmode, int *c=nullptr) const |
Point | Segment (const GeodesicLine &lineX, const GeodesicLine &lineY, int &segmode, int *c=nullptr) const |
Point | Next (Math::real latX, Math::real lonX, Math::real aziX, Math::real aziY, int *c=nullptr) const |
Point | Next (const GeodesicLine &lineX, const GeodesicLine &lineY, int *c=nullptr) const |
Finding all intersections | |
std::vector< Point > | All (Math::real latX, Math::real lonX, Math::real aziX, Math::real latY, Math::real lonY, Math::real aziY, Math::real maxdist, std::vector< int > &c, const Point &p0=Point(0, 0)) const |
std::vector< Point > | All (Math::real latX, Math::real lonX, Math::real aziX, Math::real latY, Math::real lonY, Math::real aziY, Math::real maxdist, const Point &p0=Point(0, 0)) const |
std::vector< Point > | All (const GeodesicLine &lineX, const GeodesicLine &lineY, Math::real maxdist, std::vector< int > &c, const Point &p0=Point(0, 0)) const |
std::vector< Point > | All (const GeodesicLine &lineX, const GeodesicLine &lineY, Math::real maxdist, const Point &p0=Point(0, 0)) const |
Diagnostic counters | |
long long | NumInverse () const |
long long | NumBasic () const |
long long | NumChange () const |
long long | NumCorner () const |
long long | NumOverride () const |
Insepctor function | |
const Geodesic & | GeodesicObject () const |
Static Public Member Functions | |
static Math::real | Dist (const Point &p, const Point &p0=Point(0, 0)) |
Static Public Attributes | |
static const unsigned | LineCaps |
Geodesic intersections
Find the intersections of two geodesics X and Y. Four calling sequences are supported.
In all cases the position of the intersection is given by the signed displacements x and y along the geodesics from the starting point (the first point in the case of a geodesic segment). The closest itersection is defined as the one that minimizes the L1 distance, Intersect::Dist([x, y) = |x| + |y|.
The routines also optionally return 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.
Example of use:
IntersectTool is a command-line utility providing access to the functionality of this class.
This solution for intersections is described in
It is based on the work of
Definition at line 71 of file Intersect.hpp.
typedef std::pair<Math::real, Math::real> GeographicLib::Intersect::Point |
The type used to hold the two displacement along the geodesics. This is just a std::pair with x = first and y = second.
Definition at line 79 of file Intersect.hpp.
GeographicLib::Intersect::Intersect | ( | const Geodesic & | geod | ) |
Constructor for an ellipsoid with
[in] | geod | a Geodesic object. This sets the parameters a and f for the ellipsoid. |
GeographicErr | if the eccentricity of the elliposdoid is too large. |
Definition at line 20 of file Intersect.cpp.
References GeographicLib::Geodesic::Inverse(), and GeographicLib::Math::pi().
Intersect::Point GeographicLib::Intersect::Closest | ( | Math::real | latX, |
Math::real | lonX, | ||
Math::real | aziX, | ||
Math::real | latY, | ||
Math::real | lonY, | ||
Math::real | aziY, | ||
const Point & | p0 = Point(0, 0) , |
||
int * | c = nullptr |
||
) | const |
Find the closest intersection point, with each geodesic specified by position and azimuth.
[in] | latX | latitude of starting point for geodesic X (degrees). |
[in] | lonX | longitude of starting point for geodesic X (degrees). |
[in] | aziX | azimuth at starting point for geodesic X (degrees). |
[in] | latY | latitude of starting point for geodesic Y (degrees). |
[in] | lonY | longitude of starting point for geodesic Y (degrees). |
[in] | aziY | azimuth at starting point for geodesic Y (degrees). |
[in] | p0 | an optional offset for the starting points (meters), default = [0,0]. |
[out] | c | optional pointer to an integer coincidence indicator. |
The returned intersection minimizes Intersect::Dist(p, p0).
Definition at line 55 of file Intersect.cpp.
References Closest(), GeographicLib::Geodesic::Line(), and LineCaps.
Intersect::Point GeographicLib::Intersect::Closest | ( | const GeodesicLine & | lineX, |
const GeodesicLine & | lineY, | ||
const Point & | p0 = Point(0, 0) , |
||
int * | c = nullptr |
||
) | const |
Find the closest intersection point, with each geodesic given as a GeodesicLine.
[in] | lineX | geodesic X. |
[in] | lineY | geodesic Y. |
[in] | p0 | an optional offset for the starting points (meters), default = [0,0]. |
[out] | c | optional pointer to an integer coincidence indicator. |
The returned intersection minimizes Intersect::Dist(p, p0).
Definition at line 64 of file Intersect.cpp.
Intersect::Point GeographicLib::Intersect::Segment | ( | Math::real | latX1, |
Math::real | lonX1, | ||
Math::real | latX2, | ||
Math::real | lonX2, | ||
Math::real | latY1, | ||
Math::real | lonY1, | ||
Math::real | latY2, | ||
Math::real | lonY2, | ||
int & | segmode, | ||
int * | c = nullptr |
||
) | const |
Find the intersection of two geodesic segments defined by their endpoints.
[in] | latX1 | latitude of first point for segment X (degrees). |
[in] | lonX1 | longitude of first point for segment X (degrees). |
[in] | latX2 | latitude of second point for segment X (degrees). |
[in] | lonX2 | longitude of second point for segment X (degrees). |
[in] | latY1 | latitude of first point for segment Y (degrees). |
[in] | lonY1 | longitude of first point for segment Y (degrees). |
[in] | latY2 | latitude of second point for segment Y (degrees). |
[in] | lonY2 | longitude of second point for segment Y (degrees). |
[out] | segmode | an indicator equal to zero if the segments intersect (see below). |
[out] | c | optional pointer to an integer coincidence indicator. |
segmode codes up information about the closest intersection in the case where the segments intersect. Let x12 be the length of the segment X and x = p.first, the position of the intersection on segment X. Define
and similarly for segment Y. Then segmode = 3 kx + ky.
Definition at line 72 of file Intersect.cpp.
References GeographicLib::Geodesic::InverseLine(), LineCaps, and Segment().
Intersect::Point GeographicLib::Intersect::Segment | ( | const GeodesicLine & | lineX, |
const GeodesicLine & | lineY, | ||
int & | segmode, | ||
int * | c = nullptr |
||
) | const |
Find the intersection of two geodesic segments each defined by a GeodesicLine.
[in] | lineX | segment X. |
[in] | lineY | segment Y. |
[out] | segmode | an indicator equal to zero if the segments intersect (see below). |
[out] | c | optional pointer to an integer coincidence indicator. |
See previous definition of Intersect::Segment for more information on segmode.
Definition at line 83 of file Intersect.cpp.
Intersect::Point GeographicLib::Intersect::Next | ( | Math::real | latX, |
Math::real | lonX, | ||
Math::real | aziX, | ||
Math::real | aziY, | ||
int * | c = nullptr |
||
) | const |
Find the next closest intersection point to a given intersection, specified by position and two azimuths.
[in] | latX | latitude of starting points for geodesics X and Y (degrees). |
[in] | lonX | longitude of starting points for geodesics X and Y (degrees). |
[in] | aziX | azimuth at starting point for geodesic X (degrees). |
[in] | aziY | azimuth at starting point for geodesic Y (degrees). |
[out] | c | optional pointer to an integer coincidence indicator. |
The returned intersection minimizes Intersect::Dist(p) (excluding p = [0,0]).
Definition at line 91 of file Intersect.cpp.
References GeographicLib::Geodesic::Line(), LineCaps, and Next().
Intersect::Point GeographicLib::Intersect::Next | ( | const GeodesicLine & | lineX, |
const GeodesicLine & | lineY, | ||
int * | c = nullptr |
||
) | const |
Find the next closest intersection point to a given intersection, with each geodesic specified a GeodesicLine.
[in] | lineX | geodesic X. |
[in] | lineY | geodesic Y. |
[out] | c | optional pointer to an integer coincidence indicator. |
Definition at line 98 of file Intersect.cpp.
std::vector< Intersect::Point > GeographicLib::Intersect::All | ( | Math::real | latX, |
Math::real | lonX, | ||
Math::real | aziX, | ||
Math::real | latY, | ||
Math::real | lonY, | ||
Math::real | aziY, | ||
Math::real | maxdist, | ||
std::vector< int > & | c, | ||
const Point & | p0 = Point(0, 0) |
||
) | const |
Find all intersections within a certain distance, with each geodesic specified by position and azimuth.
[in] | latX | latitude of starting point for geodesic X (degrees). |
[in] | lonX | longitude of starting point for geodesic X (degrees). |
[in] | aziX | azimuth at starting point for geodesic X (degrees). |
[in] | latY | latitude of starting point for geodesic Y (degrees). |
[in] | lonY | longitude of starting point for geodesic Y (degrees). |
[in] | aziY | azimuth at starting point for geodesic Y (degrees). |
[in] | maxdist | the maximum distance for the returned intersections (meters). |
[out] | c | vector of coincidences. |
[in] | p0 | an optional offset for the starting points (meters), default = [0,0]. |
Each intersection point satisfies Intersect::Dist(p, p0) ≤ maxdist. The vector of returned intersections is sorted on the distance from p0.
Definition at line 115 of file Intersect.cpp.
References All(), GeographicLib::Geodesic::Line(), and LineCaps.
std::vector< Intersect::Point > GeographicLib::Intersect::All | ( | Math::real | latX, |
Math::real | lonX, | ||
Math::real | aziX, | ||
Math::real | latY, | ||
Math::real | lonY, | ||
Math::real | aziY, | ||
Math::real | maxdist, | ||
const Point & | p0 = Point(0, 0) |
||
) | const |
Find all intersections within a certain distance, with each geodesic specified by position and azimuth. Don't return vector of coincidences.
[in] | latX | latitude of starting point for geodesic X (degrees). |
[in] | lonX | longitude of starting point for geodesic X (degrees). |
[in] | aziX | azimuth at starting point for geodesic X (degrees). |
[in] | latY | latitude of starting point for geodesic Y (degrees). |
[in] | lonY | longitude of starting point for geodesic Y (degrees). |
[in] | aziY | azimuth at starting point for geodesic Y (degrees). |
[in] | maxdist | the maximum distance for the returned intersections (meters). |
[in] | p0 | an optional offset for the starting points (meters), default = [0,0]. |
Each intersection point satisfies Intersect::Dist(p, p0) ≤ maxdist. The vector of returned intersections is sorted on the distance from p0.
Definition at line 106 of file Intersect.cpp.
References All(), GeographicLib::Geodesic::Line(), and LineCaps.
std::vector< Intersect::Point > GeographicLib::Intersect::All | ( | const GeodesicLine & | lineX, |
const GeodesicLine & | lineY, | ||
Math::real | maxdist, | ||
std::vector< int > & | c, | ||
const Point & | p0 = Point(0, 0) |
||
) | const |
Find all intersections within a certain distance, with each geodesic specified by a GeodesicLine.
[in] | lineX | geodesic X. |
[in] | lineY | geodesic Y. |
[in] | maxdist | the maximum distance for the returned intersections (meters). |
[out] | c | vector of coincidences. |
[in] | p0 | an optional offset for the starting points (meters), default = [0,0]. |
Each intersection point satisfies Intersect::Dist(p, p0) ≤ maxdist. The vector of returned intersections is sorted on the distance from p0.
Definition at line 132 of file Intersect.cpp.
std::vector< Intersect::Point > GeographicLib::Intersect::All | ( | const GeodesicLine & | lineX, |
const GeodesicLine & | lineY, | ||
Math::real | maxdist, | ||
const Point & | p0 = Point(0, 0) |
||
) | const |
Find all intersections within a certain distance, with each geodesic specified by a GeodesicLine. Don't return vector or coincidences.
[in] | lineX | geodesic X. |
[in] | lineY | geodesic Y. |
[in] | maxdist | the maximum distance for the returned intersections (meters). |
[in] | p0 | an optional offset for the starting points (meters), default = [0,0]. |
Each intersection point satisfies Intersect::Dist(p, p0) ≤ maxdist. The vector of returned intersections is sorted on the distance from p0.
Definition at line 125 of file Intersect.cpp.
|
inline |
This is a count of the number of times the spherical triangle needs to be solved. Each involves a call to Geodesic::Inverse and this is a good metric for the overall cost. This counter is set to zero by the constructor.
Definition at line 504 of file Intersect.hpp.
|
inline |
This is a count of the number of invocations of the basic algorithm, which is used by all the intersection methods. This counter is set to zero by the constructor.
Definition at line 514 of file Intersect.hpp.
|
inline |
If this counter is incremented by just 1 in Intersect::Closest, then the initial result of the basic algorithm was eventually accepted. This counter is set to zero by the constructor.
Definition at line 528 of file Intersect.hpp.
|
inline |
This counter is set to zero by the constructor.
Definition at line 537 of file Intersect.hpp.
|
inline |
This counter is set to zero by the constructor.
Definition at line 550 of file Intersect.hpp.
|
inline |
This can be used to query Geodesic::EquatorialRadius(), Geodesic::Flattening(), Geodesic::Exact(), and Geodesic::EllipsoidArea().
Definition at line 563 of file Intersect.hpp.
|
inlinestatic |
The L1 distance.
[in] | p | the position along geodesics X and Y. |
[in] | p0 | [optional] the reference position, default = [0, 0]. |
Definition at line 576 of file Intersect.hpp.
Referenced by main().
|
static |
The minimum capabilities for GeodesicLine objects which are passed to this class.
Definition at line 84 of file Intersect.hpp.
Referenced by All(), All(), Closest(), main(), Next(), and Segment().