Method for dynamically calculating geometric positions of vector tile elements based on openLayer

By dynamically calculating the geometric positions of vector tile elements in openLayer, the problems of repeated rendering and position changes of vector tile maps are solved, the rendering efficiency and display aesthetics are improved, and efficient rendering and flexible position settings of vector tile are realized.

CN119091019APending Publication Date: 2024-12-06UNDERGROUND SPACE TECHNOLOGY DEVELOPMENT CO LTD OF CNACG
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411071770.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-06
Publication Date
2024-12-06

AI Technical Summary

Technical Problem

When loading vector tile maps in openLayer, resolution changes or layer order changes lead to repeated rendering and position changes, resulting in too many features in the same area, low rendering efficiency and poor display effect.

Method used

Using the dynamic calculation method of vector tile features based on openLayer, the geometric position method of vector tile features is automatically detected and the styleFunction method is called to determine whether the feature has been rendered. If it is not rendered, the geographic location data is obtained and modified, the features are drawn, and the final vector tile is generated. , reduce repeated rendering and adjust feature position.

Benefits of technology

Control the number of renderings of features at the same map resolution, improve rendering efficiency, dynamically adjust feature positions, improve display aesthetics, and realize efficient rendering and flexible position settings of vector tiles.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119091019A_ABST
    Figure CN119091019A_ABST
Patent Text Reader

Abstract

The invention discloses a method for dynamically calculating geometric positions of vector tile elements based on openLayer. The method comprises the following steps: issuing a vector tile service; the method comprises the following steps of: loading a vector tile by combining a map framework openlayer with an ol-mapbox-style plug-in; the openLayer can calculate elements in the current view range, and the styles of the elements are rendered by calling a styleFunction method for the elements; in the styleFunction method, whether the element is rendered or not is judged firstly, if not, the fifth step is executed, and if yes, the process is directly returned to the end, and when the element is rendered, the element type and geographic position data are obtained firstly according to a getGeometric method, and the geographic position data are calculated and modified according to requirements; the elements are set to corresponding positions; the elements such as points, lines, planes and icons are drawn according to the types and geographical position data; and 8, generating a final vector tile map. According to the method, the geometric positions of the vector tile elements can be dynamically calculated based on openLayer and rendered, and the corresponding vector tile electronic map is generated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of geographic information, relates to a vector tile loading method, and specifically to a method for dynamically calculating the geometric position of vector tile elements based on openLayer. Background Art

[0002] With the development of technology, vector tiles have become increasingly popular in map applications as an efficient way of data transmission and rendering. In order to meet the needs of developers and users, openLayer has continuously updated its features and supported data formats in recent years, and currently also supports the loading of vector tiles.

[0003] Currently, vector tile map services can be loaded through openLayer combined with the ol-mapbox-style plug-in. While the loading is satisfactory, the display effect also has some shortcomings. When openLayer detects changes in resolution or layer order or other layer occlusions, it will re-render the features within the visible range of the map. This will cause the same feature to call the styleFunction method multiple times for rendering, and the rendering position will also change at different resolutions, which sometimes results in too many features displayed in the same area. Summary of the invention

[0004] In order to overcome the deficiencies of the above-mentioned prior art, the purpose of the present invention is to provide a method for dynamically calculating the geometric position of vector tile elements based on openLayer. When openLayer renders vector tile elements, unnecessary repeated rendering is reduced according to demand, so that the same element will only be rendered once. During rendering, the geometric position of the tile elements can also be adjusted according to demand.

[0005] In order to achieve the above object, the technical solution adopted by the present invention is: A method for dynamically calculating the geometric position of vector tile elements based on openLayer, characterized by comprising the following steps: Step 1: Publish vector tile service; Step 2: Use the openlayer map framework combined with the ol-mapbox-style plugin to load vector tiles; Step 3: The map framework openLayer automatically calculates the features within the current view range and calls the styleFunction method to render their styles for these features according to the current map resolution changes; Step 4: In the styleFunction method, first determine whether the element has been rendered. If not, proceed to step 5. If yes, return directly to the end; Step 5: When rendering features, obtain the feature type and geographic location data according to the getGeometry method; Step 6: Calculate and modify the geographic location data according to the requirements and set the elements to the corresponding locations; Step 7: Draw points, lines, surfaces, icons and other elements according to the type and the geographic location data obtained in step 6; Step 8: Generate final vector tile.

[0006] In the step 4, each time the styleFunction is called, the feature element needs to be saved in the array. Before saving, it is determined whether the feature element already exists in the array. If it exists, it will not be saved. If it does not exist, it will be saved.

[0007] In step 6, the position data can be assigned and modified, and finally displayed at the expected position.

[0008] The beneficial effects of the present invention are: 1. When loading vector tiles, you can control the number of times the same feature is rendered at the same map resolution, thereby improving rendering efficiency to a certain extent; 2. Dynamically modify the geographic location data of the elements according to the needs, and set the elements to the corresponding positions more flexibly to improve the overall display aesthetics; 3. The present invention provides a complete technical solution for dynamically calculating the geometric position of vector tile elements and points out the key points of the detailed technical route. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] Figure 1 It is a flow chart of the present invention. DETAILED DESCRIPTION

[0010] The present invention is further described below in conjunction with the accompanying drawings and embodiments.

[0011] like Figure 1 As shown, a technology for dynamically calculating the geometric position of vector tile elements based on openLayer includes the following steps: Step 1: Use the open source GIS server geoserver to add vector data files to the data store, publish each layer and check the vector tile option. Publish the vector tile cache and generate a vector tile service; Step 2: Use the front-end open source map framework OpenLayer combined with the ol-mapbox-style plug-in to load the vector tile map service published by GeoServer; Step 3: When loading, the open source map framework openLayer will automatically call the styleFunction method for the features within the current view range, with the input parameters being the current feature and the current map resolution, and render their styles according to the returned style array; Step 4: Define an array globally. Whenever a feature calls styleFunction, first determine whether the array contains the feature based on the feature ID. If not, save the feature to the array and execute step 5. If it is included, do not save and return directly. Step 5: Get the type of the feature and its geographic location data according to the getGeometry method of the feature; Step 6: Calculate and modify the geographic location data according to the requirements and set the feature to the corresponding position. For example, if an icon is to be displayed in the middle of a line segment, you need to first get the coordinates of the two end points of the line segment through the getGeometry() method, then calculate the coordinates of the midpoint by averaging the longitude and latitude, and then assign the obtained coordinates to the flatMidpoints_ field of the feature's location data; Step 7: Draw points, lines, surfaces, icons and other elements according to feature types and geographic location data; Step 8: Generate the final vector tile map.

Claims

1. A method for dynamically calculating the geometric position of vector tile elements based on openLayer, characterized in that: The following steps are involved: Step 1: Publish vector tile service; Step 2: Use the openlayer map framework combined with the ol-mapbox-style plugin to load vector tiles; Step 3: The map framework openLayer automatically calculates the features within the current view range and calls the styleFunction method to render the styles of these features according to the current map resolution changes; Step 4: In the styleFunction method, first determine whether the element has been rendered. If not, proceed to step 5. If yes, return directly to the end; Step 5: When rendering features, obtain the feature type and geographic location data according to the getGeometry method; Step 6: Calculate and modify the geographic location data according to the requirements and set the elements to the corresponding locations; Step 7: Draw points, lines, surfaces, icons and other elements according to the type and the geographic location data obtained in step 6; Step 8: Generate final vector tile.

2. The method for dynamically calculating the geometric position of vector tile elements based on openLayer according to claim 1, characterized in that: In the step 4, each time the styleFunction is called, the feature element needs to be saved in the array. Before saving, it is determined whether the feature element already exists in the array. If it exists, it will not be saved. If it does not exist, it will be saved.

3. The method for dynamically calculating the geometric position of vector tile elements based on openLayer according to claim 1, characterized in that: In step 6, the position data can be assigned and modified, and finally displayed at the expected position.