webgis原理剖析系列-以openlayers为例 -04 请求地图行列号的计算

首先要了解一些基础知识

1:经纬度所对应的投影坐标范围

Google地图采用的是Web墨卡托投影(如下图),为了方便忽略了两极变形较大的地区,把世界地图做成了一个边长等于赤道周长的正方形(赤道长度为6378137米),原点在正方形中心,即经纬度为(0,0)处。Web墨卡托投影的X,Y坐标取值范围为:[-20037508.3427892,20037508.3427892],对应的经度取值范围为[-180,180],对应的纬度范围则为[-85.05112877980659,85.05112877980659]

在使用ol-debug.js调试可以看到,不指定坐标系,会默认为3857,构造函数会初始化其范围(好像最后几位不太相同)

2 根据屏幕坐标系到地理坐标系的转换 

Level:0, Scale:591657527.591555, Resolution:156543.033928023
Level:1, Scale:295828763.795778, Resolution:78271.5169640117
Level:2, Scale:147914381.897889, Resolution:39135.7584820059
Level:3, Scale:73957190.9489444, Resolution:19567.8792410029
Level:4, Scale:36978595.4744722, Resolution:9783.93962050147
Level:5, Scale:18489297.7372361, Resolution:4891.96981025073
Level:6, Scale:9244648.86861805, Resolution:2445.98490512537
Level:7, Scale:4622324.43430902, Resolution:1222.99245256268
Level:8, Scale:2311162.21715451, Resolution:611.496226281342
Level:9, Scale:1155581.10857726, Resolution:305.748113140671
Level:10, Scale:577790.554288628, Resolution:152.874056570335
Level:11, Scale:288895.277144314, Resolution:76.4370282851677
Level:12, Scale:144447.638572157, Resolution:38.2185141425838
Level:13, Scale:72223.8192860785, Resolution:19.1092570712919
Level:14, Scale:36111.9096430392, Resolution:9.55462853564596
Level:15, Scale:18055.9548215196, Resolution:4.77731426782298
Level:16, Scale:9027.97741075981, Resolution:2.38865713391149
Level:17, Scale:4513.98870537991, Resolution:1.19432856695575
Level:18, Scale:2256.99435268995, Resolution:0.597164283477873
Level:19, Scale:1128.49717634498, Resolution:0.298582141738936

3 以下原理来自于https://www.cnblogs.com/naaoveGIS/p/3899821.html博客。

被困住的主要一点在于切片起始点的设置,当然文中还有很多处理逻辑,本文不细展开,待后续研究。主要涉及瓦片行列号的请求。全部代码及注释如下。




    
    Using Parcel 
    


图片第一次可能会出不来,多刷几次,有知道的朋友欢迎留言

 


 

你可能感兴趣的:(webgis原理剖析系列-以openlayers为例 -04 请求地图行列号的计算)