IOS maps calculate distances between two points via latitude

Source: Internet
Author: User

- (Double) Calculatestart: (cllocationcoordinate2d) Start end: (cllocationcoordinate2d) End {Doublemeter =0; DoubleStartlongitude =Start.longitude; DoubleStartlatitude =Start.latitude; DoubleEndlongitude =End.longitude; DoubleEndlatitude =End.latitude; DoubleRadLatitude1 = Startlatitude * M_pi/180.0; DoubleRadLatitude2 = Endlatitude * M_pi/180.0; DoubleA = Fabs (RadLatitude1-radLatitude2); Doubleb = Fabs (Startlongitude * M_PI/180.0-Endlongitude * M_PI/180.0); Doubles =2* ASIN (SQRT (Pow (sin (2),2) + cos (radLatitude1) * cos (radLatitude2) * POW (sin (b/2),2))); S= S *Earth_radius; Meter= Round (S *10000) /10000;//Return distance unit is m    returnmeter;}
//赤道半径EARTH_RADIUS = 6378137;//start 起点经纬度,数据格式 start = {lon:,lat:}//end 终点定位度,数据格式 end = {lon:,lat:}

IOS maps calculate distances between two points via latitude

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.