PHP calculates distance based on latitude and longitude between two points, php two-point latitude and longitude calculation _php tutorial

Source: Internet
Author: User

PHP calculates distances based on latitude and longitude between two points, php two longitude and latitude.


This is a good example of directly pasting code, first of all to know the latitude value, longitude value


PHP calculates the distance between the two latitude and longitude issues, guiding

It's not going to count, but look at the code and find something wrong with your code.
First, two points between the straight line distance squared: $len After the end of no use, nor return, completely useless
Second, input the same latitude and longitude, the result is not 0, but also a very large number, so it should be problematic

You can Baidu "php by longitude two points between the distance", there are a lot of ready-made code
I see this introduction in more detail, and there is code that you can look at
blog.csdn.net/...963740

If you know how the latitude and longitude of two points is the distance between two points

Longitude with different latitude (except equator)
H x 111 x cosd=g (h= longitude Difference d= local geographic latitude g= actual distance)

The need to construct a triangle across latitudes
For example, AB two points of different latitude and longitude (a by B weft)
The distance between the Latitude B ', which is collinear with point A, and the distance from A to B ' are calculated by using the Pythagorean theorem.

Simply put, the following general formulas are available:
The distance between the Earth and the two points formula:
The earth takes two points, its longitude is A1, A2 (e positive, w negative), Latitude is B1, B2 (n positive, s minus) respectively.
Make a0= (A1-A2) ÷2,b0= (BI-B2) ÷2
F=√sinb0xsinb0+cosb1xcosb2xsina0xsina0

The
1, two-point space between the linear distance =2FR
2, two points between the ball surface distance =arcsinf÷90°x∏r (angle)
3, two points between the ball surface distance =arcsinfx2r (radians)

Description: E, W, N, s= East; r= Earth radius; √= radical; ∏= pi.
Let's do the math.

http://www.bkjia.com/PHPjc/904006.html www.bkjia.com true http://www.bkjia.com/PHPjc/904006.html techarticle PHP based on the latitude and longitude between two points to calculate the distance, php two latitude and longitude calculation This is a good example, directly paste the code, first of all to know the latitude value, longitude value/** * @desc According to two points between ...

  • 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.