Exploring the essence, how the browser displays the map scale conversion Principle

Source: Internet
Author: User
1. What should I do if there is no soybean milk machine?

Drinking soy milk is a must-have for us in the morning. If I ask you how soy milk came from, people who don't know about grain will say they bought it with money. People who know about soy beans will say they use soya milk machines to grind soy beans out. If we go backwards for more than a decade, I believe that people who have picked up soy milk to sell soy milk will give a more detailed answer. First, let's soak soy beans in water for one night, and then trash them in the utensils, the soy milk is made after being boiled in the fire and stirred until the foam disappears.

Many people will be surprised to hear this answer. It is so troublesome that it is easy to use a soya-bean milk machine. Now I have a question: if the power is down, if the soya-bean milk machine is broken, if you have no money to buy a soya-bean milk machine, can you make soy milk by yourself? Do you have to buy others' soy milk?

2. What if there is no secondary development kit?

If I compare the existing map data to soy bean, I would like to ask you a question. If our project does not provide genuine runtime or AGS topographic map services due to funding issues, so how can we make the Browser display topographic maps? Of course, some people will point out a complete set of open-source solutions, such as using geoserver.

If I ask you again, if one day we met a strange owner, it told you that we only want the map to be displayed at the level, and we only want the map to display a certain area, there are too many elements, so we hope to dynamically load elements within the visible range when dragging a map, and so on. If you are a person who only knows how to use a soya-bean milk machine, how do you solve these problems?

Secondary Development is not limited to a certain degree. mxd is loaded at c/s, and a map is written at B/S to a topographic map service URL. He must also understand how to change a server-side tile into a complete map in a browser.

Here I will spend several consecutive sections to answer this question one by one.

3. Scale and resolution in the map scale

I have mentioned a lot of things in this section before. Now, let's get back to the point where we start the first question in this series, the principle of map scale conversion. To display tiles at the underlying layer, we must first understand the tiles themselves.

After using ArcGIS to cut the chart, open the published service or open the config. xml configuration file. You can see the related configuration of the cut chart. :

 

Levels is the scale parameter of the cut chart. Each layer level contains a resolution parameter and a scale parameter.

Scale indicates the scale, that is, the 1 cm on the map represents the actual centimeter. For example, on a map, "1 cm" indicates that the field distance is 500 km, which can be written as or "50,000,000, 1/50.

Resolution indicates the resolution. The actual meaning of resolution indicates the map unit (x map unit/pixel) in the current map range. The map unit depends on the spatial reference of the data. It can be seen that the resolution has a relationship with DPI (DPI indicates the number of pixels per inch) and the map unit.

4. row and column number-ID of the tile storage address

Here, we will introduce the topic number in GIS. As I can imagine, a map of a rectangle is divided into multiple rectangles of the same size according to certain rules (based on the cut graph origin, cut graph range, and tile size, in this case, the position of the rectangle can be represented by row and Col. Of course, if we understand the concept of the image pyramid, we need to add a level (image level) to the front. The common point is the layer in which the rectangle you cut belongs to the entire image.

Here, let's take a look at the storage path of the tiles after the map is cut. I use the discrete tile (exploded) as an example:

Here, l06 indicates the level of the map where the tile is located, r00001179d indicates the row number of the tile, and c0000a24e indicates the column number of the tile. How are these numbers calculated? Let me keep the following chapters to explain them one by one.

But here I can tell you responsibly that if you want to know how to convert the row and column numbers, you must know the answer to the following question.

What is the actual distance between one pixel on the screen?

5. What is the actual distance represented by one pixel on the screen?

Before calculating the row and column numbers of a tile, we need to obtain the number of meters from which the pixel in the figure represents the actual distance. Assume that the coordinate unit of the map is meter and DPI is 96;
1 inch = 2.54 cm;
1 inch = 96 pixels;
The final conversion unit is meter;
If the current map scale is, it indicates that 1 meter is equal to 125000000 meters;
The conversion formula between meters and pixels:
1 inch = 0.0254 meters = 96 pixels
1 pixel = 0.0254/96 meters
Then, based on the scale, 1 pixel indicates that the field distance is 125000000*0.0254/96 = 33072.9166666667.

6. scale in the flat coordinate system and the latitude and longitude Coordinate System: 6.1 scale in the flat Coordinate System

When the database is a flat coordinate system, the scale required in the system should be obtained from scale. Because the actual unit in the original scale is centimeter and the unit in our system is meter, we will divide the scale by one hundred when entering the map scale. As described in section 2, we can calculate in the system how many meters 1 pixel represents.

6.2 scale in latitude and longitude Coordinate System

When the database is a coordinate system of longitude and latitude, the scale required in the system should be obtained from resolution. At this time, the resolution directly represents the number of degrees in which the pixel on the map is equal to the actual value.

However, because the Code already has a conversion algorithm described in section 2, you need to reverse convert the algorithm before entering the scale in the database.

That is, resolution * 96/inch2centimeter

7. Problems Caused by inch to centimeter

The International parameter for inch to centimeter conversion is: 2.5399998. This parameter value can be used when map world or other third-party non-AGS are used.

However, this parameter is changed to 2.54000508001016 when the image is switched by AGS. This may be a conversion parameter defined internally by AGS.

According to different parameters, when we convert the scale under the coordinate system of longitude and latitude, we need to convert it according to different parameters. When it is a AGS map, it is: resolution * 96/2. 54000508001016.

8. Summary

After learning how one pixel represents the actual distance on the screen, we can go to the next chapter-calculate the row and column numbers of tiles based on geographical ranges.

Please stay tuned. I will try to update every one or two weeks. If you are busy, the update may be delayed. I will write 20 to 25 articles in this series, which involve the principles, design, and implementation knowledge. There may be many mistakes, forgive me for being a new person who has only taken a small step in the GIS field. Forgive me for being stupid in my qualifications. Let me take the liberty to sum up the achievements of my predecessors and combine my thoughts and thoughts, share with you.

 

--------- You are welcome to reprint it. Please indicate the source

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.