arcgis切图与tilecache切图的区别及openlayers的代码实现

1.命名方法不同
arcgis的命名为
缩放等级表示:L+两位十六进制
行表示:R+8位十六进制
列表示:C+8位十六进制
如:L02/R00000003/C00000004.png
tilecache的命名为:
它的缩放等级、行号、列号都是十进制数字表示
如:2/3/4.png
2.切图的起始坐标不同
arcgis的起始坐标为左上角的点

tilecache的起始坐标为右上角的点

3.openlayer 调用arcgis的切片的关键代码

var test=new OpenLayers.Layer.TMS(
            “ditu”,
          “”,
          {
              layerName: ‘qgm’, type: “png”, ‘getURL’: function (bounds) {

              var res = map.getResolution();
        
               var bbox = this.map.getMaxExtent();
               var size = this.tileSize;

        
               var tileX = Math.round((bounds.left – bbox.left) / (res * size.w));
              var tileY = Math.round((bbox.top-bounds.top) / (res * size.h));
                        
              var tileZ = this.map.zoom;    
        
             if(tileZ == 3 && tileX > (Math.pow(2, tileZ) – 1)){
                   tileX = tileX-Math.pow(2, tileZ);                    
             }
        
        if(tileX < 0){tileX = tileX + Math.round(bbox.getWidth() / bounds.getWidth());}       
        if(tileY < 0){tileY = tileY + Math.round(bbox.getHeight() / bounds.getHeight());}   

              return “Layers/_alllayers/L” + convert16(2,z) + “/R” + convert16(8,y) + “/C” +convert16(8,x) + “.png”;
              */
                  return “Layers/_alllayers/L” + convert16(2,tileZ) + “/R” + convert16(8,tileY) + “/C” +convert16(8,tileX) + “.png”;
              }
          }
      );

function convert16(length,value){
var v=Math.abs(value);
var s=v.toString(16);
var len=length-s.length;
var tmp=””;
for(var i=0;i<len;i++){
tmp+=”0″;
}
return tmp+s;
}

4.openlayers调用tilecache切片的关键代码

var test=new OpenLayers.Layer.TMS(
            quanguoditu,
          “”,
          {
              layerName: ‘qgm’, type: “png”, ‘getURL’: function (bounds) {

              var res = map.getResolution();
              var x = Math.round((bounds.left – map.maxExtent.left) / (res * 256));
              var y = Math.round((bounds.bottom – map.maxExtent.bottom) / (res * 256)); //从下面往上计算
              var z = this.map.getZoom();
              return CACHETMSURL + z + “/” + x + “/” + y + “.png”;
              }
          }
      );

   
在此感谢网友“GIS-xyz”和“赵钊烽”给予的代码支持。

转载自:https://blog.csdn.net/forgetive/article/details/8212910

You may also like...