openlayers加载低版本arcgis server发布的wmts无法加载/加载偏移问题
openlayer加载常规ogc标准的wmts往往只需要指定默认的resolutions和matrixIds即可
resolutions = [
0.703125, 0.3515625, 0.17578125, 0.087890625, 0.0439453125, 0.02197265625,
0.010986328125, 0.0054931640625, 0.00274658203125, 0.001373291015625,
0.0006866455078125, 3.4332275390625e-4, 1.71661376953125e-4,
8.58306884765625e-5, 4.291534423828125e-5, 2.145767211914063e-5,
1.072883605957031e-5, 5.364418029785156e-6, 2.682209014892578e-6,
];
for (let z = 0; z < 14; ++z) {
// generate resolutions and matrixIds arrays for this WMTS
// resolutions[z] = size / Math.pow(2, z);
matrixIds[z] = z;
}
但是在加载某些特殊的图层时,会遇到使用默认参数无法加载的情况,这时我们需要通过GetCapabilities获取xml文档查看图层信息,如下图所示:
某些图层每一级别都有自定义的比例尺信息,我们用默认的resolutions肯定加载不出来,这时我们需要根据ScaleDenominator(比例尺分母)去计算对应级别下的resolution.
const DPI = 90.7142857142857
const inch = 0.0254
const degree2MeterParams = 111319.49
const projection = getProjection('EPSG:4326');
const projectionExtent = projection.getExtent();
const size = getWidth(projectionExtent) / 256;
let resolutions = [];
const matrixIds = [];
for (let z = 0; z < options.scaleDenominators.length; ++z) {
// generate resolutions and matrixIds arrays for this WMTS
const meter = options.scaleDenominators[z] * inch / DPI;
resolutions[z] = meter / degree2MeterParams;
matrixIds[z] = z;
}
注意其中的degree2MeterParams 变量,arcgis10.4以下的版本使用的度转米参数是111194.65,而标准的WMTS使用的参数是111319.49,如果使用arcgis的参数会导致与天地图叠加偏移
以上就是关于openlayer加载arcgis wmts相关问题的记录了.
参考文章:
- https://blog.youkuaiyun.com/supermapsupport/article/details/122069280
- https://blog.youkuaiyun.com/chijingjing/article/details/105486393
- https://www.cnblogs.com/oloroso/p/14156002.html
- https://blog.youkuaiyun.com/nj198624/article/details/8172559