• <small id='LA24B'></small><noframes id='LA24B'>

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

        计算距离一个坐标的新坐标 x 米和 y 度

        时间:2023-09-02
        • <tfoot id='PSlzR'></tfoot>

              <tbody id='PSlzR'></tbody>

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

                <bdo id='PSlzR'></bdo><ul id='PSlzR'></ul>
              • <small id='PSlzR'></small><noframes id='PSlzR'>

                <legend id='PSlzR'><style id='PSlzR'><dir id='PSlzR'><q id='PSlzR'></q></dir></style></legend>
                1. 本文介绍了计算距离一个坐标的新坐标 x 米和 y 度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我一定是在文档中遗漏了一些东西,我认为这应该很容易......

                  I must be missing somthing out in the docs, I thought this should be easy...

                  如果我有一个坐标并且想要在 x 米外的某个方向上获得一个新坐标.我该怎么做?

                  If I have one coordinate and want to get a new coordinate x meters away, in some direction. How do I do this?

                  我正在寻找类似的东西

                  -(CLLocationCoordinate2D) translateCoordinate:(CLLocationCoordinate2D)坐标translateMeters:(int) 米translateDegrees:(double)degrees;

                  谢谢!

                  推荐答案

                  很遗憾,API 中没有提供这样的功能,所以你必须自己编写.

                  Unfortunately, there's no such function provided in the API, so you'll have to write your own.

                  这个网站给出了几个涉及纬度/经度和样本的计算JavaScript 代码.具体来说,标题为给定距离起点的目标点和方位角"的部分显示了如何计算您的要求.

                  This site gives several calculations involving latitude/longitude and sample JavaScript code. Specifically, the section titled "Destination point given distance and bearing from start point" shows how to calculate what you're asking.

                  JavaScript 代码位于该页面的底部,这是将其转换为 Objective-C 的一种可能方法:

                  The JavaScript code is at the bottom of that page and here's one possible way to convert it to Objective-C:

                  - (double)radiansFromDegrees:(double)degrees
                  {
                      return degrees * (M_PI/180.0);    
                  }
                  
                  - (double)degreesFromRadians:(double)radians
                  {
                      return radians * (180.0/M_PI);
                  }
                  
                  - (CLLocationCoordinate2D)coordinateFromCoord:
                          (CLLocationCoordinate2D)fromCoord 
                          atDistanceKm:(double)distanceKm 
                          atBearingDegrees:(double)bearingDegrees
                  {
                      double distanceRadians = distanceKm / 6371.0;
                        //6,371 = Earth's radius in km
                      double bearingRadians = [self radiansFromDegrees:bearingDegrees];
                      double fromLatRadians = [self radiansFromDegrees:fromCoord.latitude];
                      double fromLonRadians = [self radiansFromDegrees:fromCoord.longitude];
                  
                      double toLatRadians = asin( sin(fromLatRadians) * cos(distanceRadians) 
                          + cos(fromLatRadians) * sin(distanceRadians) * cos(bearingRadians) );
                  
                      double toLonRadians = fromLonRadians + atan2(sin(bearingRadians) 
                          * sin(distanceRadians) * cos(fromLatRadians), cos(distanceRadians) 
                          - sin(fromLatRadians) * sin(toLatRadians));
                  
                      // adjust toLonRadians to be in the range -180 to +180...
                      toLonRadians = fmod((toLonRadians + 3*M_PI), (2*M_PI)) - M_PI;
                  
                      CLLocationCoordinate2D result;
                      result.latitude = [self degreesFromRadians:toLatRadians];
                      result.longitude = [self degreesFromRadians:toLonRadians];
                      return result;
                  }
                  

                  在 JS 代码中,它包含 这个链接 显示更准确的计算距离大于地球周长的 1/4.

                  In the JS code, it contains this link which shows a more accurate calculation for distances greater than 1/4 of the Earth's circumference.

                  另请注意,上述代码接受以公里为单位的距离,因此请务必在通过之前将米除以 1000.0.

                  Also note the above code accepts distance in km so be sure to divide meters by 1000.0 before passing.

                  这篇关于计算距离一个坐标的新坐标 x 米和 y 度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在不使用 GPS 或互联网的情况下获取用户在 Andr 下一篇:Android:LocationManager 与 Google Play 服务

                  相关文章

                  最新文章

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

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

                    2. <tfoot id='H6td8'></tfoot>
                      • <bdo id='H6td8'></bdo><ul id='H6td8'></ul>