在方向和距离上将lat长几米

时间:2018-08-17 09:29:22

标签: gps

有什么想法吗?我的代码看起来像这样,但是不起作用。在所附的照片中,点0为圆心,其余为圆点(每45度下降)。我们看到一个例子,点不成圈

Look point 0 is center of circle 我在这里粘贴代码:

 static float[] RotateVector(float[] v, float degrees)
    {
        float sin = (float)Math.Sin(degrees * 0.0174553294f);
        float cos = (float)Math.Cos(degrees * 0.0174553294f);

        float tx = v[0];
        float ty = v[1];


        return new float[] { (cos * tx) - (sin * ty), (sin * tx) + (cos * ty) };
    }



    static void Main(string[] args)
    {

        float lat = 53.1324886f;
        float lon = 23.1688403f;

        float R = 6378137;

        float distance = 100;

        float dn = 0;
        float de = 1;

        float[] rotation = RotateVector(new float[] { dn, de }, 180);

        rotation[0] = rotation[0] * distance;
        rotation[1] = rotation[1] * distance;

        float dLat = rotation[0] / R;
        float dLon = rotation[1] / (R * (float)Math.Cos(Math.PI * lat / 180));


        float latO = lat + dLat * 180 / (float)Math.PI;
        float lonO = lon + dLon * 180 / (float)Math.PI;

        Console.WriteLine(latO+" "+ lonO);

        Console.ReadKey();
    }

1 个答案:

答案 0 :(得分:0)

带有地图的网站无法正常工作。在Google地图上,代码工作正常。