package com.palmnest.application.core.util;


/**
 * @author Casing
 * 地图获取两个经纬度点的距离帮助类
 */
public class MapDistanceUtil {


	public static int getDistance(double staffLng, double staffLat, double userLng, double userLat) {

//        double lat1 = (Math.PI/180)*staffLat;  
//        double lat2 = (Math.PI/180)*userLat;  
//        double lon1 = (Math.PI/180)*staffLon;  
//        double lon2 = (Math.PI/180)*userLon;  
//        double d =  (Math.acos(Math.sin(lat1)*Math.sin(lat2)+Math.cos(lat1)*Math.cos(lat2)*Math.cos(lon2-lon1))*6371)*1000;
		double d = (Math.acos(Math.sin((Math.PI / 180) * staffLng) * Math.sin((Math.PI / 180) * userLng) + Math.cos((Math.PI / 180) * staffLng) * Math.cos((Math.PI / 180) * userLng) * Math.cos((Math.PI / 180) * userLat - (Math.PI / 180) * staffLat)) * 6371) * 1000;
		return (int) d;
	}

	public static void main(String[] args) {
		System.out.println(getDistance(114.0827, 22.5410, 114.082809, 22.540297));
	}
}
