经纬度坐标 \((\text{lon}, \text{lat})\) 转瓦片坐标 \((\text{tileX}, \text{tileY})\) 推导过程:3.2 百度XYZ转换
- 将经纬度坐标 \((\text{lon}, \text{lat})\) 转换为Web墨卡托投影地图中的坐标(\(x'\)以角度为单位,\(y'\)以弧度为单位):
- \(x' = \text{lon}\)
- \(\displaystyle y' = \ln(\tan{(\frac{\text{lat}\times \pi}{180})} + sec{(\frac{\text{lat}\times \pi}{180})})\)
- 将Web墨卡托投影地图中的坐标原点变换到左上角,并改变 Y 轴方向(\(x'\)以角度为单位,\(y'\)以弧度为单位):
- \(x'' = x' + 180\)
- \(y'' = -(y' - \pi) = \pi - y'\)
- 转为瓦片坐标
- \(\displaystyle x = \lfloor \frac{x''}{360} \times 2^Z \rfloor = \lfloor \frac{\text{lon} + 180}{360} \times 2^Z \rfloor\)
- \(\displaystyle y = \lfloor \frac{y''}{2\pi} \times 2^Z \rfloor = \lfloor (\frac{1}{2} - \frac{\ln(\tan{(\frac{\text{lat}\times \pi}{180})} + sec{(\frac{\text{lat}\times \pi}{180})})}{2\pi}) \times 2^Z \rfloor\)
欢迎光临 IT评测·应用市场-qidao123.com (https://dis.qidao123.com/) | Powered by Discuz! X3.4 |