A method and system for generating line density of a grid structure based on length aggregation
Through the method of generating line density based on length aggregation, the problem of low calculation efficiency of line density visualization in the prior art is solved, and the effect of quickly calculating the approximate value of the line density function is achieved.
Patent Information
- Application Number
- CN202411529099.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-30
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2044-10-30
AI Technical Summary
The algorithm used by software systems that realize line density visualization in the prior art has poor calculation efficiency and takes a long time to calculate the result of line density visualization.
The method of generating line density based on length aggregation is adopted. By obtaining the target line segment data set and grid construction data, the target grid structure is constructed, and the prefixes and matrices are initialized, traversed and updated in the grid structure, the upper and lower bound functions of squares or any shape are calculated, and the line density function approximation is generated.
The calculation efficiency of line density visualization is significantly improved, and the aggregated values of any rectangular range can be quickly calculated based on existing methods to obtain an approximate value of the line density function without affecting the visualization quality.
Smart Images

Figure CN119046601B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer science and technology, and in particular to a method and system for generating line density of a grid structure based on length aggregation. Background Art
[0002] Line density visualization is a GIS tool widely used in different fields. Currently, some existing line density visualization tools are usually used to analyze line segment datasets. However, the algorithms used by existing software systems for line density visualization take a long time to calculate line density visualization, and the calculation efficiency is poor.
[0003] Therefore, the prior art still needs to be improved and developed. Summary of the invention
[0004] The main purpose of the present invention is to provide a method, system, terminal and computer-readable storage medium for generating line density from a grid structure based on length aggregation, aiming to solve the problem that the algorithm used in the software system for realizing line density visualization in the prior art takes a long time to calculate the line density visualization and has poor calculation efficiency.
[0005] To achieve the above object, the present invention provides a method for generating line density of a grid structure based on length aggregation, and the method for generating line density of a grid structure based on length aggregation comprises the following steps:
[0006] Acquire a target line segment data set and mesh construction data, and construct a target mesh structure on the target line segment data set according to the mesh construction data;
[0007] Initializing the target grid structure, scanning the intersection result between the target grid structure and the target line segment data set, and adding the intersection result to the corresponding target grid structure to obtain a first target grid structure;
[0008] Traversing the first target grid structure, calculating the prefix sum matrix of each grid in the first target grid structure according to a prefix sum matrix calculation formula, updating the first target grid structure according to each of the prefix sum matrices, and obtaining a second target network structure;
[0009] According to the target line segment data set, the upper and lower bound functions of the square are calculated in the second target network structure, and it is determined whether the upper and lower bound functions of the square meet the relative error requirements. When satisfied, the line density function approximation is generated according to the upper and lower bound functions of the square and output.
[0010] Optionally, the acquiring a target line segment data set and mesh construction data, and constructing a target mesh structure on the target line segment data set according to the mesh construction data, specifically includes:
[0011] Acquire a target line segment data set and mesh construction data, wherein the mesh construction data includes a line density visualization resolution and a visualization range;
[0012] Obtaining the pixel size of the current screen where the target line segment data set is located, generating a grid resolution according to the line density visualization resolution, and setting a grid size according to the pixel size;
[0013] A target grid structure is constructed on the target line segment data set according to the grid resolution, the grid size, and the visualization range.
[0014] Optionally, the initializing the target grid structure, scanning the intersection result of the target grid structure and the target line segment data set, and adding the intersection result to the corresponding target grid structure to obtain the first target grid structure specifically includes:
[0015] Initialize the target grid structure and set the value in the target grid structure to 0;
[0016] The length occupied by the target line segment data set in each grid of the target grid structure is scanned, a corresponding intersection result is generated according to each length, and the intersection result is added to the target grid structure to generate a first target grid structure.
[0017] Optionally, traversing the first target grid structure, calculating the prefix sum matrix of each grid in the first target grid structure according to a prefix sum matrix calculation formula, updating the first target grid structure according to each prefix sum matrix, and obtaining the second target network structure specifically includes:
[0018] Traversing the first target grid structure, and calculating the prefix sum matrix of each grid in the first target grid structure by using the prefix sum matrix calculation formula according to the intersection result of each grid in the first target grid structure;
[0019] In the first target grid structure, the corresponding intersection result is replaced by the prefix sum matrix of each grid, so as to complete the update of the first target grid structure and obtain the second target grid structure.
[0020] Optionally, the traversing the first target grid structure and calculating the prefix sum matrix of each grid in the first target grid structure by using the prefix sum matrix calculation formula according to the intersection result of each grid in the first target grid structure specifically includes:
[0021] Traversing the first target grid structure, for each grid in the first target grid structure, using the prefix sum matrix calculation formula to calculate the prefix sum matrix of each grid in the first target grid structure according to the intersection result between the corresponding grid and other grids;
[0022] Wherein, the prefix and matrix calculation formula is expressed as: ;
[0023] The calculation process of the prefix and matrix calculation formula is expressed as:
[0024] ,
[0025] express OK The prefix sum matrix of the column grid, Indicates access to the first target grid structure OK The grid where the column is located, express OK The prefix sum matrix of the column grid, express OK The prefix sum matrix of the column grid, express OK The prefix sum matrix of the column grid, and Indicates the row and column where the current grid is located in the grid. Indicates access to the first target grid structure OK The grid where the column is located, and Represents the rows and columns of the first target grid structure.
[0026] Optionally, the step of calculating upper and lower bound functions of a square in the second target network structure according to the target line segment data set, and determining whether the upper and lower bound functions of the square meet relative error requirements, and when satisfied, generating and outputting an approximate value of a line density function according to the upper and lower bound functions of the square, specifically includes:
[0027] According to the target line segment data set, obtaining upper and lower bounds of a square in the second target network structure, and calculating upper and lower bound functions of the square according to the upper and lower bounds of the square and the prefix and matrix of each grid in the second target network structure;
[0028] Determine whether the upper and lower bound functions of the square meet the relative error requirements;
[0029] When the upper and lower bound functions of the square meet the relative error requirement, the mean of the upper and lower bound functions of the square is used as an approximate value of the line density function and output.
[0030] Optionally, the determining whether the upper and lower bound functions of the square meet the relative error requirement further includes:
[0031] When the upper and lower bound functions of the square do not meet the relative error requirement, obtaining upper and lower bounds of arbitrary shapes in the second target network structure according to the target line segment data set, and calculating upper and lower bound functions of arbitrary shapes according to the upper and lower bounds of arbitrary shapes and the prefix sum matrix of each grid in the second target network structure;
[0032] Determine whether the upper and lower bound functions of the arbitrary shape meet the relative error requirements;
[0033] When the upper and lower bound functions of the arbitrary shape meet the relative error requirement, the mean of the upper and lower bound functions of the arbitrary shape is used as the approximate value of the line density function and output.
[0034] In addition, to achieve the above-mentioned purpose, the present invention further provides a system for generating line density based on a grid structure of length aggregation, wherein the system for generating line density based on a grid structure of length aggregation comprises:
[0035] A grid structure construction module, used to obtain a target line segment data set and grid construction data, and to construct a target grid structure on the target line segment data set according to the grid construction data;
[0036] A first target grid structure construction module is used to initialize the target grid structure, scan the intersection result of the target grid structure and the target line segment data set, and add the intersection result to the corresponding target grid structure to obtain a first target grid structure;
[0037] A second target network structure construction module is used to traverse the first target grid structure, calculate the prefix sum matrix of each grid in the first target grid structure according to the prefix sum matrix calculation formula, update the first target grid structure according to each of the prefix sum matrices, and obtain a second target network structure;
[0038] A line density function approximation output module is used to calculate the upper and lower bound functions of the square in the second target network structure according to the target line segment data set, and to determine whether the upper and lower bound functions of the square meet the relative error requirements. If so, an approximation of the line density function is generated according to the upper and lower bound functions of the square and outputted.
[0039] In addition, to achieve the above-mentioned purpose, the present invention also provides a terminal, wherein the terminal includes: a memory, a processor, and a program for generating line density from a grid structure based on length aggregation, which is stored in the memory and can be run on the processor, and when the program for generating line density from a grid structure based on length aggregation is executed by the processor, the steps of the method for generating line density from a grid structure based on length aggregation as described above are implemented.
[0040] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a program for generating line density from a grid structure based on length aggregation, and when the program for generating line density from a grid structure based on length aggregation is executed by a processor, the steps of the method for generating line density from a grid structure based on length aggregation as described above are implemented.
[0041] In the present invention, a target line segment data set and a grid construction data are obtained, and a target grid structure is constructed on the target line segment data set according to the grid construction data; the target grid structure is initialized, the intersection result of the target grid structure and the target line segment data set is scanned, and the intersection result is added to the corresponding target grid structure to obtain a first target grid structure; the first target grid structure is traversed, and the prefix sum matrix of each grid in the first target grid structure is calculated according to a prefix sum matrix calculation formula, and the first target grid structure is updated according to each prefix sum matrix to obtain a second target network structure; according to the target line segment data set, the upper and lower bound functions of the square are calculated in the second target network structure, and it is determined whether the upper and lower bound functions of the square meet the relative error requirements. When satisfied, a line density function approximation is generated according to the upper and lower bound functions of the square and output. The present invention establishes a grid structure based on length aggregation, in which each grid needs to store the total length of the line segments in the grid, and then establishes prefix sum matrices for these grids, so that information that can be used to calculate upper and lower bound functions is stored in the corresponding network structure. The corresponding upper and lower bound functions of the designed square and the upper and lower bound functions of any shape are used to approximate the line density function, so that the present invention can quickly calculate the aggregation value of any rectangular range to obtain the corresponding approximate value of the line density function. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 It is a flow chart of a preferred embodiment of a method for generating line density based on a grid structure of length aggregation of the present invention;
[0043] Figure 2 is a schematic diagram of a target grid structure in a method for generating line density from a grid structure based on length aggregation of the present invention;
[0044] Figure 3is a schematic diagram of a first target grid structure in a method for generating line density based on a grid structure of length aggregation of the present invention;
[0045] Figure 4 It is a schematic diagram of a second target network structure in the method for generating line density based on a grid structure of length aggregation of the present invention;
[0046] Figure 5 It is a schematic diagram of the upper and lower bound functions of a square and the upper and lower bound functions of an arbitrary shape in the method for generating line density based on the grid structure of length aggregation of the present invention;
[0047] Figure 6 It is a schematic diagram of the response time of different methods for generating line density visualization when the resolution size is changed in one embodiment of the method for generating line density based on the grid structure of length aggregation of the present invention;
[0048] Figure 7 It is a schematic diagram of the response time of different methods for generating line density visualization when the bandwidth size is changed in one embodiment of the method for generating line density based on the grid structure of length aggregation of the present invention;
[0049] Figure 8 It is a schematic diagram of an embodiment of the method for generating line density based on a grid structure of length aggregation of the present invention, in which other methods and the method for generating line density based on a grid structure of length aggregation are used to generate line density visualization;
[0050] Fig. 9 It is a structural diagram of a preferred embodiment of a system for generating line density based on a grid structure of length aggregation of the present invention;
[0051] Fig.10 It is a structural diagram of a preferred embodiment of the terminal of the present invention. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solution and advantages of the present invention clearer and more specific, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0053] Line density visualization is a GIS tool widely used in different fields. At present, some existing line density visualization tools are usually used to analyze line segment data sets. However, the algorithms used by existing software systems for implementing line density visualization take a long time to calculate line density visualization. For example, the effective algorithms based on spatial connection query and line segment query mainly focus on relatively simple line segment-based queries. These queries do not need to calculate the density function of more complex line density visualization. Therefore, they cannot be easily extended to solve the problem of line density visualization. In the effective algorithms for kernel density visualization, since line density visualization is based on line segments rather than position data points, all these effective algorithms and their theoretical results in kernel density visualization cannot be extended to generate line density visualization. The effective algorithms for moving object query do not focus on calculating line density functions, which cannot be used to improve the efficiency of generating line density visualization. In the tree-based index structure, line segments close to pixels cannot be effectively processed, and its efficiency performance is poor. The grid-based index structure mainly focuses on location point data rather than line segment data, and cannot be extended to generate line density visualization. Therefore, the algorithms used by the current software systems for implementing line density visualization have poor calculation efficiency.
[0054] In response to one or more of the above problems, the present application obtains a target line segment data set and a grid construction data, constructs a target grid structure on the target line segment data set according to the grid construction data; initializes the target grid structure, scans the intersection results of the target grid structure and the target line segment data set, and adds the intersection results to the corresponding target grid structure to obtain a first target grid structure; traverses the first target grid structure, calculates the prefix sum matrix of each grid in the first target grid structure according to a prefix sum matrix calculation formula, updates the first target grid structure according to each prefix sum matrix, and obtains a second target network structure; calculates the upper and lower bound functions of the square in the second target network structure according to the target line segment data set, and determines whether the upper and lower bound functions of the square meet the relative error requirements. When satisfied, generates and outputs an approximate value of the line density function according to the upper and lower bound functions of the square.
[0055] The method for generating line density of a grid structure based on length aggregation described in a preferred embodiment of the present invention is as follows: Figure 1 As shown, the method for generating line density of the grid structure based on length aggregation includes the following steps:
[0056] Step S10: Acquire a target line segment data set and mesh construction data, and construct a target mesh structure on the target line segment data set according to the mesh construction data.
[0057] Specifically, in this application, a length aggregation-based grid structure LARGE is proposed to process all types of line segment data sets, that is, for each corresponding line segment data set, a corresponding target network structure can be constructed through this network structure.
[0058] Furthermore, the acquiring of the target line segment data set and the mesh construction data, and constructing the target mesh structure on the target line segment data set according to the mesh construction data, specifically includes:
[0059] Acquire a target line segment data set and mesh construction data, wherein the mesh construction data includes a line density visualization resolution and a visualization range;
[0060] Obtaining the pixel size of the current screen where the target line segment data set is located, generating a grid resolution according to the line density visualization resolution, and setting a grid size according to the pixel size;
[0061] A target grid structure is constructed on the target line segment data set according to the grid resolution, the grid size, and the visualization range.
[0062] Specifically, the target line segment data set and grid construction data are obtained, wherein the grid construction data includes a line density visualization resolution of size X×Y (X×Y represents the resolution size, X represents the horizontal resolution, and Y represents the vertical resolution) and a visualization range. The grid resolution size can be obtained from the line density visualization resolution as 3X×3Y, wherein 3X×3Y represents the resolution size, 3X represents the horizontal resolution, and 3Y represents the vertical resolution. The corresponding grid size is the pixel size of the current screen where the current target line segment data set is located. Correspondingly, in this application, within the visualization range, the pixel size is used as the grid size, and a grid containing line density visualization and a resolution of 3X×3Y is established, which is the target grid structure.
[0063] Furthermore, if Figure 2 As shown in the figure, it is a corresponding target grid structure, where the position covered by the grid is the visualization range. The corresponding grid is built on the target line segment dataset, and the grids where the target grid structure and the line segments in the target line segment dataset intersect are filled with different colors. The grids with two or more line segments are filled with a color different from the other colors. Figure 2 In, consider , , 、 、 and The six line segments are used as the target line segment data set, and a target grid structure is established in the pixel plane, and the grids where the line segments intersect with the target grid structure are filled with different colors.
[0064] Step S20: Initialize the target grid structure, scan the intersection result between the target grid structure and the target line segment data set, and add the intersection result to the corresponding target grid structure to obtain a first target grid structure.
[0065] Specifically, in the present application, in the target grid structure, the corresponding intersection result is added to obtain the corresponding first target grid structure. The intersection result of the scanned target grid structure and the target line segment data set is to sequentially calculate the length of each line segment intersecting with the grid.
[0066] Further, the initializing the target grid structure, scanning the intersection result of the target grid structure and the target line segment data set, and adding the intersection result to the corresponding target grid structure to obtain the first target grid structure specifically includes:
[0067] Initialize the target grid structure and set the value in the target grid structure to 0;
[0068] The length occupied by the target line segment data set in each grid of the target grid structure is scanned, a corresponding intersection result is generated according to each length, and the intersection result is added to the target grid structure to generate a first target grid structure.
[0069] Specifically, in the present application, for the target grid structure, it is first initialized, the value in the target grid structure is set to 0, and each line segment is scanned to find the grid where the line segment intersects with the structure, and the length of the line segment in the grid is obtained. When there are multiple line segments in a grid, the lengths of all the line segments are added together, and the obtained length is used as the intersection result and added to the corresponding target grid structure to generate the first target grid structure.
[0070] Furthermore, if Figure 3 As shown, in this application, Figure 2 On the basis of , the length of the corresponding line segment in the corresponding grid is added to each grid, and the Figure 3 The first target grid structure, in Figure 3 The value in the grid is 9.8, that is Figure 2 In and The result of adding in this grid is Intersecting with 4 grids, the corresponding Figure 3 The corresponding areas in the middle are filled with light blue and the corresponding intersection results are added.
[0071] Step S30, traverse the first target grid structure, calculate the prefix sum matrix of each grid in the first target grid structure according to the prefix sum matrix calculation formula, update the first target grid structure according to each of the prefix sum matrices, and obtain a second target network structure.
[0072] Specifically, in the present application, for the first target grid structure, the prefix sum matrix of each grid is calculated accordingly, thereby obtaining the second target grid structure.
[0073] Further, traversing the first target grid structure, calculating the prefix sum matrix of each grid in the first target grid structure according to a prefix sum matrix calculation formula, updating the first target grid structure according to each prefix sum matrix, and obtaining the second target network structure specifically includes:
[0074] Traversing the first target grid structure, and calculating the prefix sum matrix of each grid in the first target grid structure by using the prefix sum matrix calculation formula according to the intersection result of each grid in the first target grid structure;
[0075] In the first target grid structure, the corresponding intersection result is replaced by the prefix sum matrix of each grid, so as to complete the update of the first target grid structure and obtain the second target grid structure.
[0076] Specifically, in the present application, for the first network structure, the corresponding prefix sum matrix is calculated for each grid therein, and after the calculation is completed, the second target grid structure is obtained. The second target network structure is as follows Figure 4 As shown, based on the first target grid structure, the grids are filled with the same color, and the corresponding prefix and matrix are added to each grid.
[0077] Further, the traversing the first target grid structure and calculating the prefix sum matrix of each grid in the first target grid structure by using the prefix sum matrix calculation formula according to the intersection result of each grid in the first target grid structure specifically includes:
[0078] Traversing the first target grid structure, for each grid in the first target grid structure, using the prefix sum matrix calculation formula to calculate the prefix sum matrix of each grid in the first target grid structure according to the intersection result between the corresponding grid and other grids;
[0079] Wherein, the prefix and matrix calculation formula is expressed as: ;
[0080] The calculation process of the prefix and matrix calculation formula is expressed as:
[0081] ,
[0082] express OK The prefix sum matrix of the column grid, Indicates access to the first target grid structure OK The grid where the column is located, express OK The prefix sum matrix of the column grid, express OK The prefix sum matrix of the column grid, express OK The prefix sum matrix of the column grid, and Indicates the row and column where the current grid is located in the grid. Indicates access to the first target grid structure OK The grid where the column is located, and Represents the rows and columns of the first target grid structure.
[0083] Specifically, when calculating the prefix sum matrix of each grid, the corresponding prefix sum matrix calculation formula is used. When the corresponding prefix sum matrix of each grid is obtained, the length aggregation value of any rectangular range can be quickly calculated, such as Figure 4 As shown, when calculating the length aggregation value in the box, a maximum of 4 prefix sum matrices are accessed to calculate it, that is, 41.1-22.3-24.8+15=9.
[0084] Step S40: According to the target line segment data set, the upper and lower bound functions of the square are calculated in the second target network structure, and it is determined whether the upper and lower bound functions of the square meet the relative error requirements. If so, an approximate value of the line density function is generated according to the upper and lower bound functions of the square and outputted.
[0085] Specifically, after obtaining the corresponding second target network structure, the upper and lower bound functions of each square can be quickly calculated.
[0086] Further, the method further comprises: calculating the upper and lower bound functions of a square in the second target network structure according to the target line segment data set, and determining whether the upper and lower bound functions of the square meet the relative error requirements; if so, generating and outputting the approximate value of the line density function according to the upper and lower bound functions of the square, specifically comprising:
[0087] According to the target line segment data set, obtaining upper and lower bounds of a square in the second target network structure, and calculating upper and lower bound functions of the square according to the upper and lower bounds of the square and the prefix and matrix of each grid in the second target network structure;
[0088] Determine whether the upper and lower bound functions of the square meet the relative error requirements;
[0089] When the upper and lower bound functions of the square meet the relative error requirement, the mean of the upper and lower bound functions of the square is used as an approximate value of the line density function and output.
[0090] Specifically, in this application, the upper and lower bound functions include upper and lower bound functions. The upper and lower bound functions of the square are calculated first, which are faster but looser, such as Figure 5 (a) and (b) of the invention, for the square upper bound function and the square lower bound function, the length aggregation value in the corresponding colored grid is calculated respectively, and when calculating, the prefix and matrix of each grid in the second target network structure can be used for corresponding calculation. Then, it is judged whether the upper and lower bound functions of the square meet the relative error requirements. If they meet the requirements, it means that the upper and lower bound functions of the square can be used to approximate the line density function at this time, and the mean of the upper and lower bound functions of the square is used as the approximate value of the line density function and output.
[0091] Further, the step of judging whether the upper and lower bound functions of the square meet the relative error requirement further includes:
[0092] When the upper and lower bound functions of the square do not meet the relative error requirement, obtaining upper and lower bounds of arbitrary shapes in the second target network structure according to the target line segment data set, and calculating upper and lower bound functions of arbitrary shapes according to the upper and lower bounds of arbitrary shapes and the prefix sum matrix of each grid in the second target network structure;
[0093] Determine whether the upper and lower bound functions of the arbitrary shape meet the relative error requirements;
[0094] When the upper and lower bound functions of the arbitrary shape meet the relative error requirement, the mean of the upper and lower bound functions of the arbitrary shape is used as the approximate value of the line density function and output.
[0095] When the upper and lower bound functions of the square do not meet the relative error requirements, it means that the upper and lower bound functions of the square cannot be used to approximate the line density function. Then, a slower but tighter upper and lower bound function of any shape is used, such as Figure 5(c) and (d) of the present invention, after calculating the upper and lower bound functions of arbitrary shapes, it is also determined whether the upper and lower bound functions of arbitrary shapes meet the relative error requirements. If they meet the requirements, it means that the upper and lower bound functions of arbitrary shapes can be used to approximate the line density function. The mean of the upper and lower bound functions of arbitrary shapes is used as the approximate value of the line density function and output.
[0096] The relative error requirement is ,in, is a value given by the user. In one embodiment of the present application, =0.05.
[0097] When the upper and lower bound functions of arbitrary shapes do not meet the relative error requirements, a slower method in the prior art is used for calculation.
[0098] Furthermore, in this application, four line segment datasets are selected, including bicycle flow datasets, taxi flow datasets, taxi flow datasets and personnel flow datasets in different regions, to test different existing methods for generating line density visualization. The existing methods for generating line density visualization include: linear pixel scanning algorithm SCAN, line segment scanning algorithm SCAN line , R-tree algorithm and PMR quadtree algorithm, we get Figure 6 and Figure 7 The results shown. Figure 6 and Figure 7 visible, Figure 6 and Figure 7 The corresponding (a), (b), (c) and (d) are respectively obtained by testing different existing methods of generating line density visualization using bicycle flow data sets, taxi flow data sets, taxi flow data sets and personnel flow data sets in different regions. When changing the resolution and bandwidth size, the method of the present invention can be 2.35 times to 291.8 times faster than the existing methods. At the same time, Figure 8 In the present invention, the bicycle flow data set is visualized using the method of the present invention and other methods, wherein the other method is SCAN. The results show that the method of the present application does not affect the final visualization quality.
[0099] The present invention obtains a target line segment data set and grid construction data, constructs a target grid structure on the target line segment data set according to the grid construction data; initializes the target grid structure, scans the intersection result of the target grid structure and the target line segment data set, and adds the intersection result in the corresponding target grid structure to obtain a first target grid structure; traverses the first target grid structure, calculates the prefix sum matrix of each grid in the first target grid structure according to a prefix sum matrix calculation formula, updates the first target grid structure according to each prefix sum matrix, and obtains a second target network structure; calculates the upper and lower bound functions of a square in the second target network structure according to the target line segment data set, and determines whether the upper and lower bound functions of the square meet the relative error requirements. When satisfied, generates and outputs a line density function approximation according to the upper and lower bound functions of the square. The present invention establishes a grid structure based on length aggregation, in which each grid needs to store the total length of the line segments in the grid, and then establishes prefix sum matrices for these grids, so that information that can be used to calculate upper and lower bound functions is stored in the corresponding network structure. The corresponding upper and lower bound functions of the designed square and the upper and lower bound functions of any shape are used to approximate the line density function, so that the present invention can quickly calculate the aggregation value of any rectangular range to obtain the corresponding approximate value of the line density function.
[0100] Furthermore, if Fig. 9 As shown, based on the above-mentioned method for generating line density from a grid structure based on length aggregation, the present invention also provides a system for generating line density from a grid structure based on length aggregation, wherein the system for generating line density from a grid structure based on length aggregation includes:
[0101] A grid structure construction module 91 is used to obtain a target line segment data set and grid construction data, and to construct a target grid structure on the target line segment data set according to the grid construction data;
[0102] A first target grid structure construction module 92 is used to initialize the target grid structure, scan the intersection result of the target grid structure and the target line segment data set, and add the intersection result to the corresponding target grid structure to obtain a first target grid structure;
[0103] A second target network structure building module 93 is used to traverse the first target grid structure, calculate the prefix sum matrix of each grid in the first target grid structure according to the prefix sum matrix calculation formula, and update the first target grid structure according to each of the prefix sum matrices to obtain a second target network structure;
[0104] The line density function approximation output module 94 is used to calculate the upper and lower bound functions of the square in the second target network structure according to the target line segment data set, and to determine whether the upper and lower bound functions of the square meet the relative error requirements. If so, the line density function approximation is generated according to the upper and lower bound functions of the square and outputted.
[0105] Furthermore, if Fig.10 As shown, based on the above-mentioned method and system for generating line density of a grid structure based on length aggregation, the present invention also provides a terminal accordingly, and the terminal includes a processor 10, a memory 20 and a display 30. Fig.10 Only some components of the terminal are shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.
[0106] In some embodiments, the memory 20 may be an internal storage unit of the terminal, such as a hard disk or memory of the terminal. In other embodiments, the memory 20 may also be an external storage device of the terminal, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc. equipped on the terminal. Furthermore, the memory 20 may also include both an internal storage unit of the terminal and an external storage device. The memory 20 is used to store application software and various types of data installed in the terminal, such as the program code of the installation terminal. The memory 20 may also be used to temporarily store data that has been output or is to be output. In one embodiment, a program 40 for generating line density based on a grid structure of length aggregation is stored on the memory 20, and the program 40 for generating line density based on a grid structure of length aggregation can be executed by the processor 10, thereby realizing the method for generating line density based on a grid structure of length aggregation in the present application.
[0107] In some embodiments, the processor 10 may be a central processing unit (CPU), a microprocessor or other data processing chip, used to run the program code or process data stored in the memory 20, such as executing the method for generating line density of the grid structure based on length aggregation.
[0108] In some embodiments, the display 30 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, etc. The display 30 is used to display information on the terminal and to display a visual user interface. The components of the terminal communicate with each other via a system bus.
[0109] In one embodiment, when the processor 10 executes the program 40 for generating line density based on a grid structure of length aggregation in the memory 20 , the steps of the above method for generating line density based on a grid structure of length aggregation are implemented.
[0110] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a program for generating line density from a grid structure based on length aggregation, and when the program for generating line density from a grid structure based on length aggregation is executed by a processor, the steps of the method for generating line density from a grid structure based on length aggregation as described above are implemented.
[0111] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the existence of other identical elements in the process, method, article or terminal including the element.
[0112] Of course, those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware (such as a processor, a controller, etc.) through a computer program, and the program can be stored in a computer-readable storage medium that can be read by a computer, and the program can include the processes of the above-mentioned method embodiments when executed. The computer-readable storage medium can be a memory, a disk, an optical disk, etc.
[0113] It should be understood that the application of the present invention is not limited to the above examples. For ordinary technicians in this field, improvements or changes can be made based on the above description. All these improvements and changes should fall within the scope of protection of the claims attached to the present invention.
Claims
1. A method for generating line density of a grid structure based on length aggregation, characterized in that: The method for generating line density of a grid structure based on length aggregation includes: Acquire a target line segment data set and mesh construction data, and construct a target mesh structure on the target line segment data set according to the mesh construction data; Initializing the target grid structure, scanning the intersection result between the target grid structure and the target line segment data set, and adding the intersection result to the corresponding target grid structure to obtain a first target grid structure; Traversing the first target grid structure, calculating the prefix sum matrix of each grid in the first target grid structure according to a prefix sum matrix calculation formula, updating the first target grid structure according to each of the prefix sum matrices, and obtaining a second target network structure; According to the target line segment data set, the upper and lower bound functions of the square are calculated in the second target network structure, and it is determined whether the upper and lower bound functions of the square meet the relative error requirements. If so, an approximate value of the line density function is generated according to the upper and lower bound functions of the square and outputted; The acquiring of the target line segment data set and the grid construction data, and constructing the target grid structure on the target line segment data set according to the grid construction data specifically includes: Acquire a target line segment data set and mesh construction data, wherein the mesh construction data includes a line density visualization resolution and a visualization range; Obtaining the pixel size of the current screen where the target line segment data set is located, generating a grid resolution according to the line density visualization resolution, and setting a grid size according to the pixel size; A target grid structure is constructed on the target line segment data set according to the grid resolution, the grid size, and the visualization range.
2. The method for generating line density of a grid structure based on length aggregation according to claim 1, characterized in that: Initializing the target grid structure, scanning the intersection result of the target grid structure and the target line segment data set, and adding the intersection result to the corresponding target grid structure to obtain the first target grid structure specifically includes: Initialize the target grid structure and set the value in the target grid structure to 0; The length occupied by the target line segment data set in each grid of the target grid structure is scanned, a corresponding intersection result is generated according to each length, and the intersection result is added to the target grid structure to generate a first target grid structure.
3. The method for generating line density of a grid structure based on length aggregation according to claim 1, characterized in that: The traversing the first target grid structure, calculating the prefix sum matrix of each grid in the first target grid structure according to a prefix sum matrix calculation formula, and updating the first target grid structure according to each prefix sum matrix to obtain a second target network structure specifically includes: Traversing the first target grid structure, and calculating the prefix sum matrix of each grid in the first target grid structure by using the prefix sum matrix calculation formula according to the intersection result of each grid in the first target grid structure; In the first target grid structure, the corresponding intersection result is replaced by the prefix and matrix of each grid, so as to complete the update of the first target grid structure and obtain the second target network structure.
4. The method for generating line density of a grid structure based on length aggregation according to claim 3, characterized in that: The traversing the first target grid structure and calculating the prefix sum matrix of each grid in the first target grid structure by using the prefix sum matrix calculation formula according to the intersection result of each grid in the first target grid structure specifically includes: Traversing the first target grid structure, for each grid in the first target grid structure, using the prefix sum matrix calculation formula to calculate the prefix sum matrix of each grid in the first target grid structure according to the intersection result between the corresponding grid and other grids; Wherein, the prefix and matrix calculation formula is expressed as: ; The calculation process of the prefix and matrix calculation formula is expressed as: , express OK The prefix sum matrix of the column grid, Indicates access to the first target grid structure OK The grid where the column is located, express OK The prefix sum matrix of the column grid, express OK The prefix sum matrix of the column grid, express OK The prefix sum matrix of the column grid, Indicates the row and column where the current grid is located in the grid. Indicates access to the first target grid structure OK The grid where the column is located, and Represents the rows and columns of the first target grid structure.
5. The method for generating line density of a grid structure based on length aggregation according to claim 1, characterized in that: The step of calculating the upper and lower bound functions of a square in the second target network structure according to the target line segment data set and determining whether the upper and lower bound functions of the square meet the relative error requirements, and if so, generating and outputting an approximate value of a line density function according to the upper and lower bound functions of the square, specifically includes: According to the target line segment data set, obtaining upper and lower bounds of a square in the second target network structure, and calculating upper and lower bound functions of the square according to the upper and lower bounds of the square and the prefix and matrix of each grid in the second target network structure; Determine whether the upper and lower bound functions of the square meet the relative error requirements; When the upper and lower bound functions of the square meet the relative error requirement, the mean of the upper and lower bound functions of the square is used as an approximate value of the line density function and output.
6. The method for generating line density of a grid structure based on length aggregation according to claim 1, characterized in that: The step of judging whether the upper and lower bound functions of the square meet the relative error requirement further includes: When the upper and lower bound functions of the square do not meet the relative error requirement, obtaining upper and lower bounds of arbitrary shapes in the second target network structure according to the target line segment data set, and calculating upper and lower bound functions of arbitrary shapes according to the upper and lower bounds of arbitrary shapes and the prefix sum matrix of each grid in the second target network structure; Determine whether the upper and lower bound functions of the arbitrary shape meet the relative error requirements; When the upper and lower bound functions of the arbitrary shape meet the relative error requirement, the mean of the upper and lower bound functions of the arbitrary shape is used as the approximate value of the line density function and output.
7. A system for generating line density of a grid structure based on length aggregation, characterized in that: The system for generating line density of a grid structure based on length aggregation includes: A grid structure construction module, used to obtain a target line segment data set and grid construction data, and to construct a target grid structure on the target line segment data set according to the grid construction data; A first target grid structure construction module is used to initialize the target grid structure, scan the intersection result of the target grid structure and the target line segment data set, and add the intersection result to the corresponding target grid structure to obtain a first target grid structure; A second target network structure construction module is used to traverse the first target grid structure, calculate the prefix sum matrix of each grid in the first target grid structure according to the prefix sum matrix calculation formula, update the first target grid structure according to each of the prefix sum matrices, and obtain a second target network structure; A line density function approximation output module is used to calculate the upper and lower bound functions of the square in the second target network structure according to the target line segment data set, and determine whether the upper and lower bound functions of the square meet the relative error requirements. If so, generate and output the line density function approximation according to the upper and lower bound functions of the square; The acquiring of the target line segment data set and the grid construction data, and constructing the target grid structure on the target line segment data set according to the grid construction data specifically includes: Acquire a target line segment data set and mesh construction data, wherein the mesh construction data includes a line density visualization resolution and a visualization range; Obtaining the pixel size of the current screen where the target line segment data set is located, generating a grid resolution according to the line density visualization resolution, and setting a grid size according to the pixel size; A target grid structure is constructed on the target line segment data set according to the grid resolution, the grid size, and the visualization range.
8. A terminal, characterized in that: The terminal includes: a memory, a processor, and a program for generating line density from a grid structure based on length aggregation, which is stored in the memory and can be run on the processor. When the program for generating line density from a grid structure based on length aggregation is executed by the processor, the steps of the method for generating line density from a grid structure based on length aggregation as described in any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a program for generating line density from a grid structure based on length aggregation, and when the program for generating line density from a grid structure based on length aggregation is executed by a processor, the steps of the method for generating line density from a grid structure based on length aggregation as described in any one of claims 1-6 are implemented.
Citation Information
Patent Citations
A method for preprocessing map display data
CN102298640A
High-fidelity stress calculation method for topological optimization of structure under fixed grid
CN117993251A