地图瓦片
栅格瓦片
瓦片分级
坐标起点与方向
- 左上角为坐标起点;
- 右下为正方向;
瓦片数量;
行列号与经纬度的转换公式
const lonLat2ColRow = (lon: number, lat: number, zoom: number) => {
const size = 2 ** zoom;
const col = Math.floor(((lon + 180) / 360) * size);
const row = Math.floor(
((1 - Math.asinh(Math.tan((lat * Math.PI) / 180)) / Math.PI) * size) / 2
);
return [col, row];
};
const ColRow2LonLat = (col: number, row: number, zoom: number) => {
const size = 2 ** zoom;
const lon = (col / size) * 360 - 180;
const lat =
Math.atan(Math.sinh(Math.PI * (1 - (2 * row) / size))) * (180 / Math.PI);
return [lon, lat];
};
mbtile
mbtile
- mapbox 创建的存储栅格瓦片的数据格式;
- 使用 sqlite 数据库;
相关库
- mbtile 的导入和导出:mbutil;