Here you can find the source of distance(double latitude1, double longitude1, double latitude2, double longitude2)
private static double distance(double latitude1, double longitude1, double latitude2, double longitude2)
//package com.java2s; public class Main { private static double distance(double latitude1, double longitude1, double latitude2, double longitude2) { return Math.sqrt((latitude1 - latitude2) * (latitude1 - latitude2) + (longitude1 - longitude2) * (longitude1 - longitude2)); }/*w w w . j a va 2 s.co m*/ }