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

    <tfoot id='mTCO8'></tfoot>
      <bdo id='mTCO8'></bdo><ul id='mTCO8'></ul>

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

        计算给定2个点,纬度和经度的距离

        Calculate distance given 2 points, latitude and longitude(计算给定2个点,纬度和经度的距离)

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

                <tbody id='oM5MG'></tbody>

            1. <tfoot id='oM5MG'></tfoot>
                <i id='oM5MG'><tr id='oM5MG'><dt id='oM5MG'><q id='oM5MG'><span id='oM5MG'><b id='oM5MG'><form id='oM5MG'><ins id='oM5MG'></ins><ul id='oM5MG'></ul><sub id='oM5MG'></sub></form><legend id='oM5MG'></legend><bdo id='oM5MG'><pre id='oM5MG'><center id='oM5MG'></center></pre></bdo></b><th id='oM5MG'></th></span></q></dt></tr></i><div id='oM5MG'><tfoot id='oM5MG'></tfoot><dl id='oM5MG'><fieldset id='oM5MG'></fieldset></dl></div>
                  <bdo id='oM5MG'></bdo><ul id='oM5MG'></ul>
                  <legend id='oM5MG'><style id='oM5MG'><dir id='oM5MG'><q id='oM5MG'></q></dir></style></legend>
                • 本文介绍了计算给定2个点,纬度和经度的距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  可能的重复:
                  MySQL 经纬度表设置

                  我知道这个问题可能已经被问过很多次了,我已经研究了很多,我需要特定事情的帮助.

                  I know this question has probably been asked many times, I've researched a lot and I need help with specific thing.

                  假设我有一个表单,用户输入经度和纬度,并且我有一个包含经度和纬度表的数据库,我将如何在该表中搜索半径 15 英里内的一个或多个点?

                  Lets say I have a form and user enters longitude and latitude, and I have a database which has table containing longitudes and latitudes, how would I search for a point or points in that table that are within 15 miles of radius?

                  推荐答案

                  您可以使用计算两点之间距离的公式.例如:

                  You can use the formula that calculates distances between two points. For example:

                  function get_distance($latitude1, $longitude1, $latitude2, $longitude2, $unit = 'Mi') { 
                      $theta = $longitude1 - $longitude2; 
                      $distance = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2))) + 
                                  (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * 
                                  cos(deg2rad($theta))); 
                      $distance = acos($distance); 
                      $distance = rad2deg($distance); 
                      $distance = $distance * 60 * 1.1515; 
                      switch($unit) { 
                          case 'Mi': 
                              break; 
                          case 'Km' : 
                              $distance = $distance * 1.609344; 
                      } 
                      return (round($distance,2)); 
                  }
                  

                  您还可以执行以下操作:

                  You can also do something like:

                  $query = "SELECT *,(((acos(sin((".$latitude."*pi()/180)) * 
                              sin((`Latitude`*pi()/180))+cos((".$latitude."*pi()/180)) * 
                              cos((`Latitude`*pi()/180)) * cos(((".$longitude."- `Longitude`)* 
                              pi()/180))))*180/pi())*60*1.1515
                          ) as distance 
                          FROM `MyTable` 
                          HAVING distance >= ".$distance.";
                  

                  这篇关于计算给定2个点,纬度和经度的距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Bogus foreign key constraint fail(虚假外键约束失败)
                  how to get last insert id after insert query in codeigniter active record(如何在codeigniter活动记录中插入查询后获取最后一个插入ID)
                  Force InnoDB to recheck foreign keys on a table/tables?(强制 InnoDB 重新检查表/表上的外键?)
                  How to auto generate migrations with Sequelize CLI from Sequelize models?(如何使用 Sequelize CLI 从 Sequelize 模型自动生成迁移?)
                  Clear MySQL query cache without restarting server(无需重启服务器即可清除 MySQL 查询缓存)
                  ALTER TABLE to add a composite primary key(ALTER TABLE 添加复合主键)

                        <tbody id='J2lBL'></tbody>
                        <bdo id='J2lBL'></bdo><ul id='J2lBL'></ul>

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

                        1. <legend id='J2lBL'><style id='J2lBL'><dir id='J2lBL'><q id='J2lBL'></q></dir></style></legend>
                            <tfoot id='J2lBL'></tfoot>

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