/// <summary> ///get the distance between two coordinates/// </summary> /// <param name= "LAT1" >The X of the first coordinate</param> /// <param name= "Lng1" >y of the first coordinate</param> /// <param name= "LAT2" >The X of the second coordinate</param> /// <param name= "Lng2" >y of the second coordinate</param> /// <returns>the distance between two coordinates</returns> Public Static DoubleGetdistance (DoubleLAT1,DoubleLng1,DoubleLAT2,Doublelng2) { Try { varb = Math.PI/ the; varc = Math.sin ((LAT2-LAT1) * b/2); varD = Math.sin ((lng2-lng1) * b/2); varA = c * C + d * d * MATH.COS (LAT1 * b) * Math.Cos (LAT2 *b); return 12756274* MATH.ATAN2 (Math.sqrt (a), math.sqrt (1-a)); } Catch(Exception) {return 0; } }
The above code is stripped from the inside of the German JS.
C # Calculates the distance between two Mars coordinates (gold or Baidu)