在ArcMap或各種前端地圖框架(Leaflet.js、OpenLayers.js、ArcGIS Javascript等)中都須要加載WMTS或ArcGIS Rest服務,但全部的地圖顯示的原理基本上都是經過座標和每張瓦片的分辨率來計算行列號的,但WMTS服務標準中實際上是沒有分辨率Resolution這個參數的,他只給出了比例尺「ScaleDenominator」這個值,須要用戶根據這個比例尺本身計算出分辨率。(參考下圖,爲同一個瓦片服務的Rest服務和WMTS服務)html
REST:http://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer前端
但在ArcGIS Rest服務中你會發現服務的Lod信息裏是同時給出了比例尺「Scale」和分辨率「Resolution」值了的。有心讀者讀到這裏和看到下面的圖片時,應該會有兩個疑惑。框架
1、Scale和 Resolution的計算公示this
案例一:若是地圖的座標單位是米,dpi爲96.net
參考: https://blog.csdn.net/redsky200905/article/details/84369213unix
1英寸=2.54釐米;rest
1英寸=96像素;server
最終換算的單位是米;xml
若是當前地圖比例尺爲1:125000000,則表明圖上1米實地125000000米;
米和像素間的換算公式:
1英寸=0.0254米=96像素
1像素=0.0254/96 米
則根據1:125000000比例尺,圖上1像素表明實地距離是 125000000*0.0254/96 = 33072.9166666667米。
以上圖第0級爲例,比例尺爲 Scale=591657527.591555,Resolution=156543.03392800014
591657527.591555*0.0254/96 =156,542.7208419323
591657527.591555*0.0254000508/96 =156,543.0339273739
咱們這個換算結果和切片的結果略微有0.07米的偏差。這個偏差產生的緣由是英寸換算釐米的參數決定的,server使用的換算參數1英寸約等於0.0254000508米。
關於1英寸單位換算有如下文獻說明
參考:http://scienceworld.wolfram.com/physics/Inch.html
An nonmetric unit of length, originally defined as the lengths of three "average size" barleycorns laid end-to-end, but now more rationally defined as 2.54 cm. An older definition no longer used was 1 meter= 39.37 inches, giving 2.54000508 cm/inch.
12 inches are called 1 foot.
案例二:若是地理座標系是wgs84,地圖的單位是度,dpi爲96
Server中度和米之間的換算參數: 1 度約等於 111194.872221777 米
接下來就須要進行度和像素間的換算:
當比例尺爲1:64000000米時,至關於1像素 = 64000000*0.0254000508/96 = 16933.3672米,再將米轉換爲度 16933.3672/ 111194.872221777 = 0.1522855043731385 度
所以當地圖單位爲度時,近似計算在1:64000000 對應的Resolution爲0.1522855043731385度。
2、WMTS服務中的Scale和ArcGIS Rest服務中不同的緣由
最核心的緣由是由於DPI計算方式不同!!!
WMTS assumes a DPI 90.7 instead of 96 as is clearly documented in the WMTSCapabilities document which states,
"The tile matrix set that has scale values calculated based on the dpi defined by OGC specification (dpi assumes 0.28mm as the physical distance of a pixel)."
0.28 mm per pixel = 0.0110236 inches per pixel or 90.71446714322 pixels per inch.
If you replace 96 in the equation above with 90.71428571429 you'll get the ScaleDenominator value so ESRI used a different conversion constant. After a little research I learned that
1 in = 2.54 cm (I thought this was an approximation but it's by definition)
Since there are 25.4 mm in one inch then 25.4 / .28 = 90.71428571429 DPI which is the value we're after for DPI. Here is a site which confirms this calculation.
繼續以第一圖爲例:
559082264.0285016 * 0.00028 = 156,543.0339279804,這樣計算的結果就和ArcGIS Rest中的差很少保持一致了。
參考文獻: