Openlayer the calculation formula for reading three types of local tiles _gis

Source: Internet
Author: User
Tags abs pow

1.arcgis Server tile Calculation formula and Geturl method:

Geturl:function (bounds) {
var lon1=bounds.left;
var lat1=bounds.top;
var lon2=bounds.right;
var Lat2=bounds.bottom;
var picheight=256; Picture size
var Picresolution,picrow,piccol; Resolution, picture line number, column number
var tileoriginx,tileoriginy; Chettu Original Point
var iresolution = this.map.getResolution ();
var temp1=new Array ();
var I,zoom=0,path; Zoom represents the zoom level;

Tileoriginx=this.tileorigin.lon;

Tileoriginy=this.tileorigin.lat;

Calculate zoom
Zoom=this.map.getzoom ();

Get the row number (using the center point of the tile to calculate the latitude and longitude)
Picrow=math.ceil (Math.Abs (tileoriginy-(LAT1+LAT2)/2)/(Iresolution*picheight))-1;

Piccol=math.ceil (Math.Abs (tileoriginx-(Lon1+lon2)/2)/(Iresolution*picheight))-1;

Calculates tile path, converts rank and column decimal to hexadecimal
Zoom=zoom.tostring (16);
Picrow=picrow.tostring (16);
Piccol=piccol.tostring (16);
var zoomtemp= "+zoom.tostring" ();
var picrowtemp= "00000000" +picrow.tostring ();
var piccoltemp= "00000000" +piccol.tostring ();
Zoom= "L" +zoomtemp.substring (zoom.length,zoom.length+2);
picrow= "R" +picrowtemp.substring (picrow.length,picrow.length+8);
Piccol= "C" +piccoltemp.substring (piccol.length,piccol.length+8);
path=this.url+ "+zoom+"/"+picrow+"/"+piccol+". jpg ";
alert (path);
return path;
},//end function

The Geturl method of 2.google tiles:

Geturl:function (bounds) {
var x = Math.Round (Math.pow (2,this.map.getzoom ()) * (bounds.left+180)/360);
x = Math.Round (x);
var y = Math.Round (Math.pow (2,this.map.getzoom ()-1) * (90-bounds.top)/180+math.pow (2,this.map.getzoom ()-2));
var z = this.map.getZoom ();
Return ". /.. /googlemap/m_ "+z+" _ "+x+" _ "+y+". png ";

},

3. Geturl method of the day map tile:

Geturl:function (bounds) {
var lon1=bounds.left;
var lat1=bounds.top;
var lon2=bounds.right;
var Lat2=bounds.bottom;
var picheight=256; Picture size
var Picresolution,picrow,piccol; Resolution, picture line number, column number
var tileoriginx,tileoriginy; Chettu Original Point
var iresolution = this.map.getResolution ();
var temp1=new Array ();
var I,zoom=0,path; Zoom represents the zoom level;

tileoriginx=-180;
tileoriginy=90;
Calculate zoom
Zoom=this.map.getzoom ();

Calculate the row number (using the center point latitude and longitude of the tile)
Picrow=math.ceil (Math.Abs (tileoriginy-(LAT1+LAT2)/2)/(Iresolution*picheight))-1;
Piccol=math.ceil (Math.Abs (tileoriginx-(Lon1+lon2)/2)/(Iresolution*picheight))-1;
Path= ". /.. /china/"+zoom+"/"+picrow+"/"+piccol+". png "
alert (path);
return path;
},//end function

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.