Php,mysql calculating distances and sorting according to latitude and longitude

Source: Internet
Author: User
Tags cos pow sin

The calculation formula given on the net is this:

    • Lng1 represents a point of latitude and longitude, and Lat2 Lng2 represents the B-point latitude and longitude
    • A = Lat1–lat2 is two points of latitude difference B = lng1-lng2 is two point longitude difference
    • 6378.137 is the radius of the Earth, the unit is kilometer
    • The calculated result is measured in kilometers.

Select *,(2 * 6378.137* ASIN(SQRT(POW (SIN(PI()*(111.86141967773438-Lng/ the),2)+COS(PI()*33.07078170776367/ the)* COS(Lat* PI()/ the)*POW (SIN(PI()*(33.07078170776367-Lat/ the),2)))) asJuli from' Area 'Order  byJuliASCLimit0, -

Php,mysql calculating distances and sorting according to latitude and longitude

Related Article

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.