Google Maps tile to Baidu map tile

Source: Internet
Author: User

4 The number of groups is from the 1-18 level of the corresponding, such as the discovery of conversion corresponding to the corresponding can be modified by the X, y number, this set of code corresponding to Sichuan Ganzi region.

 PackageCom.ly.baidu.tools;ImportJava.io.File; Public classGoogletobaidu {Static int[] Baidux = {0, 0, 1, 3, 6, 12, 24, 49, 98, 197, 395, 790, 1581,            3163, 6327, 12654, 25308, 50617 }; Static int[] Baiduy = {0, 0, 0, 1, 2, 4, 9, 18, 36, 73, 147, 294, 589,            1178, 2356, 4712, 9425, 18851 }; Static int[] GoogleX = {0, 1, 3, 7, 13, 26, 52, 106, 212, 425, 851, 1702,            3405, 6811, 13623, 27246, 54492, 107917 }; Static int[] Googley = {0, 0, 1, 2, 5, 12, 23, 47, 95, 190, 380, 761,            1522, 3045, 6091, 12183, 24366, 47261 };  Public Static voidMain (string[] args) { for(intZoom = 1; Zoom < 18; zoom++) {            //Film Tile ConversionFile dir =NewFile ("Satellite" +file.separator + (zoom-1));            Execute (dir,zoom); //Road Layer Tile conversionFile Dir2 =NewFile ("overlay" +file.separator + (zoom-1));            Execute (dir2,zoom); System.out.println ("Current Execute zoom:" +zoom); }    }    /*** Convert tiles *@paramdir *@paramZoom*/    Private Static voidExecute (File dir,intzoom) {        if(Dir.isdirectory ()) {file[] xfs=Dir.listfiles ();  for(inti = 0; i < xfs.length; i++) {File XF=Xfs[i]; if(Xf.isdirectory ()) {file[] Yfs= Xf.listfiles ();//The y-axis is a tile file, replace the file and replace the folder first                     for(intj = 0; J < Yfs.length; J + +) {File YF=Yfs[j]; String Yname=Yf.getname (); String Path=yf.getparent (); String FileType= Yname.replaceall ("\\d", "" "); if(Yf.isfile ()&& yname.matches ("^\\d+\\. ( png|jpg) {1}$ ")) {//only files with PNG and JPG suffixes are replaced                            intNewy =Googletobaiduy (integer.valueof (yname. ReplaceAll ("\\d", "" ") ), zoom); File ynew=NewFile (path +File.separator+ Newy +FileType); Yf.renameto (ynew);//System.out.println (Yname + "to"//+ ynew.getname ());                        }                    }                    intNX =Googletobaidux (integer.valueof (Xf.getname ()), zoom); File newx=NewFile (xf.getparent () +File.separator+NX); Xf.renameto (NEWX);//The X-axis is a folder//System.out.println (Xf.getname () + "to" +newx.getname ());                }            }        }    }    Private Static intGoogletobaidux (intXintz) {intb = baidux[z-1];//395        intg = googlex[z-1];//11:843,12:1685//int GX = g + (x-b);//---1587+        intGX = x-g + b;//---1587+//Google tile row number =[Google Reference tile row number + (Baidu line number – Baidu reference tile row number)]        returnGX; }    Private Static intGoogletobaiduy (intYintz) {intb = baiduy[z-1];//147        intg = googley[z-1];//Ten://int gy = G-(y-b);//        intGY = g + b-y;//        //Google tile column number =[Google reference tile column number-(Baidu column number – Baidu reference Tile column number)]//up, column descending        returnGy; }}

Google Maps tile to Baidu map tile

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.