Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static double GetDistance(double pLatitude1, double pLongitude1, double pLatitude2, double pLongitude2) {
        double vDist = Math.sin(deg2rad(pLatitude1)) * Math.sin(deg2rad(pLatitude2)) + Math.cos(deg2rad(pLatitude1))
                * Math.cos(deg2rad(pLatitude2)) * Math.cos(deg2rad(pLongitude1 - pLongitude2));
        vDist = Math.acos(vDist);
        vDist = rad2deg(vDist);
        vDist = vDist * 111189.57696;// * 60 * 1.1515 * 1.609344 * 1000;
        return vDist;
    }

    private static double deg2rad(double deg) {
        return (deg * Math.PI / 180.0);
    }

    private static double rad2deg(double rad) {
        return (rad * 180.0 / Math.PI);
    }
}