Can't translate from Delphi to C#

0 like 0 dislike
13 views
I would be very grateful if you help translate!
var
// Transmitted latitude/longitude in degrees and hundredths
StartLat: double; // Initial latitude
StartLong: double; // Initial longitude
EndLat: double; // End latitude
EndLong: double; // End longitude

// Variables used to calculate the displacement and distance
fPhimean: Double; // mean latitude
fdLambda: Double; // the difference between the two longitudes
fdPhi: Double; // Difference between the two values of latitude
fAlpha: Double; // Offset
fRho: Double; // the Meridian radius of curvature
fNu: Double; // Transverse radius of curvature
fR: Double; // Radius of the sphere of the Earth
fz: Double; // Angular distance from center of spheroid
fTemp: Double; // Temporary variable used in calculations
Distance: Double; // Calculated distance in meters
Bearing: Double; // Calculated from and to the offset
end

const
// Constants used to calculate the displacement and distance
D2R: Double = 0.017453; // Constant to convert degrees to radians
R2D: Double = 57.295781; // Constant to convert radians to degrees
a: Double = 6378137.0; // Major semi-axis
b: Double = 6356752.314245; // Minor semiaxis
e2: Double = 0.006739496742337; // Square of eccentricity of ellipsoid
f: Double = 0.003352810664747; // the alignment of the ellipsoid

begin
// Calculate the difference between two longitudes and latitudes and we get the average latitude
fdLambda := (StartLong - EndLong) * D2R;
fdPhi := (StartLat - EndLat) * D2R;
fPhimean := ((StartLat + EndLat) / 2.0) * D2R;

// Calculate the meridional and transverse radius of curvature of the middle latitude
fTemp := 1 - e2 * (Power(Sin(fPhimean), 2));
fRho := (a * (1 - e2)) / Power(fTemp, 1.5);
fNu := a / (Sqrt(1 - e2 * (Sin(fPhimean) * Sin(fPhimean))));

// Calculate the angular distance
fz :=
Sqrt(Power(Sin(fdPhi / 2.0), 2) + Cos(EndLat * D2R) * Cos(StartLat * D2R) *
Power(Sin(fdLambda / 2.0), 2));

fz := 2 * ArcSin(fz);

// Calculate the offset
fAlpha := Cos(EndLat * D2R) * Sin(fdLambda) * 1 / Sin(fz);
fAlpha := ArcSin(fAlpha);
// Calculate the radius of the Earth
fR := (fRho * fNu) / ((fRho * Power(Sin(fAlpha), 2)) + (fNu *
Power(Cos(fAlpha), 2)));

// Get the offset and the distance
Distance := (fz * fR);
if ((StartLat < EndLat) and (StartLong < EndLong)) then
Bearing := Abs(fAlpha * R2D)
else if ((StartLat < EndLat) and (StartLong > EndLong)) then
Bearing := 360 - Abs(fAlpha * R2D)
else if ((StartLat > EndLat) and (StartLong > EndLong)) then
Bearing := 180 + Abs(fAlpha * R2D)
else if ((StartLat > EndLat) and (StartLong < EndLong)) then
Bearing := 180 - Abs(fAlpha * R2D);
end;
by | 13 views

2 Answers

0 like 0 dislike
Here is the solution: freelansim.ru
by
0 like 0 dislike
by

Related questions

0 like 0 dislike
2 answers
asked Apr 1, 2019 by Egorh
0 like 0 dislike
5 answers
0 like 0 dislike
5 answers
0 like 0 dislike
3 answers
asked Mar 21, 2019 by unreturned
110,608 questions
257,186 answers
0 comments
28,731 users