"Go" C # calculates two coordinate point distance

Source: Internet
Author: User

      //radius of the earth, per metre       Private Const DoubleEarth_radius =6378137; /// <summary>       ///calculates the distance from the two-point position, returns the distance of two points, per meter///This formula is available to Google with an error of less than 0.2 meters/// </summary>       /// <param name= "LAT1" >1th Latitude</param>       /// <param name= "Lng1" >1th Longitude</param>       /// <param name= "LAT2" >2nd Latitude</param>       /// <param name= "Lng2" >2nd Longitude</param>       /// <returns></returns>        Public Static DoubleGetdistance (DoubleLAT1,DoubleLng1,DoubleLAT2,Doublelng2) {           DoubleRADLAT1 =Rad (LAT1); DoubleRadLng1 =Rad (LNG1); DoubleRADLAT2 =Rad (LAT2); DoubleRadLng2 =Rad (LNG2); DoubleA = RADLAT1-RadLat2; Doubleb = radLng1-radLng2; Doubleresult =2* Math.asin (Math.sqrt (Math.pow (Math.sin (A/2),2) + Math.Cos (RADLAT1) * MATH.COS (RADLAT2) * MATH.POW (Math.sin (b/2),2))) *Earth_radius; returnresult; }        /// <summary>       ///longitude and latitude converted into radians/// </summary>       /// <param name= "D" ></param>       /// <returns></returns>       Private Static DoubleRad (Doubled) {return(Double) d * Math.PI/180d; }

"Go" C # calculates two coordinate point distance

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.