From: ehofman Date: Tue, 25 Oct 2005 08:57:33 +0000 (+0000) Subject: Vassilii Khachaturov: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6985804e950bd33476e6f4edca28234e6aeaeb67;p=flightgear.git Vassilii Khachaturov: this patch eliminates some cut-and-paste, as well as makes some frequently used strings const static at the same time. A couple of interfaces are decorated with 'const' on the parameters that are such, in line with other such interfaces where const is used. "NINE" changed to "NINER", to match ICAO practice and the current FGFS voice data. A fixed buffer, sprintf and a warning comment replaced w/ostringstream. Alex Romosan: +string ConvertRwyNumToSpokenString(const string s) { this should be string ConvertRwyNumToSpokenString(const string& s) so we don't make unnecessary copies. --- diff --git a/src/ATC/ATCutils.cxx b/src/ATC/ATCutils.cxx index 88657ca31..0b51b550f 100644 --- a/src/ATC/ATCutils.cxx +++ b/src/ATC/ATCutils.cxx @@ -22,6 +22,8 @@ # include #endif +#include + #include #include #include @@ -36,11 +38,12 @@ #include "ATCutils.hxx" #include "ATCProjection.hxx" +static const string nums[10] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "niner"}; + // Convert any number to spoken digits -string ConvertNumToSpokenDigits(string n) { +string ConvertNumToSpokenDigits(const string &n) { //cout << "n = " << n << endl; - string nums[10] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}; - string pt = "decimal"; + static const string pt = "decimal"; string str = ""; for(unsigned int i=0; i26 string GetPhoneticIdent(int i); @@ -72,7 +72,7 @@ string GetCompassDirection(double h); ********************************/ // Given two positions (lat & lon in degrees), get the HORIZONTAL separation (in meters) -double dclGetHorizontalSeparation(Point3D pos1, Point3D pos2); +double dclGetHorizontalSeparation(const Point3D pos1, const Point3D pos2); // Given a point and a line, get the HORIZONTAL shortest distance from the point to a point on the line. // Expects to be fed orthogonal co-ordinates, NOT lat & lon ! @@ -80,10 +80,10 @@ double dclGetLinePointSeparation(double px, double py, double x1, double y1, dou // Given a position (lat/lon/elev), heading, vertical angle, and distance, calculate the new position. // Assumes that the ground is not hit!!! Expects heading and angle in degrees, distance in meters. -Point3D dclUpdatePosition(Point3D pos, double heading, double angle, double distance); +Point3D dclUpdatePosition(const Point3D pos, double heading, double angle, double distance); // Get a heading from one lat/lon to another (in degrees) -double GetHeadingFromTo(Point3D A, Point3D B); +double GetHeadingFromTo(const Point3D A, const Point3D B); // Given a heading (in degrees), bound it from 0 -> 360 void dclBoundHeading(double &hdg); @@ -118,5 +118,5 @@ Point3D dclGetAirportPos( const string& id ); ****************/ // Given a Point3D (lon/lat/elev) and an FGRunway struct, determine if the point lies on the runway -bool OnRunway(Point3D pt, const FGRunway& rwy); +bool OnRunway(const Point3D pt, const FGRunway& rwy);