<i id='8NNU4'><tr id='8NNU4'><dt id='8NNU4'><q id='8NNU4'><span id='8NNU4'><b id='8NNU4'><form id='8NNU4'><ins id='8NNU4'></ins><ul id='8NNU4'></ul><sub id='8NNU4'></sub></form><legend id='8NNU4'></legend><bdo id='8NNU4'><pre id='8NNU4'><center id='8NNU4'></center></pre></bdo></b><th id='8NNU4'></th></span></q></dt></tr></i><div id='8NNU4'><tfoot id='8NNU4'></tfoot><dl id='8NNU4'><fieldset id='8NNU4'></fieldset></dl></div>

    <bdo id='8NNU4'></bdo><ul id='8NNU4'></ul>

<small id='8NNU4'></small><noframes id='8NNU4'>

  • <tfoot id='8NNU4'></tfoot>
      1. <legend id='8NNU4'><style id='8NNU4'><dir id='8NNU4'><q id='8NNU4'></q></dir></style></legend>

        如何找到给定纬度/经度以北 x 公里的纬度/经度?

        时间:2023-07-25
      2. <tfoot id='xC5ns'></tfoot>

          <small id='xC5ns'></small><noframes id='xC5ns'>

          <legend id='xC5ns'><style id='xC5ns'><dir id='xC5ns'><q id='xC5ns'></q></dir></style></legend>

            <i id='xC5ns'><tr id='xC5ns'><dt id='xC5ns'><q id='xC5ns'><span id='xC5ns'><b id='xC5ns'><form id='xC5ns'><ins id='xC5ns'></ins><ul id='xC5ns'></ul><sub id='xC5ns'></sub></form><legend id='xC5ns'></legend><bdo id='xC5ns'><pre id='xC5ns'><center id='xC5ns'></center></pre></bdo></b><th id='xC5ns'></th></span></q></dt></tr></i><div id='xC5ns'><tfoot id='xC5ns'></tfoot><dl id='xC5ns'><fieldset id='xC5ns'></fieldset></dl></div>

              <tbody id='xC5ns'></tbody>
            • <bdo id='xC5ns'></bdo><ul id='xC5ns'></ul>
                • 本文介绍了如何找到给定纬度/经度以北 x 公里的纬度/经度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一些生成谷歌地图的 C# 代码.此代码查看我需要在地图上绘制的所有点,然后计算出矩形的边界以包含这些点.然后它将此边界传递给 Google Maps API 以适当地设置缩放级别以显示地图上的所有点.

                  I have some C# code that generates google maps. This codes looks at all the Points I need to plot on the map and then works out the Bounds of a rectangle to include those points. It then passes this bounds to the Google Maps API to set the zoom level appropriately to show all of the points on the map.

                  此代码运行良好,但我有一个新要求.

                  This code is working fine however I have a new requirement.

                  其中一个点可能具有与之相关的精度.如果是这种情况,那么我在该点周围画一个圆,半径设置为精度值.这再次工作正常,但是我的边界检查现在没有做我想要做的事情.我想让边界框包含完整的圆圈.

                  One of the points may have a precision associated with it. If this is the case then I draw a circle around the point with the radius set to the precision value. Again this works fine however my bounds checking is now not doing what I want it to do. I want to have the bounding box include the complete circle.

                  这需要一种算法来获取点 x 并计算点 y,该点位于 x 以北 z 米处和 x 以南 z 米处.

                  This requires an algorithm to take a point x and calculate the point y that would be z metres north of x and also z metres south of x.

                  有没有人有这个算法,最好是在 C# 中.我确实找到了一个通用算法 here 但我似乎没有正确实现这个作为我的答案得到的是 1000 公里的漂移.

                  Does anyone have this algorithm, preferably in C#. I did find a generic algorithm here but I appear to have not implemented this correctly as the answers I am getting are 1000s of km adrift.

                  这是通用示例

                  Lat/lon given radial and distance
                  
                  A point {lat,lon} is a distance d out on the tc radial from point 1 if:
                  
                       lat=asin(sin(lat1)*cos(d)+cos(lat1)*sin(d)*cos(tc))
                       IF (cos(lat)=0)
                          lon=lon1      // endpoint a pole
                       ELSE
                          lon=mod(lon1-asin(sin(tc)*sin(d)/cos(lat))+pi,2*pi)-pi
                       ENDIF
                  

                  这是我的 C# 翻译.

                  And this is my C# translation.

                    // Extend a Point North/South by the specified distance
                      public static Point ExtendPoint(Point _pt, int _distance, int _bearing )
                      {
                          Decimal lat = 0.0;
                          Decimal lng = 0.0;
                  
                          lat = Math.Asin(Math.Sin(_pt.Lat) * Math.Cos(_distance) + Math.Cos(_pt.Lat) * 
                              Math.Sin(_distance) * Math.Cos(_bearing));
                  
                           if (Math.Cos(lat) == 0)
                           {
                              lng = _pt.Lng;      // endpoint a pole
                           }
                           else 
                           {
                               lng = (
                                   (_pt.Lng - Math.Asin(Math.Sin(_bearing) * Math.Sin(_distance) / Math.Cos(lat)) 
                                   + Math.PI) % (2 * Math.PI)) - Math.PI;
                           }
                  
                           ret = new Point(lat,lng);
                           return ret;
                      }
                  

                  我调用这个函数的方位角为 0 来计算新的北纬位置,值 180 来计算新的南纬位置.

                  I am calling this function with a bearing of 0 to calculate the new northerly position and a value of 180 to calculate the new southerly position.

                  谁能看到我做错了什么或者提供一个已知的工作算法?

                  Can anyone either see what I have done wrong or perhaps provide a known working algorithm?

                  推荐答案

                  如果你有一个给定的纬度和经度,你可以像这样计算 x-km 纬度变化的正确纬度和经度:

                  If you have a given latitude and longitude you can calculate the correct latitude and longitude of an x-km change in latitude like so:

                  new-lat = ((old-km-north + x-km-change)/40,075) * 360)
                             ^ is the ratio of the                  ^ times the ratio of the circle
                             earth the change                       by 360 to get the total ratio 
                             covers.                                covered in degrees.
                  

                  这同样适用于经度.如果你有总距离加上变化,你可以用类似的方式计算总度数.

                  The same can apply to longitude. If you have the total distance plus the change you can calculate the total degrees in a similar fashion.

                  new-long = ((old-km-east + x-km-change)/40,075) * 360)
                             ^ is the ratio of the                  ^ times the ratio of the circle
                             earth the change                       by 360 to get the total ratio 
                             covers.                                covered in degrees.
                  

                  同样,这些计算应该有效,但我在这里失去了纯粹的直觉,但逻辑似乎确实成立.

                  Again, these calculations should work, but I'm running off pure intuition here, but the logic does seem to hold true.

                  正如 Skizz 所指出的,需要使用 2.pi.r.cos(lat) 或 40074.cos(lat) 将 40,075 调整到任何给定纬度的地球圆周

                  As pointed out by Skizz 40,075 needs to be adjusted to the circumference of the earth at any given latitude using 2.pi.r.cos(lat) or 40074.cos(lat)

                  这篇关于如何找到给定纬度/经度以北 x 公里的纬度/经度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:沿 A-B 线计算距 A 给定距离的点 下一篇:如何用半径和开始和停止角度绘制圆弧

                  相关文章

                  <small id='oKhAm'></small><noframes id='oKhAm'>

                  <i id='oKhAm'><tr id='oKhAm'><dt id='oKhAm'><q id='oKhAm'><span id='oKhAm'><b id='oKhAm'><form id='oKhAm'><ins id='oKhAm'></ins><ul id='oKhAm'></ul><sub id='oKhAm'></sub></form><legend id='oKhAm'></legend><bdo id='oKhAm'><pre id='oKhAm'><center id='oKhAm'></center></pre></bdo></b><th id='oKhAm'></th></span></q></dt></tr></i><div id='oKhAm'><tfoot id='oKhAm'></tfoot><dl id='oKhAm'><fieldset id='oKhAm'></fieldset></dl></div>
                    • <bdo id='oKhAm'></bdo><ul id='oKhAm'></ul>

                      <legend id='oKhAm'><style id='oKhAm'><dir id='oKhAm'><q id='oKhAm'></q></dir></style></legend>
                      <tfoot id='oKhAm'></tfoot>