Files
qt6-migration-pipeline/external/GeographicLib/share/doc/GeographicLib-dev/example-Intersect.cpp
T
torsten 77c67c12ca Execute the same instructions but now for tools in folders you are getti
Entire-Metadata: .entire/metadata/fb87247f-2a75-407e-b336-cbc8c20ba5a6
Entire-Session: fb87247f-2a75-407e-b336-cbc8c20ba5a6
Entire-Strategy: manual-commit
2026-09-24 16:24:51 +00:00

34 lines
1.1 KiB
C++

// Example of using the GeographicLib::Intersect class
#include <iostream>
#include <exception>
#include <GeographicLib/Intersect.hpp>
#include <GeographicLib/Constants.hpp>
using namespace std;
using namespace GeographicLib;
int main() {
try {
Geodesic geod(Constants::WGS84_a(), Constants::WGS84_f());
Intersect intersect(geod);
// Define the two geodesics
GeodesicLine lineX(geod, 0, 0, 45, Intersect::LineCaps);
GeodesicLine lineY(geod, 45, 10, 135, Intersect::LineCaps);
// Find displacement to closest intersection
Intersect::Point point = intersect.Closest(lineX, lineY);
// Check position at intersection
double latx, lonx, laty, lony;
lineX.Position(point.first, latx, lonx);
lineY.Position(point.second, laty, lony);
cout << "X intersection displacement + position "
<< point.first << " " << latx << " " << lonx << "\n";
cout << "Y intersection displacement + position "
<< point.second << " " << laty << " " << lony << "\n";
}
catch (const exception& e) {
cerr << "Caught exception: " << e.what() << "\n";
return 1;
}
}