• 经纬度 范围 距离 计算


     private const double EARTH_RADIUS = 6378.137;//地球半径
             private static double RAD = Math.PI / 180.0;
            //获取两个经纬度之间的距离
             public static double GetDistance(double lng1, double lat1, double lng2, double lat2)
            {
                double radLat1 = lat1 * RAD;
                double radLat2 = lat2 * RAD;
                double a = radLat1 - radLat2;
                double b = (lng1 - lng2) * RAD;
                double s = 2 * Math.Sin(Math.Sqrt(Math.Pow(Math.Sin(a / 2), 2) +
                 Math.Cos(radLat1) * Math.Cos(radLat2) * Math.Pow(Math.Sin(b / 2), 2)));
                s = s * EARTH_RADIUS;
                s = Math.Round(s * 10000) / 10000;
                return s;   
            }

            //获取两个经纬度的某个范围内的最大经度和最大纬度 单位 米
            public static double[] getAround(double lat, double lon, int raidus)
            {
                double PI = 3.14159265;
                Double latitude = lat;
                Double longitude = lon;

                Double degree = (24901 * 1609) / 360.0;
                double raidusMile = raidus;

                Double dpmLat = 1 / degree;
                Double radiusLat = dpmLat * raidusMile;
                Double minLat = latitude - radiusLat;
                Double maxLat = latitude + radiusLat;

                Double mpdLng = degree * Math.Cos(latitude * (PI / 180));
                Double dpmLng = 1 / mpdLng;
                Double radiusLng = dpmLng * raidusMile;
                Double minLng = longitude - radiusLng;
                Double maxLng = longitude + radiusLng;
                return new double[] { minLat, minLng, maxLat, maxLng };
            }

  • 相关阅读:
    opencv计算机视觉学习笔记一
    opencv_python学习笔记十八
    opencv_python学习笔记十六
    Android-锁屏功能
    Android-加载透明PNG图片变黑的问题
    Android-AttributeSet详解
    Android-UGallery
    Android-相册效果(图片缩放 自由滑动)
    Android进阶篇-内存管理
    Android进阶篇-时间滑动控件
  • 原文地址:https://www.cnblogs.com/weiying/p/weiying_2014_06_19.html
Copyright © 2020-2023  润新知