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

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

        <bdo id='zIfig'></bdo><ul id='zIfig'></ul>

      1. <tfoot id='zIfig'></tfoot>
      2. <legend id='zIfig'><style id='zIfig'><dir id='zIfig'><q id='zIfig'></q></dir></style></legend>
      3. 如何使用坐标将标记移动 100 米

        时间:2024-05-11
      4. <small id='n2AZ0'></small><noframes id='n2AZ0'>

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

              2. <legend id='n2AZ0'><style id='n2AZ0'><dir id='n2AZ0'><q id='n2AZ0'></q></dir></style></legend>

                  <tbody id='n2AZ0'></tbody>
                <tfoot id='n2AZ0'></tfoot>

                • 本文介绍了如何使用坐标将标记移动 100 米的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有 2 个坐标.坐标 1 是人".坐标 2 是目的地.

                  I have 2 coordinates. Coordinate 1 is a 'person'. Coordinate 2 is a destination.

                  如何将坐标 1 100 米移近坐标 2?

                  How do I move coordinate 1 100 meters closer to coordinate 2?

                  这将用于 cron 作业,因此仅包括 php 和 mysql.

                  This would be used in a cron job, so only php and mysql included.

                  例如:

                  联系人在:51.26667, 3.45417

                  Person is at: 51.26667, 3.45417

                  目的地是:51.575001, 4.83889

                  Destination is: 51.575001, 4.83889

                  我将如何计算距离 Person 更近 100 米的新坐标?

                  How would i calculate the new coordinates for Person to be 100 meters closer?

                  推荐答案

                  使用Haversine计算两点之间的差,以米为单位;然后按比例调整人物坐标的值.

                  Use Haversine to calculate the difference between the two points in metres; then adjust the value of the person coordinates proportionally.

                  $radius = 6378100; // radius of earth in meters
                  $latDist = $lat - $lat2;
                  $lngDist = $lng - $lng2;
                  $latDistRad = deg2rad($latDist);
                  $lngDistRad = deg2rad($lngDist);
                  $sinLatD = sin($latDistRad);
                  $sinLngD = sin($lngDistRad);
                  $cosLat1 = cos(deg2rad($lat));
                  $cosLat2 = cos(deg2rad($lat2));
                  $a = ($sinLatD/2)*($sinLatD/2) + $cosLat1*$cosLat2*($sinLngD/2)*($sinLngD/2);
                  if($a<0) $a = -1*$a;
                  $c = 2*atan2(sqrt($a), sqrt(1-$a));
                  $distance = $radius*$c;
                  

                  培养你的价值观:

                  $lat = 51.26667;        //  Just South of Aardenburg in Belgium
                  $lng = 3.45417;
                  $lat2 = 51.575001;      //  To the East of Breda in Holland
                  $lng2 = 4.83889;
                  

                  给出的结果是 102059.82251083 米,102.06 公里

                  gives a result of 102059.82251083 metres, 102.06 kilometers

                  调整比例为 100/102059.82251083 = 0.0009798174985988102859004569070625

                  The ratio to adjust by is 100 / 102059.82251083 = 0.0009798174985988102859004569070625

                  $newLat = $lat + (($lat2 - $lat) * $ratio);
                  $newLng = $lng + (($lng2 - $lng) * $ratio);
                  

                  给出新的纬度 51.266972108109 和经度 3.4555267728867

                  Gives a new latitude of 51.266972108109 and longitude of 3.4555267728867

                  这篇关于如何使用坐标将标记移动 100 米的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:从 php 中的图像读取地理标记数据 下一篇:WooCommerce 中特定产品的基于地理位置的自定义重定向

                  相关文章

                    • <bdo id='w2qvR'></bdo><ul id='w2qvR'></ul>

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

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

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