php - 如何将 HAM Maidenhead Grid Squares 转换为经纬度?
问题描述
在 mySQL 数据库中,我有 HAM 方形格式的点坐标(例如KO03ka
)。使用此代码,我得到地理坐标:
// fe user_loc = "KO03ka"
$loc = $user_data['user_loc'];
$lat=
(ord(substr($loc, 1, 1))-65) * 10 - 90 +
(ord(substr($loc, 3, 1))-48) +
(ord(substr($loc, 5, 1))-65) / 24 + 1/48;
$lng=
(ord(substr($loc, 0, 1))-65) * 20 - 180 +
(ord(substr($loc, 2, 1))-48) * 2 +
(ord(substr($loc, 4, 1))-65) / 12 + 1/24;
我想使用添加点到地图上print json_encode()
。如何正确准备 JSON 文件?在数据库中,我没有 lat、lng,只有方形定位器格式。
$query = mysql_query("select * from maps");
$rows = array();
while($data = mysql_fetch_array($query))
{
$rows[] = $data;
}
print json_encode($rows);
$db = NULL;
请帮我为 Leaflet 准备 JSON 文件。
解决方案
推荐阅读
- node.js - 在 Node.js Express 中禁用 TLS 1.0 和 1.1 或仅使用 TLS 1.2 及更高版本
- javascript - React - 向下滚动页面时缩小导航图像
- java - 为我的所有 REST 控制器方法请求添加 @Around 建议后,不要返回任何 JSON 数据
- javascript - 为什么当 AST 已经知道该值时此代码返回 undefined
- mysql - MySQL ORDER BY 和 LIMIT 与存储过程中的变量
- go - 如何从 Cloud Run 访问其他 GCP 服务
- visual-studio-code - 查找并替换所有不在引号中的匹配项
- windows - 远程检索 Windows Defender 状态
- javascript - 使用 JavaScript 更新测验跟踪器答案 DIV
- python - 填充字典的输出与代码块中的打印语句不同