IOS calculates the distance between two by longitude and latitude

From , 3 Years ago, written in Objective-C, viewed 221 times.
URL https://pastebin.vip/view/50e207ab
  1. +(double)distanceBetweenOrderBy:(double)lat1 :(double)lat2 :(double)lng1 :(double)lng2{
  2.     double dd = M_PI/180;
  3.     double x1=lat1*dd,x2=lat2*dd;
  4.     double y1=lng1*dd,y2=lng2*dd;
  5.     double R = 6371004;
  6.     double distance = (2*R*asin(sqrt(2-2*cos(x1)*cos(x2)*cos(y1-y2) - 2*sin(x1)*sin(x2))/2));
  7.     //km  返回
  8.     //     return  distance*1000;
  9.      
  10.     //返回 m
  11.     return   distance;
  12.  
  13. }
  14. //objectc/5842

Reply to "IOS calculates the distance between two by longitude and latitude"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website