php 根据位置的经纬度计算距离

在开发中,我们要经常和位置打交道,要计算附近的位置、距离什么的。如下:

一.sql语句

SELECT houseID,title,location,chamber,room,toward,area,rent,is_verify,look_type,look_time,
            traffic,block_name,images,tag,create_time,update_time, location->>'$.latitude' AS latitude,  
                    location->>'$.longitude' AS longitude,  
                    (  
                        6371 * acos(  
                            cos(radians(28.6558)) *  
                            cos(radians(CAST(location->>'$.latitude' AS DECIMAL(10, 6)))) *  
                            cos(radians(CAST(location->>'$.longitude' AS DECIMAL(10, 6))) - radians(112.913779)) +  
                            sin(radians(28.6558)) *  
                            sin(radians(CAST(location->>'$.latitude' AS DECIMAL(10, 6))))  
                        )  
 

相关推荐

  1. php 根据位置经纬度计算距离

    2024-07-23 08:24:05       20 阅读
  2. mysql 根据经纬度计算距离

    2024-07-23 08:24:05       21 阅读
  3. php根据用户地址获取经纬度

    2024-07-23 08:24:05       33 阅读
  4. PHP计算某个特定时间戳距离现在天数

    2024-07-23 08:24:05       64 阅读
  5. 前端点击地图上位置获取当前经纬度

    2024-07-23 08:24:05       25 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-23 08:24:05       75 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-23 08:24:05       80 阅读
  3. 在Django里面运行非项目文件

    2024-07-23 08:24:05       64 阅读
  4. Python语言-面向对象

    2024-07-23 08:24:05       75 阅读

热门阅读

  1. 【git】切换到远程其他分支

    2024-07-23 08:24:05       20 阅读
  2. CentOS 6.8 中部署 Spring Boot 应用程序

    2024-07-23 08:24:05       22 阅读
  3. Mybatis-plus常用注解

    2024-07-23 08:24:05       20 阅读
  4. 华为OD机试 - 文件缓存系统——优先队列解法

    2024-07-23 08:24:05       23 阅读
  5. 计算机网络之数据链路层

    2024-07-23 08:24:05       20 阅读
  6. 今天是闭包,装饰器和案例

    2024-07-23 08:24:05       23 阅读
  7. 【Golang 面试基础题】每日 5 题(三)

    2024-07-23 08:24:05       23 阅读
  8. 【策略模式在项目中的实际应用】

    2024-07-23 08:24:05       22 阅读
  9. 前端设计模式面试题汇总

    2024-07-23 08:24:05       17 阅读