Today I have studied scale and resolution in openlayers and learned something I didn't know before.
I. First, I will clarify several concepts: 1. Scale: Scale, ratio of distance on the graph to distance on the field. 2. Resolution: resolution. Each pixel represents the field distance (MAP units per pixels ). 3. Extent: MAP range (four ). 4. zoomlevel: zoomlevel (0 ~ 15 ). Note: These variables are quantitative descriptions of "Map Display", so they have the largest and minimum values. 5. Map and baselayer: map. The size of the map determines the display. Baselayer is equivalent to the basemap in a map. Many scale conversion functions are implemented in the baselayer class. Therefore, baselayer must be added to the map. To correctly display a map in openlayers, the preceding variables must be correctly set, but not all are set. If the calculation is incorrect, a conflict may occur. You can select the setting part, and the rest are automatically calculated by openlayers. Ii. Conversion between scale and resolution. According to the concept in openlayers, the ratio is relatively good. For example, the ratio of the actual map width (or height) to the map Div (in pixels) is directly obtained, the resolution at this zoom level is obtained. Assume that the unit of the map is meters and the resolution under a scaling Level L is R. How can we get the scale of the scaling Level L? Scale is the ratio of the distance on the map to the distance on the field. Now we have some map
Screen distance (in pixels), field distance and resolutionObviously, we only need to get
Distance on the graphYou can. How can the problem be transformed from
Screen distance + resolution, calculate the distance on the Image. The key to solving the problem is DPI, Dots Per inches, or pixels per inches. Openlayers assumes that all the map images it receives are 72 dpi, that is, 72 pixels have a length of 1 inch, that is, 72 pixels in the map image on the screen are 1 inch in length. Now we have a clue about the problem. The screen distance (in pixels) is converted to the graph distance through the 72dpi value. Assume that the screen distance is P and the resolution is R, then the scale S is: Field distance: distance on the R * P graph: (P/72)/39.3701 = P/(72*39.3701) scale: S = P/(72*39.3701)/R * p = 1/R * 72*32.3701
39.3701 is the correspondence between inches and meters.. The openlayers exclusive object defines such a ing to obtain an approximate scale for maps of different projection units. Openlayers. inches_per_unit = {'inces': 1.0, 'ft ': 12.0, 'mi': 63360.0,
'M': 39.3701,'Km ': 39370.1, 'dd': 4374754, 'yd': 36}; openlayers also has this definition: openlayers. dots_per_inch = 72; DPI mentioned earlier. Of course, the resolution from the scale Inverse calculation is also very simple, the key is to know the unit, units. I don't quite understand what I'm talking about. Maybe I just understand scale and resolution. I also have some fuzzy relationships between zoom, zoomlevel, exten, scale, and resolution. I want to learn more. If you want to know something, you can check the source code here, or you can directly study the openlayers source code, which will be more rewarding.
--------------------------------
Learning, more patient