zoukankan      html  css  js  c++  java
  • 已知一点的经纬度和该点到另一点的距离,求另一点的经纬度

    刚做了将经纬度转换成距离,现在又要弄将距离转换成经纬度,哎!伤不起啊!

    以下是将距离换算成经纬度,有误差。 

               //将相对于起点的距离转换为经纬度,distance代表到点的距离,angle代表方位角度
            private string ConvertDistanceToLogLat(float distance, string logLatPtStr, double angle)
            {
                string logLat = null;
                string[] temp_Arrary = logLatPtStr.Split(',');
                double lng1 = ConvertLongiToDouble(temp_Arrary[0].Replace("(",""));
                double lat1 = ConvertLongiToDouble(temp_Arrary[1].Replace(")",""));
                double lon = lng1 + (distance * Math.Sin(angle* Math.PI / 180)) / (111 * Math.Cos(lat1 * Math.PI / 180));//将距离转换成经度的计算公式
                double lat = lat1 + (distance * Math.Cos(angle* Math.PI / 180)) / 111;//将距离转换成纬度的计算公式
                string logStr = ConvertLogLatToString(lon);
                string latStr = ConvertLogLatToString(lat);
                logLat = "(" + logStr + "," + latStr + ")";
                return logLat;
            }


            //将double值转换成度分秒字符串
            private string ConvertLogLatToString(double lon)
            {
                string resut = null;

                string temp = lon.ToString();
                string[] du = temp.Split('.');
                resut += du[0] + "°";
                double fen = (lon - Convert.ToDouble(du[0])) * 60;
                string[] fen_Arrary = fen.ToString().Split('.');
                resut += fen_Arrary[0] + "′";
                if (fen_Arrary.Length > 1)
                {
                    double second = Math.Round((fen - Convert.ToDouble(fen_Arrary[0])) * 60, 0);
                    resut += second.ToString() + "″";
                }
                return resut;
            }

  • 相关阅读:
    const 深悟理解
    深拷贝与浅拷贝深究
    结队开发-最大子数组
    软件工程个人作业02
    四则运算关于加括号的思路
    实践出真知-所谓"java没有指针",那叫做引用!
    写代码的好习惯—先构思
    团队合作
    阿超超的四则运算 想啊想啊
    Github+阿超运算
  • 原文地址:https://www.cnblogs.com/javawebsoa/p/3165715.html
Copyright © 2011-2022 走看看