计算jsp中两个位置之间的距离
如何在JSP中计算两个位置之间的距离。我有两个位置的坐标,我只想知道在JSP中是否有任何函数可用于执行此操作 在android中,我使用这样的函数来计算两个位置之间的距离:计算jsp中两个位置之间的距离,jsp,netbeans,Jsp,Netbeans,如何在JSP中计算两个位置之间的距离。我有两个位置的坐标,我只想知道在JSP中是否有任何函数可用于执行此操作 在android中,我使用这样的函数来计算两个位置之间的距离: Location.distanceBetween(startLatitude, startLongitude, endLatitude, endLongitude, results); 如何在JSP中实现类似的功能。是否有任何jar文件我需要为此添加。请帮帮我。你可以从这里使用公式, 还是从这里 }我认为您提供的第二个链接
Location.distanceBetween(startLatitude, startLongitude, endLatitude, endLongitude, results);
如何在JSP中实现类似的功能。是否有任何jar文件我需要为此添加。请帮帮我。你可以从这里使用公式, 还是从这里
}我认为您提供的第二个链接中的第一个函数就足够了。您知道如何用Java计算它,但不知道如何将此解决方案移植到JSP,还是不知道如何用普通Java SE进行计算?
public class DistanceCalculator {
private double Radius;
// R = earth's radius (mean radius = 6,371km)
// Constructor
DistanceCalculator(double R) {
Radius = R;
}
public double CalculationByDistance(GeoPoint StartP, GeoPoint EndP) {
double lat1 = StartP.getLatitudeE6()/1E6;
double lat2 = EndP.getLatitudeE6()/1E6;
double lon1 = StartP.getLongitudeE6()/1E6;
double lon2 = EndP.getLongitudeE6()/1E6;
double dLat = Math.toRadians(lat2-lat1);
double dLon = Math.toRadians(lon2-lon1);
double a = Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) *
Math.sin(dLon/2) * Math.sin(dLon/2);
double c = 2 * Math.asin(Math.sqrt(a));
return Radius * c;
}