Method, device, equipment, medium and computer program product for rasterizing spatial line objects

By using custom grids and quadtree spatial indexes to filter non-intersecting grid areas, the problem of redundant calculation of line object rasterization in existing technologies is solved, processing efficiency is improved, and the accuracy of the results is enhanced.

CN119025606BActive Publication Date: 2025-09-19CHINA MOBILE GROUP DESIGN INST +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411149748.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-21
Publication Date
2025-09-19
Estimated Expiration
2044-08-21

AI Technical Summary

Technical Problem

The existing technology has a lot of redundant calculations in the process of online object rasterization, resulting in low processing efficiency.

Method used

By customizing the raster and spatial index, especially the quadtree spatial index, non-intersecting raster areas can be filtered out to reduce redundant calculations.

Benefits of technology

It effectively improves the processing efficiency of spatial line object rasterization and can more accurately represent the geometric shape and topological information of line objects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119025606B_ABST
    Figure CN119025606B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, apparatus, device, medium, and computer program product for rasterizing spatial line objects. The method comprises: obtaining the longitude and latitude of a spatial line object and determining whether the longitude and latitude span of the spatial line object is greater than a preset longitude and latitude threshold; if so, performing fine-grained division of the UTM projection to obtain a custom grid, and filtering the custom grid using a custom spatial index to obtain a non-empty custom grid; if not, directly obtaining a non-empty custom grid; and rasterizing the spatial line object based on its geometric type and whether it is in the same non-empty custom grid; wherein the geometric type of the spatial line object includes single-line objects and multi-line objects. The present invention uses a custom grid and a custom spatial index to filter out a large number of non-intersecting grid areas, reducing redundant calculations and effectively improving processing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of rasterized spatial analysis technology, and in particular to a spatial line object rasterization method, device, equipment, medium and computer program product. Background Art

[0002] A spatial line object refers to a data object that represents linear geometric features in a GIS (Geographic Information System). It is usually composed of multiple coordinate points and line segments connecting these coordinate points to describe linear features in the real world, such as roads, rivers, and pipelines. Raster is also a common GIS data model, which divides geographic space into equal-sized pixel units in the form of a regular grid. Compared with spatial line objects, the raster data model offers the advantage of being more suitable for quantitative analysis and spatial statistics. It can effectively represent spatially continuous surfaces, such as elevation models and climate variables, and is also applicable to discrete categorical data. Raster data has some special functions in spatial analysis, such as neighborhood operations, buffer analysis, and raster algebraic operations. Therefore, the rasterization of spatial line objects is an urgent problem to be solved.

[0003] In existing line object rasterization methods, rasterization is usually performed by calculating the bounding box of the feature. Since the bounding box and rasterization process are performed on the entire feature, a large amount of redundant calculations may be generated, resulting in ineffective processing efficiency. Summary of the Invention

[0004] The technical problem to be solved by the present invention is to provide a spatial line object rasterization method, device, equipment, medium and computer program product, which filters out a large number of non-intersecting grid areas through custom grids and custom spatial indexes, reduces redundant calculations, and effectively improves processing efficiency.

[0005] To achieve the above object, an embodiment of the present invention provides a method for rasterizing a spatial line object, comprising:

[0006] Obtaining the longitude and latitude of the spatial line object, and determining whether the longitude and latitude span of the spatial line object is greater than a preset longitude and latitude threshold;

[0007] If yes, then fine-grained division is performed on the UTM projection to obtain a custom grid, and the custom grid is filtered using a custom spatial index to obtain a non-empty custom grid; if no, then a non-empty custom grid is directly obtained;

[0008] The spatial line objects are rasterized according to the geometric types of the spatial line objects and whether the spatial line objects are in the same non-empty custom grid; wherein the geometric types of the spatial line objects include single-line objects and multi-line objects.

[0009] As an improvement to the above solution, the custom grid is filtered using a custom spatial index to obtain a non-empty custom grid, including:

[0010] Using a quadtree spatial index to traverse each of the custom grids, and calculating whether the spatial line object exists in each of the custom grids;

[0011] If it exists, get the non-empty custom grid;

[0012] If it does not exist, empty custom rasters are filtered out.

[0013] As an improvement to the above solution, rasterizing the spatial line objects according to the geometric type of the spatial line objects and whether the spatial line objects are in the same non-empty custom grid includes:

[0014] For the multi-line object, obtaining the number and information of single-line objects in the multi-line object, traversing each single-line object, and rasterizing the single-line object according to whether the single-line object is in the same non-empty custom grid;

[0015] For the single-line object, rasterize the single-line object according to whether the single-line object is in the same non-empty custom grid.

[0016] As an improvement to the above solution, rasterizing the single-line objects according to whether the single-line objects are in the same non-empty custom grid includes:

[0017] Obtain all coordinate points of the single-line object, loop through all coordinate points, convert the latitude and longitude of adjacent coordinate points into grid IDs, and assign them to the first variable and the second variable respectively;

[0018] If the first variable is equal to the second variable, it is determined that the adjacent coordinate points are located in the same non-empty custom grid, and the line objects in the same grid are rasterized;

[0019] If the first variable is not equal to the second variable, it is determined that the adjacent coordinate points are located in different non-empty custom grids, and line objects between different grids are rasterized.

[0020] As an improvement to the above solution, the line objects within the same grid are rasterized, including:

[0021] According to the precision of the predefined rasterization, the start predefined raster identifier and the end predefined raster identifier are split into a head identifier and a precision identifier;

[0022] Determine the start and end indexes of the loop based on the indexes of the start and end coordinate points;

[0023] All indexes are traversed through two nested loops to generate the current predefined grid identifier;

[0024] Creating a grid object according to the current predefined grid identifier, and performing an intersection operation on the grid object and a preset line segment;

[0025] If the intersection result is not empty and the result type is a line segment, the length of the line segment is calculated, and corresponding grid information is added or updated in the dictionary according to the current predefined grid identifier.

[0026] As an improvement to the above solution, the rasterization of line objects between different grids includes:

[0027] By comparing the longitude and latitude of two coordinate points, the minimum longitude, minimum latitude, maximum longitude and maximum latitude are calculated;

[0028] Create a single line object, which represents a line segment consisting of two coordinate points;

[0029] Converting the minimum longitude and the minimum latitude into a starting predefined grid identifier, converting the starting predefined grid identifier back into longitude and latitude coordinates by calculation, and calculating the width and height of the predefined grid;

[0030] Calculating an average of the minimum longitude and the minimum latitude to obtain the starting longitude and starting latitude of the predefined grid;

[0031] Initialize the current longitude and the current latitude to the starting longitude and the starting latitude;

[0032] Converting the maximum longitude and the maximum latitude into an end predefined grid identifier, and converting the end predefined grid identifier back into longitude and latitude coordinates by calculation, and updating the maximum longitude and the maximum latitude;

[0033] Entering a loop starting from the starting longitude and the starting latitude, traversing each of the predefined grids one by one, and performing an intersection operation on the predefined grid and a preset line segment;

[0034] If the intersection result is not empty and the result type is a line segment, the length of the line segment is calculated, and corresponding grid information is added or updated in the dictionary according to the current predefined grid identifier.

[0035] An embodiment of the present invention further provides a spatial line object rasterization device, comprising:

[0036] An acquisition module, configured to acquire the longitude and latitude of a spatial line object and determine whether the longitude and latitude span of the spatial line object is greater than a preset longitude and latitude threshold;

[0037] A filtering module is used to, if yes, perform fine-grained division on the UTM projection to obtain a custom grid, and filter the custom grid using a custom spatial index to obtain a non-empty custom grid; if no, directly obtain a non-empty custom grid;

[0038] A grid module is used to rasterize the spatial line object according to the geometric type of the spatial line object and whether the spatial line object is in the same non-empty custom grid; wherein the geometric type of the spatial line object includes a single line object and a multi-line object.

[0039] An embodiment of the present invention also provides a terminal device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements any of the above-mentioned spatial line object rasterization methods when executing the computer program.

[0040] An embodiment of the present invention also provides a computer-readable storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute any of the above-mentioned spatial line object rasterization methods.

[0041] An embodiment of the present invention further provides a computer program product, which includes a computer program or computer instructions. When the computer program or the computer instructions are executed by a processor, any of the above-mentioned spatial line object rasterization methods is implemented.

[0042] Compared to the prior art, the present invention provides a method, apparatus, device, medium, and computer program product for rasterizing spatial line objects. The method obtains the longitude and latitude of a spatial line object and determines whether the longitude and latitude span of the spatial line object is greater than a preset longitude and latitude threshold. If so, the UTM projection is finely divided to obtain a custom grid, and the custom grid is filtered using a custom spatial index to obtain a non-empty custom grid. If not, a non-empty custom grid is directly obtained. The spatial line object is rasterized based on its geometric type and whether it is in the same non-empty custom grid. The geometric type of the spatial line object includes single-line objects and multi-line objects. The present invention uses a custom grid and a custom spatial index to filter out a large number of non-intersecting grid areas, reduce redundant calculations, and effectively improve processing efficiency. Classifying elements into single-line and multi-line categories and performing segmented rasterization processing can more accurately represent the geometric shape and topological information of the line object, thereby effectively improving the accuracy of the processing results. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] Figure 1 This is a flow chart of a preferred embodiment of a method for rasterizing a spatial line object provided by the present invention;

[0044] Figure 2 This is a schematic structural diagram of a preferred embodiment of a spatial line object rasterization device provided by the present invention;

[0045] Figure 3 It is a structural diagram of a preferred embodiment of a terminal device provided by the present invention. DETAILED DESCRIPTION

[0046] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0047] See also Figure 1 , Figure 1 The figure is a flow chart of a preferred embodiment of a spatial line object rasterization method provided by the present invention. The spatial line object rasterization method includes:

[0048] S1, obtaining the longitude and latitude of a spatial line object, and determining whether the longitude and latitude span of the spatial line object is greater than a preset longitude and latitude threshold;

[0049] S2: If yes, fine-grained division is performed on the UTM projection to obtain a custom grid, and the custom grid is filtered using a custom spatial index to obtain a non-empty custom grid; if no, a non-empty custom grid is directly obtained;

[0050] S3. Rasterize the space line object according to the geometric type of the space line object and whether the space line object is in the same non-empty custom grid; wherein the geometric type of the space line object includes a single-line object and a multi-line object.

[0051] Specifically, the embodiment of the present invention first obtains the longitude and latitude of the spatial line object and determines whether the longitude and latitude span of the spatial line object is greater than the preset longitude and latitude threshold. If the longitude and latitude span of the spatial line object is greater than the preset longitude and latitude threshold, the coarse-grained UTM projection is fine-grained to obtain a custom grid, which is a custom rasterization precision. The custom grid is filtered using a custom spatial index to obtain a non-empty custom grid. The blank custom grid no longer undergoes intersection calculation with the predefined grid (required rasterization precision), which greatly reduces the amount of data for spatial operations. If the longitude and latitude span of the spatial line object is not greater than the preset longitude and latitude threshold, a non-empty custom grid is directly obtained and rasterized according to the precision of the predefined grid. The geometric information of the spatial line object is read, and the spatial line object is rasterized according to the geometric type of the spatial line object and whether the spatial line object is in the same non-empty custom grid. The geometric type of the spatial line object includes single-line object and multi-line object.

[0052] The embodiment of the present invention uses a custom grid and a custom spatial index to filter out a large number of non-intersecting grid areas, reduce redundant calculations, and effectively improve processing efficiency. The spatial line object rasterization method provided by the embodiment of the present invention can quickly and accurately convert spatial line objects into raster data through an efficient rasterization method, and can obtain more accurate rasterization results, providing accurate input data for subsequent spatial data analysis, and improving the quality and reliability of analysis results. It is of great significance for improving computing efficiency, accelerating spatial analysis, accurate visualization, spatial correlation analysis and data fusion, and can enhance the effectiveness and feasibility of geographic information systems and spatial analysis.

[0053] In another preferred embodiment, filtering the custom grid using a custom spatial index to obtain a non-empty custom grid includes:

[0054] Using a quadtree spatial index to traverse each of the custom grids, and calculating whether the spatial line object exists in each of the custom grids;

[0055] If it exists, get the non-empty custom grid;

[0056] If not present, empty custom rasters are filtered out.

[0057] Specifically, this embodiment of the present invention uses a quadtree spatial index to traverse each custom grid and calculate whether a spatial line object exists within each custom grid. If a spatial line object exists, a non-empty custom grid is obtained and further predefined rasterization is performed. If no spatial line object exists, empty custom grids are filtered out, and the intersection calculation with the predefined grid (required rasterization accuracy) is no longer performed on these blank custom grids, which greatly reduces the amount of data required for spatial operations.

[0058] The embodiments of the present invention utilize a custom grid to control grid size and resolution to meet actual needs, thereby improving the efficiency of intersection calculations and reducing the amount of computation required by reducing the number of grid cells to be intersected. Furthermore, spatial indexing through a quadtree allows for rapid location of intersections between line objects and the grid, filtering out large areas of non-intersecting grids, reducing redundant calculations, and effectively improving efficiency.

[0059] In another preferred embodiment, the rasterizing of the spatial line objects according to the geometric type of the spatial line objects and whether the spatial line objects are in the same non-empty custom grid comprises:

[0060] For the multi-line object, obtaining the number and information of single-line objects in the multi-line object, traversing each single-line object, and rasterizing the single-line object according to whether the single-line object is in the same non-empty custom grid;

[0061] For the single-line object, rasterize the single-line object according to whether the single-line object is in the same non-empty custom grid.

[0062] Specifically, the embodiment of the present invention reads the geometric information of the spatial line object, and selects to call the raster data clipping of the multi-line object or the raster data clipping of the single-line object according to the geometric type of the spatial line object (multi-line object or single-line object). If it is a multi-line object, first obtain the number and information of the single-line objects in the multi-line object according to the geometric information of the spatial line object, and then loop through each single-line object. In the loop, by obtaining the line geometry information of each single-line object and whether the single-line object is in the same non-empty custom grid, the raster data clipping of the single-line object can be performed, and the result usage method returned by each line is added to the list. If it is a single-line object, the raster data clipping of the single-line object is performed directly according to the line geometry information of the single-line object and whether the single-line object is in the same non-empty custom grid.

[0063] In the rasterization processing of spatial line objects, the embodiment of the present invention is applicable to the rasterization of complex line objects, and achieves efficient rasterization of spatial line objects based on line object segmentation by filtering non-intersecting indexes in a large range.

[0064] In another preferred embodiment, the rasterizing of the single-line objects according to whether the single-line objects are in the same non-empty custom grid comprises:

[0065] Obtain all coordinate points of the single-line object, loop through all coordinate points, convert the latitude and longitude of adjacent coordinate points into grid IDs, and assign them to the first variable and the second variable respectively;

[0066] If the first variable is equal to the second variable, it is determined that the adjacent coordinate points are located in the same non-empty custom grid, and the line objects in the same grid are rasterized;

[0067] If the first variable is not equal to the second variable, it is determined that the adjacent coordinate points are located in different non-empty custom grids, and line objects between different grids are rasterized.

[0068] Specifically, in the embodiment of the present invention, the parameters of the single-line object type represent the geometric information of the line object, as well as an accuracy parameter. Create a dictionary for storing the clipped raster data object. Get all the coordinate points of the single-line object, loop through all the coordinate points, convert the longitude and latitude of the adjacent coordinate points into the ID of the raster, and assign the first variable and the second variable, for example, the startId and endId variables, respectively. By checking whether the first variable is equal to the second variable, it is determined whether the single-line object is in the same non-empty custom grid, for example, whether startId and endId are equal. If the first variable is equal to the second variable, it is determined that the adjacent coordinate points are in the same non-empty custom grid, and the line objects in the same grid are rasterized, and the results are stored in the dictionary. If the first variable is not equal to the second variable, it is determined that the adjacent coordinate points are in different non-empty custom grids, and the line objects between different grids are rasterized, and the results are stored in the dictionary.

[0069] The embodiment of the present invention adopts a segmentation approach for acquiring a bounding box, and segments the line object according to spatial information to obtain a finer-grained line object, thereby making the acquisition of the line object more accurate.

[0070] In another preferred embodiment, rasterizing the line objects in the same grid includes:

[0071] According to the precision of the predefined rasterization, the start predefined raster identifier and the end predefined raster identifier are split into a head identifier and a precision identifier;

[0072] Determine the start and end indexes of the loop based on the indexes of the start and end coordinate points;

[0073] All indexes are traversed through two nested loops to generate the current predefined grid identifier;

[0074] Creating a grid object according to the current predefined grid identifier, and performing an intersection operation on the grid object and a preset line segment;

[0075] If the intersection result is not empty and the result type is a line segment, the length of the line segment is calculated, and corresponding grid information is added or updated in the dictionary according to the current predefined grid identifier.

[0076] Specifically, when rasterizing line objects within the same grid, the embodiment of the present invention splits the starting and ending predefined grid identifiers into a header identifier and a precision identifier based on the predefined rasterization precision. The starting and ending indexes of the loop are determined based on the indices of the starting and ending coordinate points. Then, two nested loops are used to traverse all indexes to generate the current predefined grid identifier. A raster object is created based on the current predefined grid identifier, and each raster object is intersected with a preset line segment. If the intersection result is not empty and the result type is a line segment, the length of the line segment is calculated, and the corresponding raster information is added or updated in the dictionary based on the current predefined grid identifier.

[0077] In another preferred embodiment, rasterizing line objects between different grids includes:

[0078] By comparing the longitude and latitude of two coordinate points, the minimum longitude, minimum latitude, maximum longitude and maximum latitude are calculated;

[0079] Create a single line object, which represents a line segment consisting of two coordinate points;

[0080] Converting the minimum longitude and the minimum latitude into a starting predefined grid identifier, converting the starting predefined grid identifier back into longitude and latitude coordinates by calculation, and calculating the width and height of the predefined grid;

[0081] Calculating an average of the minimum longitude and the minimum latitude to obtain the starting longitude and starting latitude of the predefined grid;

[0082] Initialize the current longitude and the current latitude to the starting longitude and the starting latitude;

[0083] Converting the maximum longitude and the maximum latitude into an end predefined grid identifier, and converting the end predefined grid identifier back into longitude and latitude coordinates by calculation, and updating the maximum longitude and the maximum latitude;

[0084] Entering a loop starting from the starting longitude and the starting latitude, traversing each of the predefined grids one by one, and performing an intersection operation on the predefined grid and a preset line segment;

[0085] If the intersection result is not empty and the result type is a line segment, the length of the line segment is calculated, and corresponding grid information is added or updated in the dictionary according to the current predefined grid identifier.

[0086] Specifically, when rasterizing line objects between different grids, the present invention compares the longitudes and latitudes of two coordinate points p1 and p2 to calculate the minimum longitude minLon, minimum latitude minLat, maximum longitude maxLon, and maximum latitude maxLat. A single line object is created to represent the line segment formed by the two coordinate points p1 and p2. The minimum longitude and minimum latitude are then converted to the starting predefined grid identifier startid, which is then converted back to longitude and latitude coordinates through calculation. The width dlon and height dlat of the predefined grid are calculated. The starting longitude startLon and starting latitude startLat of the predefined grid are obtained by calculating the average of the minimum longitude and minimum latitude. The current longitude currentLon and current latitude currentLat are initialized as the starting longitude and starting latitude. The maximum longitude and maximum latitude are converted to the ending predefined grid identifier endid, which is then converted back to longitude and latitude coordinates through calculation, and the maximum longitude maxLon and maximum latitude maxLat are updated. Starting from the starting longitude and latitude, the loop goes through each predefined grid one by one and intersects the predefined grid with the preset line segment. If the intersection result is not empty and the result type is a line segment, the length of the line segment is calculated and the corresponding grid information is added or updated in the dictionary based on the current predefined grid identifier.

[0087] For example, within the loop, the current longitude and latitude values ​​(currentLat and currentLon) are first converted to a predefined raster index (rasterIndex). A raster object (r) is created based on the predefined raster index, and the intersection of the raster and line objects (line) is obtained. If the intersection result is not empty and the result type is a line segment (LineString), the intersection is added as a line object to the dictionary storing the raster. If data for the predefined raster index already exists in the dictionary, the line object is added to the corresponding line list and the length of the segment is accumulated to the line. If data for the predefined raster index does not exist in the dictionary, a new raster object is created and added to the dictionary. After each inner loop ends, the value of currentLat is updated and the traversal continues to the next predefined raster. After the outer loop ends, the value of currentLon is updated and the traversal continues to the next column of rasters until the specified longitude range is exceeded. Ultimately, the raster data information stored in the dictionary is the clipping result.

[0088] After generating raster data, embodiments of the present invention can also perform post-processing and quality control. For example, data cleaning can be performed to remove noise and outliers; data measurement and accuracy verification can be performed to assess the quality of the generated raster data. Furthermore, the generated raster data can be visualized using mapping software for easy browsing and analysis.

[0089] The embodiment of the present invention no longer performs calculations based on the overall circumscribed rectangle of the determined element, but instead segments the line object, thereby reducing the scope of calculation and improving the accuracy of rasterization. To calculate the raster where the line object intersects with the predefined raster, this process requires converting the geometric information of the line object and the raster into a raster form for processing and analysis. During the calculation process, it is necessary to first convert the longitude and latitude coordinates of the line object and the raster into corresponding rasters through geocoding, and then further determine whether the two rasters intersect. The embodiment of the present invention can efficiently convert spatial line objects into raster images, retaining the precise shape and position information of the line segments, and can be used in many geospatial-related applications, improving the efficiency and accuracy of data processing and analysis.

[0090] Correspondingly, the present invention also provides a spatial line object rasterization device, which can implement all processes of the spatial line object rasterization method in the above embodiment.

[0091] See also Figure 2 , Figure 2 1 is a schematic structural diagram of a preferred embodiment of a spatial line object rasterization device provided by the present invention. The spatial line object rasterization device comprises:

[0092] An acquisition module 201 is configured to acquire the longitude and latitude of a spatial line object and determine whether the longitude and latitude span of the spatial line object is greater than a preset longitude and latitude threshold;

[0093] Filtering module 202 is configured to, if yes, perform fine-grained division on the UTM projection to obtain a custom grid, and filter the custom grid using a custom spatial index to obtain a non-empty custom grid; if no, directly obtain a non-empty custom grid;

[0094] The grid module 203 is configured to rasterize the spatial line objects according to their geometric types and whether they are in the same non-empty custom grid; wherein the geometric types of the spatial line objects include single-line objects and multi-line objects.

[0095] Preferably, the filtering of the custom grid using the custom spatial index to obtain a non-empty custom grid includes:

[0096] Using a quadtree spatial index to traverse each of the custom grids, and calculating whether the spatial line object exists in each of the custom grids;

[0097] If it exists, get the non-empty custom grid;

[0098] If not present, empty custom rasters are filtered out.

[0099] Preferably, the grid module 203 includes:

[0100] The multi-line processing unit 213 is configured to obtain the number and information of single-line objects in the multi-line object, traverse each single-line object, and rasterize the single-line object according to whether the single-line objects are in the same non-empty custom grid;

[0101] The single-line processing unit 223 is configured to rasterize the single-line object according to whether the single-line object is in the same non-empty custom grid.

[0102] Preferably, rasterizing the single-line objects according to whether the single-line objects are in the same non-empty custom grid comprises:

[0103] Obtain all coordinate points of the single-line object, loop through all coordinate points, convert the longitude and latitude of adjacent coordinate points into grid IDs, and assign them to the first variable and the second variable respectively;

[0104] If the first variable is equal to the second variable, it is determined that the adjacent coordinate points are located in the same non-empty custom grid, and the line objects in the same grid are rasterized;

[0105] If the first variable is not equal to the second variable, it is determined that the adjacent coordinate points are located in different non-empty custom grids, and line objects between different grids are rasterized.

[0106] Preferably, rasterizing the line objects in the same grid includes:

[0107] According to the precision of the predefined rasterization, the start predefined raster identifier and the end predefined raster identifier are split into a head identifier and a precision identifier;

[0108] Determine the start and end indexes of the loop based on the indexes of the start and end coordinate points;

[0109] All indexes are traversed through two nested loops to generate the current predefined grid identifier;

[0110] Creating a grid object according to the current predefined grid identifier, and performing an intersection operation on the grid object and a preset line segment;

[0111] If the intersection result is not empty and the result type is a line segment, the length of the line segment is calculated, and corresponding grid information is added or updated in the dictionary according to the current predefined grid identifier.

[0112] Preferably, rasterizing the line objects between different grids includes:

[0113] By comparing the longitude and latitude of two coordinate points, the minimum longitude, minimum latitude, maximum longitude and maximum latitude are calculated;

[0114] Create a single line object, which represents a line segment consisting of two coordinate points;

[0115] Converting the minimum longitude and the minimum latitude into a starting predefined grid identifier, converting the starting predefined grid identifier back into longitude and latitude coordinates by calculation, and calculating the width and height of the predefined grid;

[0116] Calculating an average of the minimum longitude and the minimum latitude to obtain the starting longitude and starting latitude of the predefined grid;

[0117] Initialize the current longitude and the current latitude to the starting longitude and the starting latitude;

[0118] Converting the maximum longitude and the maximum latitude into an end predefined grid identifier, and converting the end predefined grid identifier back into longitude and latitude coordinates by calculation, and updating the maximum longitude and the maximum latitude;

[0119] Entering a loop starting from the starting longitude and the starting latitude, traversing each of the predefined grids one by one, and performing an intersection operation on the predefined grid and a preset line segment;

[0120] If the intersection result is not empty and the result type is a line segment, the length of the line segment is calculated, and corresponding grid information is added or updated in the dictionary according to the current predefined grid identifier.

[0121] In specific implementation, the working principle, control process and technical effects achieved by the spatial line object rasterization device provided in the embodiment of the present invention are the same as those of the spatial line object rasterization method in the above embodiment, and will not be repeated here.

[0122] See also Figure 3 , Figure 3 3 is a schematic diagram of a preferred embodiment of a terminal device provided by the present invention. The terminal device includes a processor 301, a memory 302, and a computer program stored in the memory 302 and configured to be executed by the processor 301. When the processor 301 executes the computer program, it implements the spatial line object rasterization method described in any of the above embodiments.

[0123] Preferably, the computer program can be divided into one or more modules / units (e.g., computer program 1, computer program 2, ...), which are stored in the memory 302 and executed by the processor 301 to implement the present invention. The one or more modules / units can be a series of computer program instruction segments capable of implementing specific functions, and the instruction segments are used to describe the execution process of the computer program in the terminal device.

[0124] The processor 301 can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor, or the processor 301 can be any conventional processor. The processor 301 is the control center of the terminal device, and uses various interfaces and lines to connect the various parts of the terminal device.

[0125] The memory 302 mainly includes a program storage area and a data storage area. The program storage area can store an operating system, at least one application required for a function, and the data storage area can store related data. In addition, the memory 302 can be a high-speed random access memory or a non-volatile memory, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, and a Flash Card. Alternatively, the memory 302 can be other volatile solid-state storage devices.

[0126] It should be noted that the above terminal device may include, but is not limited to, a processor and a memory. Those skilled in the art will understand that Figure 3 The structural diagram is only an example of the above-mentioned terminal device and does not constitute a limitation on the above-mentioned terminal device. It may include more or fewer components than shown in the figure, or combine certain components, or different components.

[0127] An embodiment of the present invention also provides a computer-readable storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the spatial line object rasterization method described in any of the above embodiments.

[0128] An embodiment of the present invention further provides a computer program product, which includes a computer program or computer instructions. When the computer program or the computer instructions are executed by a processor, the spatial line object rasterization method described in any of the above embodiments is implemented.

[0129] Embodiments of the present invention provide a method, apparatus, device, medium, and computer program product for rasterizing spatial line objects. The method obtains the longitude and latitude of a spatial line object and determines whether the longitude and latitude span of the spatial line object is greater than a preset longitude and latitude threshold. If so, the UTM projection is finely divided to obtain a custom grid, and the custom grid is filtered using a custom spatial index to obtain a non-empty custom grid. If not, a non-empty custom grid is directly obtained. The spatial line object is rasterized based on the geometric type of the spatial line object and whether the spatial line object is in the same non-empty custom grid. The geometric type of the spatial line object includes single-line objects and multi-line objects. The embodiment of the present invention filters out a large number of non-intersecting grid areas through a custom grid and a custom spatial index, reduces redundant calculations, and effectively improves processing efficiency. Classifying elements into single-line and multi-line categories and performing segmented rasterization processing can more accurately represent the geometric shape and topological information of the line object, thereby effectively improving the accuracy of the processing results.

[0130] It should be noted that the system embodiment described above is merely illustrative, wherein the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed across multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment. In addition, in the drawings of the system embodiment provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, which can be specifically implemented as one or more communication buses or signal lines. A person of ordinary skill in the art can understand and implement the present invention without inventive work.

[0131] The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.

Claims

1. A method for rasterizing spatial line objects, characterized in that: include: Obtaining the longitude and latitude of the spatial line object, and determining whether the longitude and latitude span of the spatial line object is greater than a preset longitude and latitude threshold; If yes, fine-grained division is performed on the Universal Transverse Mercator UTM projection to obtain a custom grid, and the custom grid is filtered using a custom spatial index to obtain a non-empty custom grid; if no, a non-empty custom grid is directly obtained; The spatial line objects are rasterized according to the geometric types of the spatial line objects and whether the spatial line objects are in the same non-empty custom grid; wherein the geometric types of the spatial line objects include single-line objects and multi-line objects.

2. The spatial line object rasterization method according to claim 1, characterized in that: The step of filtering the custom grid using the custom spatial index to obtain a non-empty custom grid includes: Using a quadtree spatial index to traverse each of the custom grids, and calculating whether the spatial line object exists in each of the custom grids; If it exists, get the non-empty custom grid; If it does not exist, empty custom rasters are filtered out.

3. The spatial line object rasterization method according to claim 2, wherein: The rasterizing of the spatial line objects according to the geometric type of the spatial line objects and whether the spatial line objects are in the same non-empty custom grid includes: For the multi-line object, obtaining the number and information of single-line objects in the multi-line object, traversing each single-line object, and rasterizing the single-line object according to whether the single-line object is in the same non-empty custom grid; For the single-line object, rasterize the single-line object according to whether the single-line object is in the same non-empty custom grid.

4. The spatial line object rasterization method according to claim 3, characterized in that: The rasterizing of the single-line objects according to whether the single-line objects are in the same non-empty custom grid includes: Obtain all coordinate points of the single-line object, loop through all coordinate points, convert the longitude and latitude of adjacent coordinate points into grid IDs, and assign them to the first variable and the second variable respectively; If the first variable is equal to the second variable, it is determined that the adjacent coordinate points are located in the same non-empty custom grid, and the line objects in the same grid are rasterized; If the first variable is not equal to the second variable, it is determined that the adjacent coordinate points are located in different non-empty custom grids, and line objects between different grids are rasterized.

5. The spatial line object rasterization method according to claim 4, characterized in that: The rasterization of line objects within the same grid includes: According to the precision of the predefined rasterization, the start predefined raster identifier and the end predefined raster identifier are split into a head identifier and a precision identifier; Determine the start and end indexes of the loop based on the indexes of the start and end coordinate points; All indexes are traversed through two nested loops to generate the current predefined grid identifier; Creating a grid object according to the current predefined grid identifier, and performing an intersection operation on the grid object and a preset line segment; If the intersection result is not empty and the result type is a line segment, the length of the line segment is calculated, and corresponding grid information is added or updated in the dictionary according to the current predefined grid identifier.

6. The spatial line object rasterization method according to claim 4, characterized in that: The rasterization of line objects between different grids includes: By comparing the longitude and latitude of two coordinate points, the minimum longitude, minimum latitude, maximum longitude and maximum latitude are calculated; Create a single line object, which represents a line segment consisting of two coordinate points; Converting the minimum longitude and the minimum latitude into a starting predefined grid identifier, converting the starting predefined grid identifier back into longitude and latitude coordinates by calculation, and calculating the width and height of the predefined grid; Calculating an average of the minimum longitude and the minimum latitude to obtain the starting longitude and starting latitude of the predefined grid; Initialize the current longitude and the current latitude to the starting longitude and the starting latitude; Converting the maximum longitude and the maximum latitude into an end predefined grid identifier, and converting the end predefined grid identifier back into longitude and latitude coordinates by calculation, and updating the maximum longitude and the maximum latitude; Entering a loop starting from the starting longitude and the starting latitude, traversing each of the predefined grids one by one, and performing an intersection operation on the predefined grid and a preset line segment; If the intersection result is not empty and the result type is a line segment, the length of the line segment is calculated, and corresponding grid information is added or updated in the dictionary according to the current predefined grid identifier.

7. A spatial line object rasterization device, characterized in that: include: An acquisition module, configured to acquire the longitude and latitude of a spatial line object and determine whether the longitude and latitude span of the spatial line object is greater than a preset longitude and latitude threshold; A filtering module is used to, if yes, perform fine-grained division on the UTM projection to obtain a custom grid, and filter the custom grid using a custom spatial index to obtain a non-empty custom grid; if no, directly obtain a non-empty custom grid; A grid module is used to rasterize the spatial line object according to the geometric type of the spatial line object and whether the spatial line object is in the same non-empty custom grid; wherein the geometric type of the spatial line object includes a single line object and a multi-line object.

8. A terminal device, characterized in that: The method comprises a processor and a memory, wherein a computer program is stored in the memory and the computer program is configured to be executed by the processor, and when the processor executes the computer program, the spatial line object rasterization method according to any one of claims 1 to 6 is implemented.

9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein when the device where the computer-readable storage medium is located executes the computer program, the spatial line object rasterization method according to any one of claims 1 to 6 is implemented.

10. A computer program product, characterized in that The computer program product includes a computer program or computer instructions, and when the computer program or the computer instructions are executed by a processor, the spatial line object rasterization method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Spatial data organization method based on global multi-scale grid

    CN113515525A

  • Terrain elevation map processing method and device, vehicle and medium

    CN114612627A