Gets the distance between the two longitude and latitude, the degree algorithm by which the number of meters moves through the latitudes; __ algorithm

Source: Internet
Author: User
Tags cos pow sin
Package xxtest; public class Test {//earth radius public static final Double Earth_radius = 6378137.0;//unit M private static DOUBL
    E Getrad (double D) {return d * math.pi/180.0; /** * Two coordinates (latitude and longitude) distance between calculation * GD/BD map using this algorithm * @param startlng start coordinates longitude * @param startlat start coordinates latitude * @p Aram ENDLNG Endpoint coordinates longitude * @param endlat endpoint coordinates latitude * @return The distance between the start and end coordinates unit: m/public static double GETGREATC 
        Ircledistance (double startlng, double Startlat, double endlng, double Endlat) {Double radLat1 = Getrad (Startlat);
        Double radLat2 = Getrad (Endlat); Double dy = radlat1-radlat2; A double dx = Getrad (STARTLNG)-Getrad (ENDLNG); b Double s = 2 * Math.asin (MATH.SQRT (Math.pow (Math.sin (DY/2), 2) + Math.Cos (RADLAT1) * MATH.COS (RADLAT2) * Ma
        Th.pow (Math.sin (DX/2), 2));
        s = S * earth_radius;
        s = Math.Round (S * 10000)/10000.0;
    return s; public static void Main (string[] ArGS) {//n 106.486654 degrees north latitude 23.490295 degrees to the east move 4000 meters northward move 3000 m double lng = GETMOVELNG (23.490295, 4000)
        + 106.486654;
        Double lat = Getmovelat (3000) + 23.490295;
        SYSTEM.OUT.PRINTLN (LAT);
        System.out.println (LNG);
    System.out.println ("Two point distance after moving (m):" +getgreatcircledistance (106.486654, 23.490295,lng,lat)); /** * Get latitude to move latmovement meters, latitude to move degrees * @param latmovement units: M * @return latitude of the degree of movement/public stat
    IC Double Getmovelat (double latmovement) {return (180/(Math.PI * earth_radius)) *latmovement; /** * Obtain longitude movement lngmovement m, Longitude movement degree * @param lat latitude * @param lngmovement unit: M * @return Longitude movement degree Number/public static double getmovelng (double-lat, double lngmovement) {return (180/Math.PI * Earth_radiu
    S*math.cos (Math.toradians (LAT))) *lngmovement;
 }
}

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.