Method, device, medium and product for dynamically loading vector maps
By storing vector features and attribute information separately in different databases and adopting an adaptive loading mechanism, the problem of high rendering pressure in traditional map loading methods is solved, achieving efficient and flexible map display and updating.
Patent Information
- Application Number
- CN202511477144.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-16
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2045-10-16
AI Technical Summary
Traditional map loading methods involve numerous layers and high rendering pressure on features, resulting in poor performance, unsatisfactory visual effects, and a tendency to cause page rendering crashes, making it impossible to accurately display the map.
Vector features are stored in a spatial database, while attribute information is stored in a relational database. Map labels are dynamically loaded through a split request and adaptive loading mechanism, allowing for the separate storage and management of vector features and attribute information.
It improves the efficiency of map acquisition and display, reduces the impact of data updates, ensures data security and rapid response, and enhances the flexibility and aesthetics of the map system.
Smart Images

Figure CN120950619B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of map display, in particular to a method, device, medium and product for dynamically loading a vector map. BACKGROUND
[0002] The conventional map loading method can refer to Figure 1 , which comprises the following steps: drawing a complete map, adding attribute information to each vector element, publishing a WMTS and REST standard map service conforming to the OGC standard, and directly loading the map and rendering it to a webpage after receiving a request for the map service.
[0003] Further, the map returned to the user is a static sliced map, and all elements are integrated and the style is adjusted during mapping, so as to complete the drawing. Figure 1 Generally, the map needs to be updated. According to the prior art, the map is updated as follows: for a map element with a fixed style, the map element is updated once in a long time, and a static map service can be selected to reduce errors caused by loading and interactive operation; for a layer with fast business update, the modification cost is high, and the common practice is to draw different layers and display different business data, so that the browser rendering pressure is large.
[0004] In the process of the conventional map loading method, a large number of business maps are involved. Due to the large number of layers and the large rendering pressure of elements, the attribute information is very large. If all the layers and elements are loaded at one time, the elements are overlapped with each other, the visual sense is not good, the performance is low, the time consumption is long, and even the webpage rendering crashes, so that the map cannot be accurately displayed. SUMMARY
[0005] The purpose of the present application is to provide a method, device, medium and product for dynamically loading a vector map to solve the problems described in the background art.
[0006] To achieve the above-mentioned purpose, the present application provides the following solutions.
[0007] In a first aspect, the present application provides a method for dynamically loading a vector map, comprising the following steps:
[0008] receiving a map display request, the map display request carrying a target place name, the map comprising vector elements and attribute information, the vector elements being stored in a spatial database, the attribute information being stored in a relational database, the attribute information being used to describe the attributes of the vector elements, and the target place name being a place name to be displayed on the map;
[0009] splitting the map display request into a vector data request and an attribute data request, the vector data request being used to request vector elements corresponding to the target place name from the spatial database, and the attribute data request being used to request attribute information corresponding to the target place name from the relational database;
[0010] reconstructing the vector elements corresponding to the target place name and the attribute information corresponding to the target place name to obtain layer data of the target place name;
[0011] obtaining a display level corresponding to the target place name, and sending the display level and the layer data to a terminal, so that the terminal renders a map according to the display level and the layer data, and displays the map;
[0012] when the map is rendered, based on a label collision rate of the rendered map, and in combination with a hysteresis mechanism, adaptively and dynamically loading labels of the vector elements.
[0013] Optionally, the spatial database and the relational database are generated by the following method:
[0014] drawing a full-quantity map, and storing the full-quantity map in a spatial database, the full-quantity map including full vector elements and full attribute information;
[0015] assigning the same association code to each vector element included in the full vector elements and attribute information corresponding to the vector element;
[0016] moving the attribute information and the association code corresponding to the attribute information to a relational database.
[0017] Optionally, after the attribute information and the association code corresponding to the attribute information are moved to the relational database, the method further includes:
[0018] receiving an attribute information modification request, the attribute modification request carrying a place name of attribute information to be modified and a modification requirement;
[0019] determining attribute information to which the place name of attribute information to be modified belongs from the relational database;
[0020] performing a modification operation on the attribute information based on the modification requirement.
[0021] Optionally, the splitting the map display request into a vector data request and an attribute data request includes:
[0022] obtaining a place name identifier corresponding to the target place name from a correspondence between place names and place name identifiers;
[0023] acquire the associated code corresponding to the place name from a correspondence relationship between place names and associated codes stored in advance;
[0024] generate the vector data request based on the associated code and the first identifier of the spatial database, and generate the attribute data request based on the associated code and the second identifier of the relational database.
[0025] Optionally, the acquisition process of the vector elements and the attribute information is as follows:
[0026] identify the spatial database based on the first identifier, and query the vector element corresponding to the associated code from the spatial database based on the associated code;
[0027] identify the relational database based on the second identifier, and query the attribute information corresponding to the associated code from the relational database based on the associated code.
[0028] Optionally, the display level corresponding to the target place name is acquired, and the display level and the layer data are sent to the terminal, so that the terminal renders a map according to the display level and the layer data, and displays:
[0029] a rendering layer array is set locally on the terminal, and the rendering layer array is used to dynamically display the layer data to be displayed by the map to be rendered;
[0030] acquire the zoom level of the map being displayed at the current time;
[0031] when the display level is less than or equal to the current zoom level of the map, it is determined whether the rendering layer exists, and if not, the layer data is added to the layer rendering data group;
[0032] when the display level is greater than the zoom level, it is determined whether the rendering layer exists, if it exists, the layer data is removed from the layer rendering data group, and if the layer rendering data group does not have the layer data, the layer rendering data group is not added.
[0033] Optionally, when the rendering of the map is completed, the label of the vector element is adaptively and dynamically loaded based on the label collision rate of the rendered map and in combination with a hysteresis mechanism, and the label includes:
[0034] determine the label collision rate of the rendered map;
[0035] when the label collision rate falls within a predetermined range, the currently displayed label is not modified;
[0036] When the label collision rate is greater than the hysteresis interval, the maximum allowed display level k is reduced by one level, and the label collision rate is recalculated, and the level reduction process is repeated until the label collision rate falls within the hysteresis interval, and the maximum allowed display level k is obtained.
[0037] When the label collision rate is less than the hysteresis interval, k is increased by one level, and the label collision rate is recalculated, and the level increase process is repeated until the label collision rate of the rendered map falls within the hysteresis interval, and the maximum allowed display level k is obtained.
[0038] In a third aspect, the present application provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor executes the computer program to implement the steps of the method of any one of the above-mentioned second aspects.
[0039] In a fourth aspect, the present application provides a computer readable storage medium having a computer program stored thereon, and the computer program is executed by a processor to implement the steps of the method of any one of the above-mentioned second aspects.
[0040] In a fifth aspect, the present application provides a computer program product comprising a computer program, and the computer program is executed by a processor to implement the steps of the method of any one of the above-mentioned second aspects.
[0041] The method for dynamically loading a vector map provided by the embodiments of the present application stores vector elements in a spatial database and stores attribute information in a relational database, so that the vector elements and the attribute information are stored separately, which can simultaneously acquire the vector elements and the attribute information and improve the acquisition efficiency, thereby improving the efficiency of reconstructing and displaying a map. In addition, after the vector elements and the attribute information are stored separately, when the vector elements or the attribute information need to be modified, only the data to be modified needs to be operated separately, without pulling other irrelevant data, thereby improving the data update efficiency and realizing a responsive and flexible map system. In addition, modification does not cause misoperation on other data, thereby improving the security of the data. BRIEF DESCRIPTION OF DRAWINGS
[0042] In order to more clearly illustrate the technical solutions of the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed in the embodiments. Obviously, the drawings described below are only some embodiments of the present application, and those skilled in the art can obtain other drawings according to these drawings without creative labor.
[0043] Figure 1A schematic diagram of a prior art method of loading a map provided for an embodiment of the present application;
[0044] Figure 2 A schematic diagram of an application environment of a method of dynamically loading a vector map provided for an embodiment of the present application;
[0045] Figure 3 A schematic diagram of a flow of a method of dynamically loading a vector map provided for an embodiment of the present application;
[0046] Figure 4 A schematic diagram of a flow of a method of generating a spatial database and a relational database provided for another embodiment of the present application;
[0047] Figure 5 A schematic diagram of a flow of a method of generating a spatial database and a relational database provided for an embodiment of the present application;
[0048] Figure 6 A schematic diagram of a flow of a method of modifying attribute information provided for an embodiment of the present application;
[0049] Figure 7 A schematic diagram of a flow of a method of generating a vector data request and an attribute data request provided for an embodiment of the present application;
[0050] Figure 8 A schematic diagram of a flow of a method of querying a vector element and attribute information provided for an embodiment of the present application;
[0051] Figure 9 A schematic diagram of a flow of a method of querying a vector element and attribute information provided for an embodiment of the present application;
[0052] Figure 10 A schematic diagram of attribute information found provided for an embodiment of the present application;
[0053] Figure 11 A schematic diagram of reconstructed geojson data provided for an embodiment of the present application;
[0054] Figure 12 A schematic diagram of reconstructed geojson data provided for an embodiment of the present application;
[0055] Figure 13 A schematic diagram of an array B provided for an embodiment of the present application;
[0056] Figure 14 A schematic diagram of an array A provided for an embodiment of the present application;
[0057] Figure 15 A schematic diagram of a flow of a method of rendering a map provided for an embodiment of the present application;
[0058] Figure 16 A flowchart of a method for rendering a vector element according to an embodiment of the present application is shown in FIG. 1;
[0059] Figure 17 A flowchart of a method for rendering a map according to an embodiment of the present application is shown in FIG. 2;
[0060] Figure 18 A flowchart of a method for rendering a map label according to an embodiment of the present application is shown in FIG. 3;
[0061] Figure 19 A flowchart of a method for determining a label collision rate according to an embodiment of the present application is shown in FIG. 4;
[0062] Figure 20 A flowchart of a method for determining a display level according to an embodiment of the present application is shown in FIG. 5;
[0063] Figure 21 A structural diagram of a computer device according to an embodiment of the present application is shown in FIG. 6. DETAILED DESCRIPTION
[0064] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of protection of the present application.
[0065] The above purposes, features and advantages of the present application will be more apparent and understandable. The content involved in the present application will be described in further detail below with reference to the drawings and specific embodiments.
[0066] Noun explanation:
[0067] Layer: a collection of each type of business data, generally referred to as a vector map, such as a river layer, a reservoir layer;
[0068] Element / vector element: each point / line / surface in a layer, each layer / vector map is composed of related elements, i.e. point / line / surface, for example, a river layer is generally composed of line elements of rivers, and large dots of rivers may be surface elements, each river, such as the Huaihe River, the Xiaoqing River, and the Beikang River, is drawn completely to form the entire river layer; for example, a lake layer, small lakes may be point elements, and large reservoirs may be surface elements, each lake, such as Chao Lake, Hongze Lake, and Chengxi Lake, is drawn completely to form a lake layer.
[0069] Attribute information: business information contained in a feature, for example, in a river layer, a line is the Huaihe River, which is a vector feature in the river layer, the attribute information of the Huaihe River includes the river name, the river level, the river length, the river source, and other business content, which is called attribute information. Further, the attribute information can also include display levels.
[0070] Display level: the more the map is zoomed in, the more display levels there are, for example, the display level of a river is 10, which means that the river is displayed when the map is zoomed in to level 10 or above.
[0071] Label: a text annotation corresponding to a vector feature displayed on a map.
[0072] The method for dynamically loading a vector map provided in the embodiments of the present application can be applied in an application environment as shown in Figure 2 The application environment includes a terminal and a server. The terminal communicates with the server through a network. A data storage system can store data required to be processed by the server. The data storage system can be separately arranged, integrated on the server, or placed on a cloud or other server. The terminal can send a map display request to the server. After receiving the map display request, the server performs a corresponding display operation according to the map display request and returns the result to the terminal.
[0073] The terminal can be, but is not limited to, various desktop computers, notebook computers, smart phones, tablet computers, Internet of Things devices, and portable wearable devices. The Internet of Things device can be a smart speaker, a smart television, a smart air conditioner, a smart vehicle device, etc. The portable wearable device can be a smart watch, a smart bracelet, a head-mounted device, etc. The server can be implemented by an independent server or a server cluster composed of multiple servers, and can also be a cloud server.
[0074] In an exemplary embodiment, as shown in Figure 3 A method for dynamically loading a vector map is provided, which is executed by a computer device, specifically, can be executed by a terminal or a server, or can be executed by a terminal and a server together. In the embodiments of the present application, the method is applied to the server in Figure 2 The following steps 101 to 105 are included:
[0075] Step 101, receiving a map display request, the map display request carrying a target place name, the map including a vector feature and attribute information, the vector feature stored in a spatial database, the attribute information stored in a relational database, the attribute information used to describe the attribute of the vector feature, and the target place name being a place name to be displayed on the map;
[0076] The map display request can be input by a user through a human-computer interaction interface. When inputting the map display request, the user generally directly inputs a target place name. When the target place name is received, the id corresponding to the target place name is determined according to the target place name.
[0077] The spatial database stores vector elements of all place names in the full-amount map. Each vector element corresponds to attribute information, which is used to describe the characteristics of the vector element, such as name, longitude, latitude, etc.
[0078] The full-amount map is a map layer of all place names drawn according to requirements. The full-amount map can be large or small according to requirements. For example, if the Huaihe River basin map needs to be studied, the full-amount map is to draw all the main and branch rivers of the Huaihe River basin on the desktop of a geographic information system (GIS), including the attribute data thereof.
[0079] The spatial database and the relational database are both configured in advance and arranged on a server.
[0080] In step 102, the map display request is split into a vector data request and an attribute data request. The vector data request is used to request the vector element corresponding to the target place name from the spatial database, and the attribute data request is used to request the attribute information corresponding to the target place name from the relational database.
[0081] In step 103, the vector element corresponding to the target place name and the attribute information corresponding to the target place name are reconstructed to obtain the layer data of the target place name.
[0082] The layer data is data including both vector elements and attribute information.
[0083] The data format of the vector element is geojson, which contains a properties field. The attribute information taken from the relational database is put into the properties in the json format to form new geojson data, which constitutes a complete layer of data, including both vector elements and attribute information of the vector elements.
[0084] Further, the attribute information can be merged into the vector element to obtain new geojson data. The new geojson data is layer data, which is a complete layer for various businesses, such as a river layer, a lake layer, etc. Each layer is composed of many vector elements, and the vector element is actually a geojson format data, which includes an association code and a display level DT, such as Figure 11 andFigure 12 After the recombination is completed, the display layer DT is cached locally according to the layer type.
[0085] Exemplarily, the complete data structure of one vector element is as follows:
[0086] {
[0087] "type": "Feature",
[0088] "id": 0,
[0089] "geometry": {
[0090] "type": "Polygon",
[0091] "coordinates": [
[0092] [longitude, latitude] ]
[0094] },
[0095] "properties": {
[0096] "FID": 0,
[0097] "DT": "12",
[0098] "NAME": "Beikangou"
[0099] }
[0100] }
[0101] Step 104: Obtain the display layer DT corresponding to the target place name; and send the display layer DT and the layer data to the terminal, so that the terminal renders a map according to the display layer DT and the layer data and displays.
[0102] This step can refer to Figure 15 and Figure 16 , wherein the attribute information contains the display layer.
[0103] A field of the display layer is defined for each vector element. If the web map is divided into 1-20 layers, the display layer of each vector element is in the range of 1-20. Each element fills in the corresponding display layer,
[0104] , see Figure 15, the terminal renders a map according to the display level and the layer data, comprising: step 601, setting a rendering layer array locally on the terminal, and obtaining a zoom level of a map being displayed at a current time; step 602, when the display level is less than or equal to the zoom level of the map, adding the layer data to a layer rendering data group; step 603, when the display level is greater than the zoom level, removing the layer data from the layer rendering data group;
[0105] wherein the rendering can be a first rendering, and the terminal renders the map by the following method:
[0106] (1) setting a rendering layer array locally on the terminal, the rendering layer array being used for dynamically displaying layer data to be rendered by the map;
[0107] storing the reconstructed data, i.e. the layer data, obtained in step 103 into a layer array of a local map, to form layer data of various types.
[0108] storing new geojson data into the layer array of the local map, to form layer data of various types, i.e. geojson data, such as Figure 12 、 Figure 13 .
[0109] (2) obtaining a zoom level of a map being displayed at a current time;
[0110] (3) when the display level is less than or equal to the zoom level of the map, determining whether a rendering layer exists, and if not, adding the layer data to a layer rendering data group;
[0111] (4) when the display level is greater than the zoom level, determining whether a rendering layer exists, and if so, removing the layer data from the layer rendering data group, and if the layer data does not exist in the layer rendering data group, not adding the layer data to the layer rendering data group.
[0112] wherein determining whether a rendering layer exists can be understood as determining whether a rendering layer already exists in a layer rendering array.
[0113] step 105, when the map is rendered, based on a label collision rate of the rendered map, and in combination with a hysteresis mechanism, adaptively and dynamically loading labels of the vector elements.
[0114] In view of the label congestion problem, a hierarchical display method based on label adaptation is adopted, before rendering the labels, candidate labels in a current window are sequentially placed and simulated, a maximum allowed display level is calculated by calculating a label collision (overlap) rate and in combination with a hysteresis interval, and the maximum allowed display level is less than a current map level, and then the display of the labels is controlled according to the maximum allowed display level.
[0115] The label-adaptive hierarchical display method comprises:
[0116] (1) A "candidate label set" L (such as the name of a main river and the name of an important lake) can be generated in a current view window, the candidate labels are placed in order according to a DT display level (the DT is both a display level of a vector element and an importance level of a label), the total number N_total of the candidate labels is defined, the number N_overlap of labels that collide (overlap) is calculated, and a label collision rate Rc = N_overlap / |L| is obtained.
[0117] (2) A threshold parameter is set: Rc_max ≈ 0.25 and ε ≈ 0.03-0.05, and a threshold band is judged according to Rc. If Rc is greater than or equal to Rc_max+ε, the level is lowered for trial, if Rc is less than Rc_max-ε, the level is raised for trial, and Rc is recalculated after each trial until Rc is in the interval [Rc_max-ε, Rc_max+ε], and thus a maximum allowed display level k is obtained, which is less than a current map zoom level zoom.
[0118] The vector layer (geometric element) is controlled to be displayed based on the DT, and the label is controlled to be displayed based on k. When the DT of the label corresponding to the vector element is less than or equal to k and the current label has not been displayed, the label is added to the display; when the DT of the label corresponding to the vector element is greater than k and the current label has been displayed, the label is removed from the display. The decoupling of the above-mentioned vector element and label can ensure the integrity of the geometric map and the readability of the label.
[0119] The method for dynamically loading a vector map provided in the embodiments of the present application stores vector elements in a spatial database and stores attribute information in a relational database, thereby storing the vector elements and the attribute information separately. In this way, the vector elements and the attribute information can be acquired simultaneously, the acquisition efficiency is improved, and thus the efficiency of reconstructing and displaying a map can be improved. In addition, after the vector elements and the attribute information are stored separately, when the vector elements or the attribute information need to be modified, only the data to be modified needs to be operated separately, and other irrelevant data does not need to be pulled, thereby improving the data update efficiency, realizing a map system that responds quickly and flexibly. In addition, no misoperation is generated on other data during the modification, thereby improving the security of the data. Further, by introducing a self-adaptive hierarchical display method based on a label collision rate, display can be dynamically controlled according to the label congestion degree, the label collision rate is significantly reduced, and the user experience is improved.
[0120] In addition, the embodiments of this application separate the layer rendering and the label loading, so that they do not affect each other, thereby ensuring the independence of label loading. While ensuring that the target place name is displayed as expected, the collision rate of each label on the map is controlled within a predetermined range, improving the aesthetics of the map.
[0121] For example, when attribute information (such as the location, name, or other attributes of a river) changes, only a query to the relational database is needed, and the corresponding value in the relational database is updated. There is no need to regenerate or re-download the entire map. The platform can refresh only the rendering effect corresponding to the updated data, greatly improving update efficiency. Users can customize style rules (colors, icons, etc.), increasing the flexibility and convenience of user-defined settings. The same vector feature can be flexibly displayed using different styles according to user needs or different scenarios. For frequently changing features (such as real-time conditions), this method of changing only the style (color) without redrawing the geometry is highly efficient and practical.
[0122] Optionally, see Figure 4 and Figure 5 In another exemplary embodiment of this application, the spatial database and the relational database are generated through the following steps 201 to 203:
[0123] Step 201: Draw a full map and store it in a spatial database. The full map includes all vector features and all attribute information.
[0124] Among them, the full amount Figure 1 Maps are typically saved in a unique format and drawn on a desktop application. During the map-making process, cartographers need to associate the attribute information of each vector feature with that vector feature to generate the unique format. Therefore, when drawing maps, both vector features and attribute information are stored in a spatial database.
[0125] Among them, full vector features refer to all vector features included in the full map.
[0126] Among them, the full attribute information is the attribute information of each vector feature included in the full vector feature.
[0127] Step 202: Assign the same association code to each vector element and the corresponding attribute information of the full vector element;
[0128] First, the vector layer is drawn precisely, an associated mapping ID is defined, and it is stored in a spatial database (i.e., a non-relational database).
[0129] The attribute information related to the vector layer is separated from the vector layer's properties and stored in a relational database, with the addition of a correlation mapping ID and a layer level (DT) field. The correlation mapping ID is the same as the correlation mapping ID in the spatial database, facilitating queries between the two databases. The layer level (DT) field represents the display level of each feature in the layer; for example, a river's display level is 10, meaning that the river will be displayed when the map is zoomed in to level 10 or higher. The advantage of choosing a relational database lies in its high-performance data retrieval and processing capabilities.
[0130] Step 203: Move the attribute information and the corresponding association code to the relational database.
[0131] After the movement, the spatial database includes vector features and their corresponding association codes, but no longer contains attribute information; the relational database includes attribute information and its corresponding association codes.
[0132] Spatial databases use standard GeoJSON format for layer data, while relational databases use business-defined data structures, linked together by a common association mapping ID. The data structure of a spatial database is as follows:
[0133] ..."type": "Feature",
[0134] ..."geometry": {
[0135] …………"type": "Polygon",
[0136] …………"coordinates": [
[0137] ...[longitude, latitude], ...
[0138] Optionally, see Figure 6 In another exemplary embodiment of this application, after step 203, the method further includes the following steps 301 to 303:
[0139] Step 301: Receive an attribute information modification request, wherein the attribute modification request carries the place name of the attribute information to be modified and the modification requirements;
[0140] Step 302: Determine the attribute information to which the place name whose attribute information needs to be modified belongs from the relational database.
[0141] In a relational database, you can retrieve a record by using the place name or related ID in the request. This record contains all the attribute information corresponding to the place name, and you can delete or modify it.
[0142] Step 303, performing a modification operation on the attribute information of the category based on the modification requirement.
[0143] In the process of modifying the attribute information, the attribute information corresponding to the place name is directly obtained from the relational database, so that the efficiency of updating the attribute information is improved; meanwhile, the information is not required to be obtained from the spatial database, so that the misoperation on the spatial database is reduced, and thus the mismodification on the vector element is also reduced.
[0144] Optionally, referring to Figure 7 In another exemplary embodiment of the present application, the step 102 comprises steps 401-403.
[0145] Step 401, obtaining the place name identifier corresponding to the target place name from the correspondence between the place name and the place name identifier;
[0146] The correspondence between the place name and the place name identifier is established in advance.
[0147] Step 402, obtaining the association code corresponding to the place name identifier from the correspondence between the place name identifier and the association code identifier stored in advance;
[0148] Step 403, generating the vector data request based on the association code and the first identifier of the spatial database, and generating the attribute data request based on the association code and the second identifier of the relational database.
[0149] The first identifier and the second identifier can be the interface identifier of the corresponding database.
[0150] Optionally, referring to Figure 8 , Figure 9 and Figure 10 In another exemplary embodiment of the present application, the process of obtaining the vector element and the attribute information is as follows:
[0151] Step 501, identifying the spatial database based on the first identifier, and then querying the vector element corresponding to the association code from the spatial database based on the association code;
[0152] When the map is requested to be loaded, two requests are sent in the background, and the spatial database and the relational database are requested at the same time, and the vector layer data and the attribute data of the same ID are taken out through the association mapping ID.
[0153] Step 502, identifying the relational database based on the second identifier, and then querying the attribute information corresponding to the association code from the relational database based on the association code.
[0154] Optionally, referring to Figure 14 and Figure 17In another exemplary embodiment of this application, step 104 includes steps 701 to 704:
[0155] Step 701: Set a rendering layer array locally on the terminal. The rendering layer array is used to dynamically display the layer data that the map to be rendered needs to display.
[0156] The reconstructed data obtained in step 103 above, i.e., the layer data, is stored in the layer array of the local map to form layer data of various types.
[0157] Step 702: Obtain the zoom level of the map currently being displayed;
[0158] Step 703: When the display level is less than or equal to the current zoom level of the map, determine whether the rendering layer already exists. If not, add the layer data to the layer rendering data group.
[0159] Step 704: When the display level is greater than the scaling level, determine whether the rendering layer already exists. If it does, remove the layer data from the layer rendering data group. If the layer data is not in the layer rendering data group, do not add it to the layer rendering data group.
[0160] The step of determining whether a rendering layer already exists can be understood as checking if the rendering layer already exists in the layer rendering array. For example, city-level point markers are displayed when the display level reaches level 8 or higher, while some place names are only displayed at level 12 or higher. This step reduces unnecessary vector feature rendering, significantly lowering the computational burden and time required for real-time rendering.
[0161] For example, we set up a local map display array A, listen to the current map zoom level, and store various layers in array B. The structure of B is:
[0162] "B": {
[0163] "River": [
[0164] {"name":"Huaihe River","DT":6},
[0165] {"name":"North Cam","DT":10},
[0166] {"name":"Shaying River","DT":12},
[0167] {"name":"Xiaoqing River","DT":14}
[0168] ],
[0169] "lake":[
[0170] {"name":"Chaohu", "DT":6},
[0171] {"name":"Hongze Lake", "DT":10},
[0172] {"name":"Chengxi Lake", "DT":12}
[0173] ],
[0174] "reservoirs": [
[0175] {"name":"Chushandian Reservoir", "DT":6},
[0176] {"name":"Meishan Reservoir", "DT":10} ]
[0178] }
[0179] When the zoom value is 7, add
[0180] "rivers": [
[0181] {"name":"Huai River", "DT":6} ],
[0182] "lakes": [
[0183] {"name":"Chaohu", "DT":6} ],
[0184] "reservoirs": [
[0185] {"name":"Chushandian Reservoir", "DT":6}]
[0186] to A, and the content in A is:
[0187] "A": {
[0188] "rivers": [
[0189] {"name":"Huai River", "DT":6} ],
[0190] "lakes": [
[0191] {"name":"Chaohu", "DT":6} ],
[0192] "reservoirs": [
[0193] {"name":"Chushandian Reservoir", "DT":6}]
[0194] }
[0195] According to the zoom level of the current map, the vector data under the level is displayed on demand. Avoid performance waste caused by processing too much invisible data (especially in mobile or weak network environment).
[0196] Therefore, by the method of judging with the current map state, dynamic processing is performed to achieve the effect of rendering the map on demand and dynamically. The rendering array of the layer is set to be loaded to the map during page initialization. Dynamic loading reduces the rendering pressure of the browser. Therefore, the above-mentioned method of dynamically loading the vector map can greatly reduce the rendering pressure, reduce the loading time, and improve the software performance.
[0197] Further, when initializing the map, the vector elements are preloaded into the local cache. Different arrays load different types of vector elements, such as river array, lake array, reservoir array, etc. This organization method facilitates efficient classification management and rendering. Initialization also has a display array. According to the demand, the rendering task is split into multiple logical layers. When the display layer is reached, the river array greater than or equal to the current zoom will be added to the display array for rendering, so as to achieve the way of on-demand and dynamic loading of the vector map.
[0198] On-demand loading of data and rendering of layers reduces bandwidth consumption and memory and CPU pressure of the client (especially the browser), and optimizes resource use.
[0199] In this application, each vector element in the layer needs to be classified and displayed. For example, when the map is at a small level (which can be understood as being able to see all of China), the river layer can only display the main rivers such as Huaihe River, Shaying River, and Hongru River. When the map is zoomed in to Anhui Province, i.e., the level is increased, the river layer can display more rivers, but there will be no serious superposition of rivers. In this way, the smallest rivers are displayed when the level is increased to the maximum level, which is assumed to be 20 levels.
[0200] The application realizes fast response and smooth zooming and panning operation of the map, and provides a smooth user experience.
[0201] Optionally, referring to Figure 18 In another exemplary embodiment of the application, the step 105 includes steps 801-804:
[0202] Step 801, determining the label collision rate of the rendered map;
[0203] The label is designed for the vector element and is used to mark the names of different place names when the map is displayed. The user distinguishes different place names on the map through the label. Further, the label can be the name in the attribute information.
[0204] The calculation process of the label collision rate is as follows:
[0205] (1) Generate a "candidate label set" L (such as the name of the main river, the name of the important lake) in the current window. The DT obtained above is the display level, which is also the importance ranking of the label (main river > tributary, close to the center of the window > edge).
[0206] (2) The total number of candidate label set L is N_total, the label is placed according to DT, the number of labels that occur collision (collision) is calculated N_overlap, and the collision rate Rc = N_overlap / |L| is obtained. See Figure 19 , for example:
[0207] Suppose there are 5 labels
Huaihe River main stream, Shaying River, Cao River, Xiaqing River, Huaihongxin River
Huaihe River main stream
Shaying River
Cao River
Xiaqing River
Huaihe River main stream
Shaying River
Cao River
Huaihongxin River
[0208] N_total = 5 (Huaihe River main stream, Shaying River, Cao River, Xiaqing River, Huaihongxin River)
[0209] N_overlap = 2 (
Shaying River
Huaihe River main stream
Xiaqing River
Shaying River
[0210] Rc = N_overlap / N_total = 0.4
[0211] Step 802, when the collision rate of the label falls within a predetermined range, the currently displayed label is not modified;
[0212] Set the starting parameters, the maximum collision rate Rc_max ≈ 0.25, and the hysteresis parameter ε ≈ 0.03~0.05, then the hysteresis interval is [Rc_max−ε, Rc_max+ε], which can be adjusted according to the effect. According to the Rc calculated above, the threshold band is judged.
[0213] When the collision rate of the label does not fall within a predetermined range, step 803 is executed.
[0214] Step 803, when the label collision rate is greater than the hysteresis interval, the maximum allowed display level k is reduced by one level, and the label collision rate is recalculated. Repeat the process of reducing the level until the label collision rate falls within the hysteresis interval, stop changing the maximum allowed display level, and get the final maximum allowed display level k;
[0215] The hysteresis interval is a range of a predetermined re-collision rate, which can be an empirical value. The hysteresis interval makes the collision of the labels of the rendered map less, does not affect the user to view the map, and also makes the map as a whole look beautiful.
[0216] The label collision rate greater than the predetermined range means that the label collision rate is greater than the maximum value of the hysteresis interval.
[0217] When the label collision rate is greater than the hysteresis interval, it means that the collision rate is too large, and the labels that collide with each other affect the convenience of the user to view the map, so at this time, the display level of the label needs to be reduced to reduce the collision of the label.
[0218] The increase in the display level is an increase by one level at a time, and the calculation needs to be looped.
[0219] In addition, it needs to be noted that the label collision rate can need to be calculated multiple times until the label collision rate after rendering falls within the hysteresis interval, to obtain the maximum allowed display level k, and k is less than the current map zoom level zoom.
[0220] When the DT of the vector element corresponding to the label is less than k and the current label is not displayed, the label is added to the display; when the DT of the vector element corresponding to the label is greater than k and the current label is displayed, the label is removed from the display.
[0221] Step 804, when the label collision rate is less than the hysteresis interval, k is increased by one level, and the label collision rate is recalculated, and the process of increasing the level is repeated until the label collision rate of the rendered map falls within the hysteresis interval, and the loop is stopped, to obtain the maximum allowed display level k.
[0222] The label collision rate less than the hysteresis interval means that the label collision rate is less than the minimum value of the hysteresis interval.
[0223] When the label collision rate is less than the predetermined range, the collision rate is too small, which makes the distance between different labels too large, and also affects the convenience of the user to view the map.
[0224] Referring to Figure 20 The Rc calculated above is used to loop to determine the allowed display level k:
[0225] The starting parameters are set, the maximum collision rate Rc_max is approximately 0.25, and the hysteresis interval ε is approximately 0.03-0.05, which can be adjusted appropriately according to the actual effect.
[0226] If Rc exceeds Rc_max + ε, k is decreased by one level, if Rc is less than Rc_max - ε, k is increased by one level, and the label collision rate R̂c is recalculated until R̂c is in the interval [Rc_max - ε, Rc_max + ε], thus obtaining the maximum allowed display level k, which is less than the current map zoom level zoom.
[0227] An example is as follows:
[0228] Parameter settings: Rc_max = 0.25, ε = 0.05, hysteresis band: [0.20, 0.30]
[0229] Case 1: Current Rc = 0.35 > Rc_max + ε = 0.30, resulting in a decrease: k ← k_prev - 1
[0230] Case 2: Current Rc = 0.15 < Rc_max - ε = 0.20, proceed to increase level: k_prev+1, recalculate the new label collision rate R̂c = 0.18 < 0.20,
[0231] Continue to increase level k_prev+2: calculate R̂c = 0.22 < 0.20 → k ← k_prev+2
[0232] Continue to increase level k_prev+3: estimate R̂c = 0.28 > 0.20, stop as it exceeds the maximum value
[0233] Resulting in k = k_prev+2
[0234] Case 3: Current Rc = 0.25 falls within the hysteresis band [0.20, 0.30], then keep: k = k_prev
[0235] Thus obtaining the maximum allowed display level k, and k is less than the current map zoom level zoom.
[0236] Control based on k pairs of label display: for vector layer (geometric elements), still according to DT for display control; for label (text annotation), when the DT of the vector element corresponding to the label is less than or equal to k and the current label has not been displayed, the label is added to the display; when the DT of the vector element corresponding to the label is greater than k and the current label has been displayed, the label is removed from the display. It should be further pointed out that, when rendering the map, in order to solve the problem of label congestion superposition, the traditional method loads / unloads the label according to the defined map level. In the present application, an adaptive control method based on label collision rate is proposed, which is not a single display of layers according to the map zoom level, but first evaluates whether the collision rate of the labels in the current map is too high and whether the labels are too crowded, selects appropriate visual effects, and decides how many levels can be displayed at most, so as to display the map that is more convenient to watch. The geometric elements of the vector layer are still controlled according to DT for display, which maintains the integrity and accuracy of the map.
[0237] The rendering map process mentioned in steps 803 and 804 above is similar to the steps of steps 701-704 above, and the process is as follows:
[0238] 1. When the maximum allowed display level k is greater than or equal to the DT of the vector element, it is judged whether the rendered layer has a label, and if not, the label is added to the layer rendering data group;
[0239] 2. When the maximum allowed display level k is less than the DT of the vector element, it is judged whether the rendered layer has a label, and if so, the label is removed from the layer rendering data group, and if the layer rendering data group does not have the label, the layer rendering data group is not added.
[0240] That is, the vector elements that need to be displayed are dynamically recombined into rendering layers to achieve the goal of dynamically loading vector maps, thereby adapting to complex business scenarios.
[0241] In the rendering stage, by listening to the current level of the map, the vector elements are recombined to form the layers that need to be rendered. These layers are in the cache, which not only improves the rendering efficiency, but also adapts to complex business scenarios. Further, by introducing an adaptive display method based on label collision rate, the label collision rate is significantly reduced, and the decoupling of vector elements and labels can ensure the integrity of geometric maps and the readability of labels, improving user reading experience and interaction fluency.
[0242] In an exemplary embodiment, a computer device, which can be a server or a terminal, is provided, and its internal structure diagram can be seen from Figure 21As shown in the figure. The computer device includes a processor, a memory, an input / output interface (I / O for short) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capability. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store the related data of the method for dynamically loading a vector map. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with external terminals through network connection. The computer program is executed by the processor, and a method for dynamically loading a vector map can be realized.
[0243] Those skilled in the art can understand that, Figure 21 The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different component arrangement.
[0244] In one exemplary embodiment, a computer device is also provided, including a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps in each of the method embodiments.
[0245] In one exemplary embodiment, a computer readable storage medium is provided, storing a computer program, which is executed by a processor to implement the steps in each of the method embodiments.
[0246] In one exemplary embodiment, a computer program product is provided, including a computer program, which is executed by a processor to implement the steps in each of the method embodiments.
[0247] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data agreed by the user or fully agreed by all parties, and the collection, use and processing of related data need to comply with relevant regulations.
[0248] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when the computer program is executed, the processes of the above-mentioned embodiments of the methods can be included. In the embodiments provided in the present application, any reference to the memory, database or other medium can include at least one of the non-volatile and volatile memories. The non-volatile memory can include read-only memory (Read-Only Memory, ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive memory (ReRAM), magnetoresistive random access memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric memory (Ferroelectric Random Access Memory, FRAM), phase change memory (Phase Change Memory, PCM), graphene memory, etc. The volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, etc. As an illustration but not limitation, the RAM can be in various forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), etc.
[0249] The database involved in the embodiments provided in the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a blockchain, etc., without being limited thereto. The processor involved in the embodiments provided in the present application can be a general processor, a central processor, a graphics processor, a digital signal processor, a data processing logic of a programmable logic device, etc., without being limited thereto.
[0250] The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described, but as long as the combinations of the technical features do not exist, they should be considered as the scope of the present application.
[0251] The principles and implementation modes of the present application are described by applying specific examples herein. The above description of the embodiments is only used to help understand the method and its core idea of the present application; meanwhile, for those skilled in the art, according to the idea of the present application, the specific implementation mode and application range can be changed. In conclusion, the content of the present application should not be understood as a limitation.
Claims
1. A method of dynamically loading a vector map, characterized by, The method comprises the following steps: receiving a map display request, the map display request carrying a target place name, the map comprising vector elements and attribute information, the vector elements being stored in a spatial database, the attribute information being stored in a relational database, the attribute information being used to describe attributes of the vector elements, the target place name being a place name to be displayed on the map; splitting the map display request into a vector data request and an attribute data request, the vector data request being used to request the spatial database to obtain vector elements corresponding to the target place name, the attribute data request being used to request the relational database to obtain attribute information corresponding to the target place name; reconstructing the vector elements corresponding to the target place name and the attribute information corresponding to the target place name to obtain layer data of the target place name; obtaining a display level corresponding to the target place name; and sending the display level and the layer data to a terminal, so that the terminal renders a map according to the display level and the layer data and displays the map; after the rendering of the map is completed, based on a label collision rate of the rendered map, combining a hysteresis mechanism, and adaptively and dynamically loading labels of the vector elements; wherein, after the rendering of the map is completed, based on the label collision rate of the rendered map, combining the hysteresis mechanism, and adaptively and dynamically loading the labels of the vector elements, comprising: determining the label collision rate of the rendered map, i.e. a label overlap rate; when the label collision rate falls within a hysteresis interval, not modifying the currently displayed labels, the hysteresis interval being a predetermined range of the label collision rate; when the label collision rate is greater than the hysteresis interval, decreasing a maximum allowed display level k by one level, and recalculating the label collision rate, repeating the decreasing level process until the label collision rate falls within the hysteresis interval, stopping changing the maximum allowed display level, and obtaining a final maximum allowed display level k; when the label collision rate is less than the hysteresis interval, increasing k by one level, and recalculating the label collision rate, repeating the increasing level process until the label collision rate of the rendered map falls within the hysteresis interval, stopping the cycle, and obtaining the maximum allowed display level k.
2. The method of dynamically loading vector maps according to claim 1, wherein, The spatial database and the relational database are generated by the following method: drawing a full-quantity map and storing the full-quantity map in the spatial database, the full-quantity map comprising full vector elements and full attribute information; allocating the same association code to each vector element included in the full vector elements and attribute information corresponding to the vector element; moving the attribute information and the association code corresponding to the attribute information to the relational database.
3. The method of dynamically loading vector maps of claim 2, wherein, After the attribute information and the association code corresponding to the attribute information are moved to the relational database, the method further comprises: receiving an attribute information modification request, the attribute information modification request carrying a place name to be modified attribute information and a modification requirement; from the relational database, determining attribute information to which the place name to be modified attribute information belongs; based on the modification requirement, performing a modification operation on the attribute information.
4. The method of claim 1, wherein, The splitting of the map display request into the vector data request and the attribute data request comprises: Obtaining a geographical name mark corresponding to the target geographical name from a correspondence between geographical names and geographical name marks; Obtaining an associated code corresponding to the geographical name mark from a correspondence between geographical name marks and associated code marks stored in advance; Generating the vector data request based on the associated code and a first identifier of the spatial database, and generating the attribute data request based on the associated code and a second identifier of the relational database.
5. The method of dynamically loading vector maps of claim 4, wherein, The process of obtaining vector elements and attribute information is as follows: Identifying the spatial database based on the first identifier, and querying the vector element corresponding to the associated code from the spatial database based on the associated code; Identifying the relational database based on the second identifier, and querying the attribute information corresponding to the associated code from the relational database based on the associated code.
6. The method of claim 1, wherein, The method for obtaining the display level corresponding to the target geographical name, and sending the display level and the layer data to the terminal, so that the terminal renders a map and displays according to the display level and the layer data, comprises: Setting a rendering layer array in the terminal, which is used to dynamically display the layer data to be rendered by the map; Obtaining the zoom level of the map being displayed at the current time; When the display level is less than or equal to the current zoom level of the map, determining whether the rendering layer exists, and if not, adding the layer data to the layer rendering data group; When the display level is greater than the zoom level, determining whether the rendering layer exists, if yes, removing the layer data from the layer rendering data group, and if not, not adding the layer data to the layer rendering data group.
7. A computer device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor executes the computer program to implement the method for dynamically loading a vector map according to any one of claims 1-6.
8. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the method for dynamically loading a vector map according to any one of claims 1-6.
9. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the method for dynamically loading a vector map according to any one of claims 1-6.
Citation Information
Patent Citations
High-performance rapid rendering method for large vector data
CN112395073A
Mobile terminal APP embedded configuration graph rendering method and device and storage medium thereof
CN118467056A