One of the most interesting features of Geoserver is its ability to manage a map server. In this article we will explain how to take full advantage of this feature.
Reminder of the tiling concept
In the following image you can observe the two different operating methods for a map server.
- a client application creates a query to display a map. The server receives the query
- the server proceeds to retrieve the required data from a database holding the different geographical layers to generate the map
- the result is properly shaped to layout the map requested
- the map is sent to the client application to be posted
Everytime a query is placed, the server must query the database and formatting the data retrieved.
The right image shows how a map server with the feature « tiling » activated works:
- a client application creates a query to display a map
- the server receives the query according to the area of the requested map, the server selects the already calculated images from the server cache corresponding to the area and zoom level requested
- the images are transmitted to the client application to be displayed
The retrieval and formatting has taken place beforehand and just once.. When using this second configuration, only a simple calculation is needed to determine which images must be retrieved to the client application. This configuration is time and resource sensitive. A map is created in accordance with a formatting symbology, finally the image is cut in equal size tiles. This task has to be done just once.
Each tile represents the formatted data and can be « served » very quickly. However, the only possible outcome is the display, it is not possible neither to access the underlying data nor to modify their format.
On the other hand, if you zoom in the tile, the pixellisation will increase very quickly. In order to solve this problem,you must create various maps, using different zoom levels. Each map is divided in tiles. At the time of receiving a query, the corresponding zoom level is calculated and the tiles pertaining to that level will aree used.
Typically you usie 4 tiles at a time. The most detailed layer is divided in tiles, generally 256×256 pixels. The underlying layer formed by 2×2 tiles is calculated (when using 4 tiles of 256×256 pixels or more, just one tile is calculated). And so forth till the level where only one tile is found.
This set of layers is called a pyramid.
Raster and Vector tiles.
Up to this moment we have been discussing a map server with images (raster). Even if the data from the database is vector data (Streets, buildings, parcs, etc) the final result is applied to the vector layers to generate a raster image, i.e., the outcome of the query.
This type of service is called WMS (Web map service).
Presently a new type of service has been developed. It allows to supply the data as tiles, the so called WMTS (Web map tile service).This service is included in gGeoserver to supply the data tiles as vector tiles.
The principle is the same used for the raster tiles :
The tiles creation process is the same whether they are raster or vector tiles.
Almost always this data is the vector data (point, line, polygon).
This is the data matching the entire available space, not just one tile.
The second step refers to the so-called « generalization ».
The third step is the creation of a file to translate the grid system used by the tiling into a system of coordinates. Geoserver uses grid sets or grid subsets. GeoWebCache does not recognize the referencing system. Since GeoWebCache sends a request to WMS, it uses the information grid set and subset to transform its internal tile index into a spatial request accessible for the WMS.
The fourth step is a second type of generalization, but, instead of simplifying the geometries by reducing the number of points, it removes the features which are too small or superfluous.
The step before last is the tile clipping. We haven’t yet applied the formatting. If we retrieve the exact required zone for each tile we could be missing the objects right on the joint of the tiles, as shown in the figure below.Geoserver uses a technique that reclaims a slightly larger zone than the demanded for the tile. This avoids those elements on the edges.
Finally we retrieve the formatted entitities depicting the symbology defined in one SLD file:
Raster and vector tiles
According to the OGC standards there are three types of services
- WMS-Maps supply system
- WMTS-Tiles supply system
- WFS-Data supply system
The raster or vector tiles are supplied by the same service, the WMTS.
Even if both types of data are supplied by similar methods, there are some differences.
In comparison to the raster tiles, the vector tiles are formatted by the client instead of the server. For example, when using the OpenLayers app, you will only have the chance to display the raster tiles with their original form, while when using the vector tiles you will have total freedom to choose the symbols.
One tiling alone can produce different maps. It must be added that, compared with the raster tiles, the vector tiles show an increased yield for the High resolution screens.
As for the disadvantages, the use of raster tiles is easier than the vector tiles. In order to work with vector tiles you must have a deeper knowledge.
You can conclude that it is more interesting to use the vector tiles service instead of the classic WFS.
Both can return vector data without formatting, but the WFS returns the underlying data UNMODIFIED, while the WMTS returns the underlying data MODIFIED : ready to be posted.
In the first case you have access to all the attributes of the entities, while in the second case you only have the attributes defined in the SLD file of the tiling.
In the next article we will discuss how to set up the raster and vector service using Geoserver.