diff --git a/src/Airports/GenAirports850/object.cxx b/src/Airports/GenAirports850/object.cxx index 4715dabc..a89085ac 100644 --- a/src/Airports/GenAirports850/object.cxx +++ b/src/Airports/GenAirports850/object.cxx @@ -1,4 +1,4 @@ -#include +#include #include #include "object.hxx" @@ -17,25 +17,18 @@ void LightingObj::BuildBtg( superpoly_list* lights ) double left_hdg = heading - 90.0; if ( left_hdg < 0 ) { left_hdg += 360.0; } - Point3D ref(lon, lat, 0.0); + SGGeod ref = SGGeod::fromDeg(lon, lat); - // Calculate the normal direction once for all objects. + // Calculate the light normal with the help of a second point + // in the object heading direction. // SimGear takes care of the glideslope angle calculation from the normal + SGVec3d cart1 = SGVec3d::fromGeod(SGGeodesy::direct( ref, heading, 10)); + SGVec3d cart2 = SGVec3d::fromGeod(ref); - // calculate a second point in the object heading direction - double lon2 = 0, lat2 = 0, r; - geo_direct_wgs_84 ( lat, lon, heading, - 10, &lat2, &lon2, &r); - - Point3D cart1 = sgGeodToCart( Point3D(lon2, lat2, 0.0) * SG_DEGREES_TO_RADIANS ); - Point3D cart2 = sgGeodToCart( ref * SG_DEGREES_TO_RADIANS ); - - Point3D normal = cart2 - cart1; - double length = normal.distance3D( Point3D(0.0) ); - normal = normal / length; + Point3D normal = Point3D::fromSGVec3(normalize(cart2 - cart1)); // We know our normal, now create the lights - Point3D pt1; + SGGeod pt1; if (type == 1) { @@ -45,46 +38,34 @@ void LightingObj::BuildBtg( superpoly_list* lights ) // Space between the bars is 200m // Go to downwind bar - geo_direct_wgs_84 ( ref.lat(), ref.lon(), heading, - -100, &lat2, &lon2, &r ); - pt1 = Point3D( lon2, lat2, 0.0 ); + pt1 = SGGeodesy::direct( ref, heading, -100 ); // unit1 - geo_direct_wgs_84 ( pt1.lat(), pt1.lon(), left_hdg, - -5, &lat2, &lon2, &r ); - pt1 = Point3D( lon2, lat2, 0.0 ); - lightobj.push_back( pt1 ); + pt1 = SGGeodesy::direct( pt1, left_hdg, -5 ); + lightobj.push_back( Point3D::fromSGGeod(pt1) ); normals.push_back( normal ); // unit2+3 for (int i = 0; i < 2; ++i) { - geo_direct_wgs_84 ( pt1.lat(), pt1.lon(), left_hdg, - 5, &lat2, &lon2, &r ); - pt1 = Point3D( lon2, lat2, 0.0 ); - lightobj.push_back( pt1 ); + pt1 = SGGeodesy::direct( pt1, left_hdg, 5 ); + lightobj.push_back( Point3D::fromSGGeod(pt1) ); normals.push_back( normal ); } // Go to upwind bar - geo_direct_wgs_84 ( ref.lat(), ref.lon(), heading, - 100, &lat2, &lon2, &r ); - pt1 = Point3D( lon2, lat2, 0.0 ); + pt1 = SGGeodesy::direct( ref, heading, 100 ); // unit4 - geo_direct_wgs_84 ( pt1.lat(), pt1.lon(), left_hdg, - -5, &lat2, &lon2, &r ); - pt1 = Point3D( lon2, lat2, 0.0 ); - lightobj.push_back( pt1 ); + pt1 = SGGeodesy::direct( pt1, left_hdg, -5 ); + lightobj.push_back( Point3D::fromSGGeod(pt1) ); normals.push_back( normal ); // unit5+6 for (int i = 0; i < 2; ++i) { - geo_direct_wgs_84 ( pt1.lat(), pt1.lon(), left_hdg, - 5, &lat2, &lon2, &r ); - pt1 = Point3D( lon2, lat2, 0.0 ); - lightobj.push_back( pt1 ); + pt1 = SGGeodesy::direct( pt1, left_hdg,5 ); + lightobj.push_back( Point3D::fromSGGeod(pt1) ); normals.push_back( normal ); } } @@ -93,19 +74,15 @@ void LightingObj::BuildBtg( superpoly_list* lights ) SG_LOG(SG_GENERAL, SG_DEBUG, "Generating PAPI 4L = " << assoc_rw); // unit1 - geo_direct_wgs_84 ( ref.lat(), ref.lon(), left_hdg, - -12, &lat2, &lon2, &r ); - pt1 = Point3D( lon2, lat2, 0.0 ); - lightobj.push_back( pt1 ); + pt1 = SGGeodesy::direct( ref, left_hdg, -12 ); + lightobj.push_back( Point3D::fromSGGeod(pt1) ); normals.push_back( normal ); // unit2-4 for (int i = 0; i < 3; ++i) { - geo_direct_wgs_84 ( pt1.lat(), pt1.lon(), left_hdg, - 8, &lat2, &lon2, &r ); - pt1 = Point3D( lon2, lat2, 0.0 ); - lightobj.push_back( pt1 ); + pt1 = SGGeodesy::direct( pt1, left_hdg, 8 ); + lightobj.push_back( Point3D::fromSGGeod(pt1) ); normals.push_back( normal ); } } @@ -114,19 +91,15 @@ void LightingObj::BuildBtg( superpoly_list* lights ) SG_LOG(SG_GENERAL, SG_DEBUG, "Generating PAPI 4R = " << assoc_rw); // unit1 - geo_direct_wgs_84 ( ref.lat(), ref.lon(), left_hdg, - 12, &lat2, &lon2, &r ); - pt1 = Point3D( lon2, lat2, 0.0 ); - lightobj.push_back( pt1 ); + pt1 = SGGeodesy::direct( ref, left_hdg, 12 ); + lightobj.push_back( Point3D::fromSGGeod(pt1) ); normals.push_back( normal ); // unit2-4 for (int i = 0; i < 3; ++i) { - geo_direct_wgs_84 ( pt1.lat(), pt1.lon(), left_hdg, - -8, &lat2, &lon2, &r ); - pt1 = Point3D( lon2, lat2, 0.0 ); - lightobj.push_back( pt1 ); + pt1 = SGGeodesy::direct( pt1, left_hdg, -8 ); + lightobj.push_back( Point3D::fromSGGeod(pt1) ); normals.push_back( normal ); } } @@ -139,7 +112,7 @@ void LightingObj::BuildBtg( superpoly_list* lights ) SG_LOG(SG_GENERAL, SG_DEBUG, "Generating tri-colour VASI = " << assoc_rw); // only one light here - lightobj.push_back( ref ); + lightobj.push_back( Point3D::fromSGGeod(ref) ); normals.push_back( normal ); } else