Here you can find the source of distanceByLBS(double lo1, double la1, double lo2, double la2)
public static double distanceByLBS(double lo1, double la1, double lo2, double la2)
//package com.java2s; //License from project: Apache License public class Main { public static double distanceByLBS(double lo1, double la1, double lo2, double la2) { double radLat1 = la1 * Math.PI / 180; double radLat2 = la2 * Math.PI / 180; double a = radLat1 - radLat2; double b = lo1 * Math.PI / 180 - lo2 * Math.PI / 180; 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 * 6378137.0;// w w w. ja va2 s. c om s = Math.round(s * 10000) / 10000; return s; } }