According to two points of latitude and longitude calculation precision distance, the results and Baidu map ranging as--java implementation

Source: Internet
Author: User
Calculation of precise distance--java based on two-point latitude and longitude

Baidu map pickup latitude and longitude coordinates: http://api.map.baidu.com/lbsapi/getpoint/index.html on the internet to see a lot of distance based on latitude and longitude of the code is not accurate, and I tested the latitude to adjust to the North Pole (lon=90) , Latitude does not change, the result is still so much distance. Let's look at some conventional computing methods .

1. What is this. This is the Pythagorean theorem.

2. And this, is the most conventional algorithm, you will find that the latitude is the same, but latitude one but change the value will be wrong.

3. The second algorithm is originally from the Google formula, I dare not say that the formula is wrong, but the distance is not the same as the Baidu map.
The main errors of these algorithms are as follows: 1. Ignoring that the earth is not a standard sphere, it is based on a standard sphere . 2. Ignores changes in latitude that can cause longitude distances so based on the cost of more than 10 minutes of transformation and logical realization finally distance and Baidu map exactly the same.

Baidu map pickup latitude and longitude coordinates: http://api.map.baidu.com/lbsapi/getpoint/index.html
Can first in the Baidu API to take out the coordinates, and then use the Baidu map ranging. Ensure the results are identical. Download source code address

Click to download

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.