Show Tile Map

Source: Internet
Author: User
Tags in degrees

Requirement scenario: Give the scale of each level of the tile map, and the window displays the number of tiles required for the map, and the vertex coordinates of each.

GIS concepts that need to be understood:

scale (Scale)

A centimeter on the map represents the actual number of centimeters. For example 1:1,155,583.42 means that 1cm on the map equals the actual 11.5558342km.

Dpi

Every inch of the screen contains pixels, the general screen is to take 96

1 inch = 2.54 CM

1 pixels = 0.0254/96 M (on the map) the true distance is multiplied by the scale.

Map of the individual rate (Resolution)

1 pixels corresponds to how many geographic units, where geographic units depend on the coordinate system of the cut map, usually longitude and latitude

If the geographic coordinate system is WGS84, the map is in degrees and DPI is 96

Conversion formula between scale and resolution

Resolution = 1 pixels corresponding to true meter/1 degree corresponding to real meters

1 pixels Real meter = 0.0254/96 * scale

1 degrees corresponds to real meters = 2 * Math.PI * 6378137/360 approx. 111194.872221777 m

The origin of the map transduction is latitude ( -180,90), the tile size of the map is tilesize, given the center point latitude and longitude (lonx,laty) to display,

Calculates the tile range and the fixed-point coordinates that need to be displayed in the windows of Wscreen and Hscreen.

        DoubleTilesize = Pgis_tile_width * presolution;//Tile Geographic Length        DoubleWINDOWW = Wscreen * presolution;//Window Geography Length        DoubleWINDOWH = Hscreen *presolution;//top left corner of window geographic offset        DoubleWINDOWOFFSETW = wscreen/2*presolution; DoubleWindowoffseth = hscreen/2*presolution; //the geographic coordinates in the upper-left corner (this calculates the assumption that the center point of the window coincides with the center point of the displayed map)        DoubleLEFTW = CENLON-WINDOWOFFSETW;//The smaller the longitude to the left        DoubleLefth = (Cenlat + windowoffseth);//the higher the latitude, the greater the//Step1: The first tile of the row number,PFIRSTW = Floor ((Leftw-maporix)/tilesize);//The longitude to the right is larger, so it is the end longitude minusPfirsth = Floor ((maporiy-lefth)/tilesize);//The downward latitude becomes smaller, so it is the starting latitude minus//the number of tiles that can be displayed in the window rangeWcount = Ceil (windoww/tilesize) +1; Hcount= Ceil (windowh/tilesize) +1; //Step2: The last tile row numberPENDH = pfirsth + Hcount-1; PENDW= PFIRSTW + Wcount-1 ; //the pixel coordinates of the upper-left corner of the window (this is the map cutting origin is 0,0)        DoublePixx = (Leftw-maporix)/presolution; DoublePixy = (maporiy-lefth)/presolution; //Step3: The top left corner of the first tile photo offset (the pixel coordinates of the upper-left corner of the window are 0,0)Leftxtopdifftoctrl = PIXX-PFIRSTW *Pgis_tile_width; Leftytopdifftoctrl= Pixy-pfirsth * Pgis_tile_height;

At this point, we can calculate the pixel coordinates of each tile in the window coordinate system to complete the map display. The operation of the user to pan the map is to change the latitude and longitude coordinates of the center point of the map, recalculate the row number of tiles to be displayed, and the pixel coordinate value of the top left corner of the first tile relative to the window.

Reference Links:

Http://www.thinkgis.cn/topic/541a5206da8db186fd0673ba

Show Tile Map

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.