怎么把HAM Maidenhead Grid Squares转换成经度?

时间:2019-06-08 18:15:54

标签: php mysql leaflet coordinates

在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文件。

0 个答案:

没有答案