• 计算两个坐标之间的距离


    public class DistanceInMeter
    {
    	
    public static double distFrom(double lat1, double lng1, double lat2, double lng2) {
        double earthRadius = 3958.75;
        double dLat = toRadians(lat2-lat1);
        double dLng = toRadians(lng2-lng1);
        double a = Math.Sin(dLat/2) * Math.Sin(dLat/2) +
                   Math.Cos(Math.toRadians(lat1)) * Math.Cos(Math.toRadians(lat2)) *
                   Math.Sin(dLng/2) * Math.Sin(dLng/2);
        double c = 2 * Math.Atan2(Math.sqrt(a), Math.sqrt(1-a));
        double dist = earthRadius * c;
    
        int meterConversion = 1609;
    
        return (dist * meterConversion);
        }
    
    	static double  toRadians(double degree)
    	{
    		return (degree*0.0174532925 );
    	}
    }  
  • 相关阅读:
    友链大集合
    雅礼学习10.7
    雅礼学习10.6
    雅礼学习10.5
    雅礼学习10.4
    雅礼学习10.3
    雅礼学习10.4
    雅礼学习10.2
    雅礼学习10.1
    如何让SublimeText3更好用
  • 原文地址:https://www.cnblogs.com/cplusplus/p/3078086.html
Copyright © 2020-2023  润新知