geoserver releases vector tile service theory and practice

Geoserver has already shared the previous articles of vector data service, but in actual business, the vector data shp file is sometimes relatively large, containing millions of points. After the complete service is released, sometimes the front-end display is still a little bit Slow, after all, it is loaded once; and the front end needs different styles to render a map, without pre-configuring the style on the server side (such as GeoServer); based on this, we can slice the vector data, and the front end calls frequently , getting a small amount of data each time.

Table of contents

1. Operation process

 2. Theoretical support


1. Operation process

First of all, you need to understand that GeoServer can generate vector tiles in three formats: GeoJSON, TopoJSON, MapBox Vector (MVT). These vector tile formats are also supported by OpenLayers and other client-side map engines.

1. Install the vector slice plugin

Official website download address: slice download

Just click to download. 

After decompression it shows:

 Note: The version of this plugin and the version of geoserver must be consistent!

2. Import jar

Copy the downloaded four jar packages to the WEB-INF/lib folder of GeoServer, namely:

apache-tomcat-7.0.72\webapps\geoserver\WEB-INF\lib

3. Verify before reboot

Click on any layer to view:

There are currently no options related to aspect plugins.

4. Verify after reboot

Also click on any layer to view

 It is found that the installed slice plugin has taken effect

5. Publish vector tiles

Click on the slice layer

Enter the layer list and find the layer to be sliced:

Click, then add four slice-related options

 Then click Save to return to the list:

It is found that the drop-down box has become wider, click to view:

 It is found that the tile cache has been generated. For example, select the WFS-geojson option (wfs can be edited), that is, the vector format, which cannot be edited, and the vector slice is an optimized format for reading and rendering. If you want to edit elements on the client side, the most suitable is to use OGC's WFS service , click:

Browser request address:

http://127.0.0.1:8080/geoserver/nandaoVeloc/gwc/demo/nandaoVeloc:Veloc_201809_202102?gridSet=EPSG:4326&format=application/json;type=geojson

F12 to view the calling situation:

 View parameters:

 return data:

Note: When wfs is loaded in openlayer, the loaded elements have their own attributes and can be obtained directly.

Select the fourth .pdf to try, it is in mapbox format, that is (.mvt): the picture is displayed normally

The browser address has changed:

http://127.0.0.1:8080/geoserver/nandaoVeloc/gwc/demo/nandaoVeloc:Veloc_201809_202102?gridSet=EPSG:4326&format=application/vnd.mapbox-vector-tile
That is, the parameters have changed:

The return value is binary:

 Based on this front end, you can configure the parameters to request the back end, put it in or shrink the layer, or click on the picture, it will check whether there is data content according to the position of the click, if there is a returned url, and then go to the back end request according to the url to return the content Attributes of the clicked element.

Note: wms and vector tiles cannot be edited.

vector effect contrast effect

 2. Theoretical support

1. Features of vector slices

advantage:

  • Data is rendered on the client side (for example, OpenLayers), not on the server side. This allows different map applications to use different styles to render a map without the need for pre-configured styles on the server side (such as GeoServer).
  • Vector tiles are usually smaller in size than image tiles , which allows data to be transferred faster and uses lower bandwidth.
  • GeoWebCache embedded in GeoServer can efficiently store vector tile data. Since the style is configured by the client rather than the server, GeoWebCache only needs to store a vector tile to configure different styles on the client .
  • Since the vector data can be obtained on the client side, high-resolution maps can be drawn without a corresponding increase in bandwidth .
  • The client can access the actual feature information (attribute information and geometric information) locally, so it can perform very complex and detailed feature rendering.

shortcoming:

The main disadvantage of vector tiles is that the geographic data needs to be preprocessed so that the client can do the desired drawing (similar to preprocessing data for image tile maps). With this in mind, vector tiles should only be used for rendering . Although they are in vector format, they are not editable. Vector tiles are optimized for reading and rendering. If you want to edit elements on the client side, the most suitable method is to use OGC's WFS service.

In addition, you can refer to this article for the theory. The articles I occasionally see feel okay:

Theoretical support reference

So far, geoserver has finished sharing the theory and actual combat of the vector slice service. If you test and verify it a few times, you will gain a lot.

Guess you like

Origin blog.csdn.net/nandao158/article/details/130728268