`
hooroger
  • 浏览: 13283 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

Calculate the Distance Between Two Coordinates (latitude, longitude)

    博客分类:
  • php
阅读更多
  1. function distance($lat1, $lng1, $lat2, $lng2, $miles = true)
  2. {
  3. $pi80 = M_PI / 180;
  4. $lat1 *= $pi80;
  5. $lng1 *= $pi80;
  6. $lat2 *= $pi80;
  7. $lng2 *= $pi80;
  8.  
  9. $r = 6372.797; // mean radius of Earth in km
  10. $dlat = $lat2 - $lat1;
  11. $dlng = $lng2 - $lng1;
  12. $a = sin($dlat / 2) * sin($dlat / 2) + cos($lat1) * cos($lat2) * sin($dlng / 2) * sin($dlng / 2);
  13. $c = 2 * atan2(sqrt($a), sqrt(1 - $a));
  14. $km = $r * $c;
  15.  
  16. return ($miles ? ($km * 0.621371192) : $km);
  17. }
分享到:
评论

相关推荐

    Latitude longitude coordinate conversion UTM coordinate operatio

    Functions supported by version 0.11: ...2. Calculate the distance between two UTM coordinates C++ See main.cpp function for details of Demo Python3.7 See main.py for details of Demo

    Phased_Array_Impedance_Calculation.rar_antennas matlab_between

    Calculate the impedance between two antennas.

    calculate_min_distance.zip_Euclid_Euclidean distance_Min_pixel_最

    计算2组象素的最小距离 minimum euclidean distance calculation between 2 groups pixels and returns the distance and pixel coordinations文件内容:test_min_distance5a.tif, CONTENTS.M, euclidean_distance.m,...

    matlab 两点距离

    % Calculate distance between two positions on glode using the "Plane % Sailing" method. Also uses simple geometry to calculate the bearing of % the path between position pairs. % % INPUT: % lat = ...

    hungry-distance

    Calculate the distance between two points in an XYZ space USAGE: hungry-distance < x> < y> < z> < x> < y> ARGS: < x> co-ordinate 1 x < y> co-ordinate 1 y < z> co-ordinate 1 z < x> co-ordinate 2 ...

    calculate_distance_基站覆盖_基站_basestation_distance_距离_源码.zip

    本资源"calculate_distance_基站覆盖_基站_basestation_distance_距离_源码.zip"包含了用于计算这些参数的源代码。 首先,我们要理解基站覆盖的基本概念。基站的覆盖范围取决于多种因素,包括发射功率、天线高度、...

    calculate_distance_基站覆盖_基站_basestation_distance_距离.zip

    标题中的“calculate_distance_基站覆盖_基站_basestation_distance_距离.zip”暗示了这个压缩包文件包含的内容可能与计算移动通信中的基站覆盖范围以及基站之间的距离有关。这通常涉及到无线通信、网络规划和信号...

    calculate_distance_基站覆盖_基站_basestation_distance_距离

    在无线通信领域,基站(Basestation)是网络基础设施的关键组成部分,负责向移动用户设备(UE,User Equipment)提供无线连接。基站覆盖是指基站信号能够达到的地理区域,它直接影响着移动通信的质量和范围。...

    Calculate-Distance-Matrix:使用 csv 获取两个位置之间的距离或时间

    git clone https://github.com/lucioerlan/calculate-distance-matrix.git$ cd calculate-distance-matrix/client -and- calculate-distance-matrix/server$ npm install 注意事项: 正确格式化 .csv 文件,在 /...

    View Factor

    Another model implemented, calculates the view factor between two or more surfaces. Determination of the long-wave radiant heat exchange between two or more surfaces or heat exchange with a surface ...

    lsmr.zip_calculate distance_yourkvy_距离 角度

    标题中的“lsmr.zip_calculate distance_yourkvy_距离 角度”表明这是一个关于使用LSMR算法(一种求解线性系统的迭代方法)来计算地理位置间距离和角度的项目。描述中提到的“根据卫星坐标准确计算三点距离及其角度...

    untitled.rar_between

    This code is used to calculate the relationship between the elevation and loss angle of the atmospheric gases

    sonar_smaller_distance

    This file contains an example that show how to detect an object's distance and calculate the smallest distance.

    Calculate-the-day-of-the-year.zip_The Year

    本项目“Calculate-the-day-of-the-year.zip_The Year”提供了这样的学习资源,通过一个名为“Calculate the day of the year.txt”的文本文件,帮助我们理解如何实现这一功能。 首先,我们需要知道的是年份、月份...

    二级减速器课程设计说明书reducer design specification.doc

    According to the selected fullload speed of the motor nm and the drive shaft speed of the motor nw,we can calculate the total transmission ratio of the transmission device ia: (2)Allocate ...

    CalculateDistance

    在Android开发中,"CalculateDistance"项目是一个基于Java的应用,主要功能是计算预计到达时间(ETA)以及参与者之间的会面点与他们当前位置的距离。这个应用对于旅行者、聚会组织者或者任何需要估算行程时间与距离的...

    腾讯计算距离回调方法1

    接下来,`calculateDistance`方法被用来计算从一个点到多个点的距离。这个方法接受一个对象作为参数,其中包括`to`字段,它是一个包含目标位置的数组。每个目标位置都是一个包含`latitude`和`longitude`的对象。在这...

    华中科技大学出品的应用语言学与统计学的研究方法课程完整精品版SPSS数据分析数据挖掘全套英文PPT课程(共47页)11 相关与多元回归.ppt

    Pearson Correlation The Pearson correlation allows us to ... SPSS will also explore the relationship between two variables, while controlling for another variable. This is known as partial correlation.

    lyft_challenge

    Lyft 编程挑战Lyft 编程挑战的解决方案 Calculate the detour distance between two different rides. Given four latitude / longitude pairs, where driver one is traveling from point A to point B and driver ...

    Beginning Neo4j(Apress,2016)

    Using this book, you'll get everything up and running, and then learn how to use Neo4j to build up recommendations, relationships, and calculate the shortest route between two locations. With example ...

Global site tag (gtag.js) - Google Analytics