5. Online map of WebGIS converts URLs of multiple tiles by ranks number

5.1. Preface

In this article, I focus on the OGC standard of WMS, WMTS, and ArcGIS online map services for analysis.

In the field of spatial data interoperability, interoperability method based on public interface access mode is a basic method of operation. Through the International Organization for Standardization (ISO/TC211) or the Technical Alliance (e.g. OGC) to develop spatial data interoperability interface specifications, GIS software vendors develop spatial data reading and writing functions that follow this interface specification, so as to achieve interoperability of heterogeneous spatial databases (from Baidu Encyclopedia).

Currently, the standards developed by OGC are: WMS (Map Service), WMTS (Map Tile Service), WFS (Element Service), WCS (Grid Service).The map requests I’ve described below are all requested under RESTFUL.

5.2. URL of WMS service

WMS services can provide the following services:

GetCapabilities returns service level metadata。

../_images/img_12.png

GetMap returns a map image。

../_images/img_23.png

GetFeatureinfo returns information about some special features displayed on the map, etc.。

../_images/img_32.png

5.2.1. Example

Let’s take a look at the URL example when the WMS service requests a map.:http://172.18.0.154:7001/ServiceRight/proxy/f446aabb04a59af336901290d615e16b/xzcg/WMS/XZ500DLG_BZWGS84?LAYERS=XZ500DLG_BZWGS84&FORMAT=image/gif&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG:4326

&WIDTH=256&HEIGHT=256&bbox=117.21879147492814,34.240704396544345,117.22000975886715,34.24192268048341。

../_images/img_41.png
../_images/img_5.png

Observing this URL, many parameters can be fixed according to the service provided, such as FORMAT, LAYERS, REQUEST, SRS, STYLES, VERSION, WIDTH, HEIHT parameters.What we really need to keep converting is BBOX.

5.2.2. Principle

A WMS request is a dynamic map-out request that, in principle, which shows a map of the original image at any scale, unlike the tile service, and can only display the map under the set scale that was set when the drawing was cut.When we use a secondary development package, such as a development package provided with esri, we only need to set the number of levels that need to be displayed, but not the scale of each level, because WMS is a dynamic map outing service.In secondary development, it is very simple to directly use the provided WMS class,which only need to provide the scope of display and the number of levels to be displayed, the scale of each level will be automatically divided within this class, and WMS is dynamically mapped, so this method can be fully supported.

5.2.3. Note

However, some WMS services provided by service providers are not like this in fact,they are likely to make restrictions on a small scale,so that we can only access tiles in a few fixed scales, other scales can not.That’s the reason, when a Map is loaded on a WMS class based on a FlexViewer framework that has been worked out before for other group colleagues, the map is not displayed at a specific level.The solution to this problem is to re-expand the class so that the extended WMSEX class can convert the corresponding Bbox by setting a scale of each level, and here we got the algorithm of the numbers for use finally.

minX=resolution*tileSize*col;

minY=resolution*tileSize*row;

maxX=resolution*tileSize*(col+1);

maxY=resolution*tileSize*(row +1);

Bbox=“minX,minY,maxX,maxY”;

5.3. WMTS service

The full name of WMTS service is Web Map Tile Service, therefore, Different from the dynamic mapping of the previous WMS, the WMTS service is based on tile ideas.WMTS supports the provision of certain standard services, such as:

GetCapabilities(Get the meta information of the service, in this meta information we can see the detailed configuration of the cut chart)。

../_images/img_6.png

GetTile(Get slice)。

GetFeatureInfo(Optional, get the selected feature information)。

It can be seen that these operations are very similar to the operation of the WMS.

5.3.1. Example

Let’s take a look at the URL example of the request map tile under WMTS,I take the URL in the sky map as an example here.:http://srv.zjditu.cn/ZJEMAP_2D/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=ZJEMAP&FORMAT=image/png&TILEMATRIXSET=TileMatrixSet0&TILEMATRIX=17&STYLE=default&TILEROW=21747&TILECOL=109282

../_images/img_7.jpeg
../_images/img_8.jpeg

Observe the parameters contained in this URL. We can write FORMAT, LAYER, REQUEST, SERVICE, STYLE, and VERSION according to the requirements before acquiring the tiles, the changing ones are TILEMATRIX, TILEROW, and TILECOL.

5.3.2. Principle

The WMTS service is consistent with the tile ideas we have discussed repeatedly, and the observation parameters can also be seen.TILEMATRIX, TILEROW, and TILECOL are actually Level, row, and col.Therefore, the URL of the tile request under the WMTS service can also be spelled out in a logical way: Fixed formatURL+“&TILEMATRIX=”+level+“&TILEROW=”+row+“&TILECOL=”+col。

5.4. URLs in maps published by common map servers - taking AGS services as an example

In AGS, after the service is cut out, the request URL of the map becomes a fixed format,such as:http://172.29.0.74:8399/arcgis/rest/services/HFTile/MapServer/tile/2/957/834。

../_images/img_9.png

 Obviously, after tiles are Level, row, col. So the URL under AGS is: restMapService address / Level / row / col.

5.5. Ask a few questions

Question one:

A map that requires the first few levels of the map is derived from the A service, and its service address is AURL.The middle several levels of the map from the B service, its service address is BURL, the next few other maps are from the C service, its service address is CURL.How do we get the system to be able to map at every level at this time?

Question two:

A map needs to display both the topographic map and the annotation layer, and the topographic map service is derived from the A service, and the annotation layer is derived from the B service. How can I load two services normally and let the annotation layer be superimposed on the topographic map?

Question three:

Or a map that needs to display both topographic and annotation layers, but the topographic map service is a WMTS service and the annotation layer is a WMS service. how do I overlay tiles from two different services?

I will only mention these three questions, this kind of similar problem is particularly much, but I think as long as we know the URL of various services to obtain the principle, plus a little bit of their own problem-solving ideas,which should not be difficult to solve. In future chapters on grid layer (tile layer) design, I’ll give us a way to solve this kind of problem, which is very common.

5.6. Summary

When we talk about this, in the whole series, we have already talked about what the ranks number is, how to get them, and get the tile URL by the numbers. It can be said that we are not far from how to display raster images on the front end.Then In the next chapter, I’ll speed up this.The next section is: The principle of tile display on the front end. Welcome to the continued attention.