From: curt Date: Tue, 27 May 2003 18:59:14 +0000 (+0000) Subject: Add a utility that given a specific localizer position and corresponding X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=c538cc44fd441b27beb644dc3530b3e913f2d328;p=flightgear.git Add a utility that given a specific localizer position and corresponding runway info, repositions the localizer and realigns it with the runway heading so that the approach lines up perfectly. --- diff --git a/src/Airports/Makefile.am b/src/Airports/Makefile.am index 2ac70f3b8..4435e5888 100644 --- a/src/Airports/Makefile.am +++ b/src/Airports/Makefile.am @@ -1,6 +1,6 @@ noinst_LIBRARIES = libAirports.a -noinst_PROGRAMS = gensimple genrunways +noinst_PROGRAMS = gensimple genrunways calc_loc libAirports_a_SOURCES = \ runways.cxx runways.hxx \ @@ -12,4 +12,7 @@ gensimple_LDADD = libAirports.a -lsgdebug -lsgmisc -lsgxml -lmk4 -lz genrunways_SOURCES = genrunways.cxx genrunways_LDADD = libAirports.a -lsgdebug -lsgmisc -lsgxml -lmk4 -lz +calc_loc_SOURCES = calc_loc.cxx +calc_loc_LDADD = -lsgmath + INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src diff --git a/src/Airports/calc_loc.cxx b/src/Airports/calc_loc.cxx new file mode 100644 index 000000000..fe709c3d4 --- /dev/null +++ b/src/Airports/calc_loc.cxx @@ -0,0 +1,61 @@ +// Calculate ILS heading + +#include + +#include +#include + +#include +#include STL_STRING + +#include + +#include + + +SG_USING_STD(string); +SG_USING_STD(cout); +SG_USING_STD(endl); + +int main( int argc, char **argv ) { + + if ( argc != 9 ) { + cout << "Wrong usage" << endl; + } + + double loc_lat = atof( argv[1] ); + double loc_lon = atof( argv[2] ); + string dir = argv[3]; + double rwy_lat = atof( argv[4] ); + double rwy_lon = atof( argv[5] ); + double rwy_hdg = atof( argv[6] ); + double rwy_len = atof( argv[7] ) * SG_DEGREES_TO_RADIANS; + double rwy_wid = atof( argv[8] ); + + if ( dir == "FOR" ) { + rwy_hdg += 180.0; + if ( rwy_hdg > 360.0 ) { + rwy_hdg -= 360.0; + } + } + + // calculate runway threshold point + double thresh_lat, thresh_lon, return_az; + geo_direct_wgs_84 ( 0.0, rwy_lat, rwy_lon, rwy_hdg, + rwy_len / 2.0, &thresh_lat, &thresh_lon, &return_az ); + cout << "Threshold = " << thresh_lat << "," << thresh_lon << endl; + + // calculate distance from threshold to localizer + double az1, az2, dist_m; + geo_inverse_wgs_84( 0.0, loc_lat, loc_lon, thresh_lat, thresh_lon, + &az1, &az2, &dist_m ); + cout << "Distance = " << dist_m << endl; + + // back project that distance along the runway center line + double nloc_lat, nloc_lon; + geo_direct_wgs_84 ( 0.0, thresh_lat, thresh_lon, rwy_hdg + 180.0, + dist_m, &nloc_lat, &nloc_lon, &return_az ); + printf("New localizer = %.6f %.6f\n", nloc_lat, nloc_lon ); + + return 0; +}