It gives you two latitude and longitude, and calculates the distance between them.

Source: Internet
Author: User

It gives you two latitude and longitude, and calculates the distance between them.

How are these cable cables determined? The earth is constantly rotating around the Earth's axis (the Earth's axis is a path through the north and south poles of the Earth and the Center of the Earth
Imaginary line), draw a large circle perpendicular to the ground axis in the waist of the earth, so that every point in the circle is equal to the distance between the North and South Poles, this circle
It is called "Equator ". On the north and south sides of the Equator, draw many circles parallel to the equator, that is, the latitude circle,
It is called a weft. We set the equator to zero latitude, 90 degrees to the north to the south, and north to the south of the equator.
The North Pole is 90 degrees north latitude, and the South Pole is 90 degrees south latitude. The latitude and height also indicate the hot and cold climate, such as the winter in the Equator and low latitude regions,
There is no summer in the polar and high latitudes, and the middle and latitude regions have distinct seasons.
Second, from the Arctic point to the South Pole, we can draw many large circles perpendicular to the earth's equator in the North-South direction, which is called the "Meridian Circle ".
The line segments of some circles are called longitude lines. In the year of the planimetric map 1884, the international regulation adopted by the Greenwich Observatory on the outskirts of London
The longitude line is used as the start point for calculating the longitude, that is, the longitude is 0 minutes 0 seconds, also known as the "primary meridian ". The east longitude is in the east, with a total of 180 degrees;
In the west of the Meridian, a total of 180 degrees. Because the earth is circular, the longitude of the east longitude is 180 degrees and the longitude line of the west longitude is the same. Countries
The 180-degree longitude line is the "International Date change line ". In order to avoid using two different dates in the same region, the international date variation occurs on land.
Slightly deviated.
Each longitude and latitude can be subdivided into 60 minutes, and each minute is divided into 60 seconds and decimal places in seconds. We can confirm with the cable
The specific location of each place on the earth, and it is displayed on a map or globe. For example, what is the longitude and latitude of Beijing? We
It is easy to find out from the map that the longitude is 116 degrees 24 points, and the latitude is 39 degrees 54 points. For a vessel sailing in the sea, you only need to test the longitude of its location.
To determine the position and Forward Direction of the ship in the ocean. The latitude is 90 degrees. The equator is 0 degrees, arranged to two poles, and the smaller the circle,
The higher the level.
The horizontal line is the latitude, and the vertical line is the longitude.
Of course, it can be computed by quadratic equation of four elements.
Longitude and latitude are both an angle. Longitude is the angle between two sides and the plane of the longitude line. Because all longitude lines are the same length, to measure
Longitude selects a starting area. After consultation at the 1884 International Conference, it is decided to pass through the Greenwich royal family on the outskirts of London and the south bank of the river.
The meridian line of a major meridian Cross of the Observatory (old site) is the starting Meridian. The primary meridian plane is the starting point.
Point plane. The end plane is the plane of the local longitude line. The longitude of a point is the angle between the longitude plane of the point and the primary meridian plane. In
On the equator, the original primary meridian plane is used as the starting point and measured to the east and west respectively. The value to the east is called the east longitude, and the value to the west is called the West
Longitude. It can be seen that the longitude of a region is the direction and angular distance of the region to the primary Meridian. The prime meridian is 0 ° longitude, and the east longitude is the most
The longitude is 180 °, and the maximum value of the west longitude is 180 °. The longitude line of the east and west longitude is the same longitude line.
180 ° longitude cable.
Latitude is a line angle. The START plane is the equator plane, and the line is the local ground normal. The so-called normal, that is, the line perpendicular to the reference flat surface.
The latitude of a place is the angle between the normal of the place and the Equator plane. Latitude is measured on the local longitude line, from the equator to the south, north, and North
A value is called the north latitude, and a value to the south is called the south latitude. It can be seen that the latitude of a region is the direction and angular distance of the region to the equator. Equator is
0 ° weft, the maximum value of the north latitude is 90 °, that is, the northern point; the maximum value of the southern latitude is 90 °, that is, the southern pole.

Longitude and latitude Interchange

Degree (DDD): E 108.90593 degrees N 34.21630 degrees

How to convert degrees (DDD): 108.90593 degrees to degrees (DMS) Dong Jing E 108 degrees 54 minutes 22.2 seconds? The conversion method is to change the 108.90593 integer to 108 degrees, and use 0.90593*60 = 54.3558 to retrieve the entire digit 54 (points ), 0.3558*60 = 21.348 and then the integer is 21 (seconds), so it is converted to 108 degrees 54 minutes 21 seconds.

Similarly, the method for converting degrees into seconds (DMS): Dong Jing E 108 degrees 54 minutes 22.2 seconds to degrees (DDD) is as follows: 108 degrees 54 minutes 22.2 seconds = 108 + (54/60) + (22.2/3600) = 108.90616 degrees

Because the decimal point is retained During computation, there is a certain error in the positive and negative computation, but the error does not have a great impact. The error of one second is a few meters. GPS drivers can use the above method to convert the Unit coordinates they need.

 

 

Longitude and latitude to meter

The latitude is divided into 60 points, and each point is divided into 60 seconds and the decimal point of the second.

The latitude line is projected on a seemingly horizontal parallel line, but it is actually a circle with different radius. All locations with the same specific latitude are on the same weft.
The latitude of the equator is 0 °, and the planet is evenly divided into the Southern Hemisphere and the northern hemisphere.
Latitude refers to the line angle between a point and the Earth's ball center and the Earth's track surface. Its value ranges from 0 to 90 degrees. The latitude of a point located north of the equator is north latitude, which is recorded as N. the latitude of a point located south of the equator is called south latitude, and it is recorded as S.
The region with the latitude value between 0 and 30 degrees is called the low latitude area, and the region with the latitude value between 30 and 60 degrees is called the middle latitude area, the area with a latitude value between 60 and 90 degrees is called the high latitude area.
The equator, the return-to-south line, the return-to-north line, the Antarctic Circle, and the Arctic Circle are special latitudes.
Length of 1 second at latitude
The total meridian length of the Earth is about 40008 km. Average:
Latitude 1 degree = approximately 111 km
Latitude: 1 = approximately 1.85 km
Latitude 1 second = approximately 30.9 m

Calculate the distance between two points based on the longitude and latitude of any two points on the ball

The earth is a quasi-Standard Elliptical body. Its equator radius is 6378.140 km, the polar radius is 6356.755 km, and the average radius is 6371.004 km. If we assume that the Earth is a perfect sphere, its radius is the mean radius of the Earth, which is recorded as R. If the zero-degree longitude line is used as the basis, the distance between the two points can be calculated based on the latitude and longitude of any two points on the Earth's surface. (here, the error caused by the calculation of the earth's surface topography is ignored, only theoretical estimates ). Set the longitude and latitude of the first Vertex A to (LonA, LatA), and the longitude and latitude of the second vertex B to (LonB, LatB) based on the zero-degree longitude line, the Longitude is a positive value (longpolling), the Longitude is a negative value (-longpolling), and the Latitude is 90-Latitude ), when the Latitude value is 90 + (90 + Latitude), the two points after processing are counted as (MLonA, MLatA) and (MLonB, MLatB ). According to the triangle derivation, the following formula is obtained for calculating the distance between two points:

C = sin (MLatA) * sin (MLatB) * cos (MLonA-MLonB) + cos (MLatA) * cos (MLatB)

Distance = R * Arccos (C) * Pi/180

Here, the units of R and Distance are the same. If 6371.004 km is used as the radius, Distance is the unit of kilometer. If other units such as mile are used, unit conversion is also required, 1Km = 0.621371192 mile

If only the longitude is processed plus and minus, And the Latitude is not processed with 90-Latitude (assuming they are all in the northern hemisphere, and the southern hemisphere is only available in Australia), the formula will be:

C = sin (LatA) * sin (LatB) + cos (LatA) * cos (LatB) * cos (MLonA-MLonB)

Distance = R * Arccos (C) * Pi/180

The above can be introduced through simple triangle transformation.

If the input and output values of trigonometric functions use radians, the formula can also be written as follows:

C = sin (LatA * Pi/180) * sin (LatB * Pi/180) + cos (LatA * Pi/180) * cos (LatB * Pi/180) * cos (MLonA-MLonB) * Pi/180)

Distance = R * Arccos (C) * Pi/180

That is:

C = sin (LatA/57.2958) * sin (LatB/57.2958) + cos (LatA/57.2958) * cos (LatB/57.2958) * cos (MLonA-MLonB)/57.2958)

Distance = R * Arccos (C) = 6371.004 * Arccos (C) kilometer = 0.621371192*6371.004 * Arccos (C) mile = 3958.758349716768 * Arccos (C) mile

In practical application, we generally use an individual zip code to find the longitude and latitude of the region center corresponding to the zip code, and then calculate the distance between each other based on these latitudes, to estimate the approximate distance between certain groups (for example, the distribution range of hotel passengers-the latitude and longitude corresponding to the zip code of each passenger and the distance range calculated by the hotel's latitude and longitude ), therefore, it is a useful resource to query such a database by postal code.
Appendix: java code:

/*** Calculate the distance between two latitude and longitude ** @ author **/public class CalulateTwoLanLon {private static final double EARTH_RADIUS = 6378.137; // The Earth's radius, unit: kilometer private static double rad (double d) {return d * Math. PI/180.0 ;} /***** @ param lat1 first latitude * @ param lng1 first longitude * @ param lat2 second latitude * @ param lng2 second longitude * @ return distance between two latitude and longitude * /public static double getDistance (double lat1, double lng1, double lat2, double lng2) {double radLat1 = rad (lat1); double radLat2 = rad (lat2); double a = radLat1-radLat2; double B = rad (lng1) -rad (lng2); double s = 2 * Math. asin (Math. sqrt (Math. pow (Math. sin (a/2), 2) + Math. cos (radLat1) * Math. cos (radLat2) * Math. pow (Math. sin (B/2), 2); s = s * EARTH_RADIUS; s = Math. round (s * 10000)/10000; return s;} public static void main (String [] args) {System. out. println (CalulateTwoLanLon. getDistance (22.75424, 112.76535, 23.014171, 113.10111 ));}}

 

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.