Method and device for checking vector elements and administrative regions in full coverage mode
Technical Field
The invention relates to the field of spatial data analysis and processing, in particular to a method and a device for full-coverage inspection of vector elements and administrative regions.
Background
In the actual operation process, in order to effectively standardize the content form of database results and effectively check the conformity of the results to the standards, the results of the grain production functional area and the important agricultural product production protection area need to be defined for quality check. In the checking process, one item is to check geographic data, when the geographic data is checked, a file to be checked needs to be compared with an administrative division file, so that corresponding vector elements in the file to be checked and the administrative division file need to be extracted respectively firstly, and then the vector elements are compared one by one to obtain a checking result, but the file types in the data result are various, the data volume and the occupied storage space of the data result are large, the number of land blocks is in the million level, the number of boundary points and boundary lines is in the million level, the storage space occupied by a single data result can reach the TB level, a large amount of time is needed in the query stage of the vector elements, and therefore, the checking of the geographic data is difficult at present.
Disclosure of Invention
Therefore, the technical problem to be solved by the present invention is to overcome the defect of difficulty in checking geographic data in the prior art, and to provide a method and an apparatus for full coverage checking of vector elements and administrative areas.
The invention provides a method for checking vector elements and administrative regions in a full coverage manner, which comprises the following steps: acquiring a vector element file to be checked and a preset vector element reference file; establishing a first spatial index file according to a vector element file to be checked; establishing a first spatial grid according to a data range in a vector element file to be detected, wherein the first spatial grid comprises a plurality of first sub-grids; establishing a first element offset attribute table according to the first sub-grid, wherein the first element offset attribute table comprises element offsets for representing the positions of the vector elements in the first spatial index file; inquiring a first vector element point according to the element offset and the first spatial index file; inquiring a second vector element point corresponding to the first vector element point according to a preset vector element reference file; and judging whether the first vector element point and the second vector element point are the same element point or not to obtain a query result.
Optionally, the preset vector element reference file is established by the following process: establishing a second spatial index file according to the vector element file to be stored; establishing a second spatial grid according to a data range in the vector element file to be stored, wherein the second spatial grid comprises a plurality of second sub-grids, and the size of the second sub-grids is the same as that of the first sub-grids; establishing a second element offset attribute table according to the second sub-grid, wherein the second element offset attribute table comprises element offsets used for representing the positions of the vector elements in the second spatial index file; and packaging the second spatial index file, the second spatial grid and the second element offset attribute table to form a preset vector element reference file.
Optionally, the method for checking the vector elements and the administrative region in full coverage further includes: the same coordinate system is established for the first spatial grid and the second spatial grid, respectively.
Optionally, the step of querying a second vector element point corresponding to the first vector element point according to a preset vector element file includes: inquiring the number of a first sub-grid corresponding to the first vector element point according to the first element offset attribute table; searching a second sub-grid with the same number as that of the first sub-grid; and querying a second vector element point according to the searched second sub-grid, the second element offset attribute table and the second spatial index file.
Optionally, the step of determining whether the first vector element point and the second vector element point are the same element point includes: the first vector element point and the second vector element point respectively comprise a plurality of pixels; obtaining coordinates of each pixel in the first vector element point in a coordinate system to which the pixel belongs to form a first coordinate set; obtaining coordinates of each pixel in the second vector element point in a coordinate system to which the pixel belongs to form a second coordinate set; and when the number of the coordinates with different values in the first coordinate set and the second coordinate set is less than or equal to a preset threshold value, judging that the first vector element point and the second vector element point are the same element point.
Optionally, the step of determining whether the first vector element point and the second vector element point are the same element point further includes: and when the number of the coordinates with different values in the first coordinate set and the second coordinate set is greater than a preset threshold value, judging that the first vector element point and the second vector element point are not the same element point.
The second aspect of the present invention provides a device for checking vector elements and administrative regions in a full coverage manner, comprising: the file acquisition module is used for acquiring a vector element file to be checked and a preset vector element reference file; the first spatial index file establishing module is used for establishing a first spatial index file according to the vector element file to be checked; the first spatial grid establishing module is used for establishing a first spatial grid according to a data range in the vector element file to be detected, wherein the first spatial grid comprises a plurality of first sub-grids; the first element offset attribute table establishing module is used for establishing a first element offset attribute table according to the first sub-grid, and the first element offset attribute table comprises element offset used for representing the position of the vector element in the first spatial index file; the first vector element point query module is used for querying a first vector element point according to the element offset and the first spatial index file; the second vector element point query module is used for querying a second vector element point corresponding to the first vector element point according to a preset vector element reference file; and the element point judging module is used for judging whether the first vector element point and the second vector element point are the same element point or not to obtain a query result.
A third aspect of the present invention provides a computer apparatus comprising: at least one processor; and a memory communicatively coupled to at least one processor; wherein the memory stores instructions executable by at least one processor to perform the method for performing vector element and administrative area full coverage inspection as provided by the first aspect of the present invention.
A fourth aspect of the present invention provides a computer-readable storage medium storing computer instructions for causing a computer to perform the method for full coverage inspection of vector elements and administrative areas as provided by the first aspect of the present invention.
The technical scheme of the invention has the following advantages:
1. the invention provides a method for full-coverage inspection of vector elements and administrative regions, which comprises the steps of firstly establishing a first spatial index file according to a vector element file to be inspected, establishing a first spatial grid according to a data range in the vector element file to be inspected, establishing a first element offset attribute table comprising element offset for representing the position of the vector element in the first spatial index file for a first sub-grid in the first grid, searching the first spatial index file according to the offset in the first element offset attribute table when inquiring the first vector element point, extracting the required first vector element point through the first spatial index file, and improving the inquiry speed of the vector element point without traversing all files.
2. The invention provides a method for checking vector elements and administrative regions in a full-coverage manner, wherein a preset vector element reference file comprises a second space index file, a second space grid and a second element offset attribute table, the method for establishing the second space grid is the same as that of the first space grid, the size of a second sub-grid in the second space grid is the same as that of a first sub-grid, when a second vector element point corresponding to the first vector element point is searched in the preset vector element reference file, only a first sub-grid number corresponding to the first vector element point is determined, then a second sub-grid with the same number as that of the first sub-grid is searched in the preset vector element reference file, the second vector element point can be searched according to the searched second sub-grid, the second element offset attribute table and the second space index file, and all vector element points in the preset vector element reference file can be quickly searched in a traversal manner and the second vector element point can be quickly searched without traversing all vector element points in the preset vector element reference file A second vector element point corresponding to a vector element point.
3. The device for the full-coverage inspection of the vector elements and the administrative regions, provided by the invention, comprises the steps of firstly establishing a first spatial index file according to a vector element file to be inspected, establishing a first spatial grid according to a data range in the vector element file to be inspected, establishing a first element offset attribute table comprising element offset for representing the position of the vector elements in the first spatial index file for a first sub-grid in the first grid, searching the first spatial index file according to the offset in the first element offset attribute table when inquiring the first vector element point, extracting the required first vector element point through the first spatial index file, and extracting the required vector element point without traversing all files.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a flow chart of a specific example of a method for full coverage inspection of vector elements and administrative areas according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a first spatial grid in an embodiment of the present invention;
3-5 are flowcharts of specific examples of methods for full coverage inspection of vector elements and administrative areas according to embodiments of the present invention;
FIG. 6 is a block diagram of an apparatus for full coverage inspection of vector elements and administrative areas according to an embodiment of the present invention;
fig. 7 is a block diagram of a computer device according to an embodiment of the present invention.
Detailed Description
The technical solutions of the present invention will be described clearly and completely with reference to the accompanying drawings, and it should be understood that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In the description of the present invention, it should be noted that the terms "first", "second", and "third" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance.
In addition, the technical features involved in the different embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.
Example 1
The embodiment of the present invention provides a method for checking vector elements and administrative regions in a full coverage manner, as shown in fig. 1, including:
step S110: and acquiring a vector element file to be checked and a preset vector element reference file.
Step S120: and establishing a first spatial index file according to the vector element file to be checked, wherein the position of the vector element point is recorded in the first spatial index file, and when the vector element point in the vector element file to be checked is inquired subsequently, the required vector element point can be inquired only according to the position of the vector element point in the first spatial index file.
Step S130: establishing a first spatial grid according to the data range in the vector element file to be checked, wherein the first spatial grid comprises a plurality of first sub-grids, and each sub-grid has a respective number, as shown in fig. 2, in a specific embodiment, the size of the first sub-grid can be adjusted according to actual requirements, and a buffer area can be created for each first sub-grid according to actual requirements, for example, for a region with complex terrain, the buffer area can be set to be 1-10 meters, but for a region with flat terrain, the buffer area can be set to be 50-100 meters.
Step S140: and establishing a first element offset attribute table according to the first sub-grid, wherein the first element offset attribute table comprises element offset used for representing the position of the vector element in the first spatial index file. In one embodiment, the first element offset attribute table is shown in table 1:
TABLE 1
First sub-mesh id1
|
Int offset
|
First sub-mesh id2
|
Int offset
|
First sub-mesh id3
|
Int offset |
Wherein, the Int offset is the element offset of the position of the vector element point in the first spatial index file.
Step S150: and querying the first vector element points according to the element offset and the first spatial index file, namely, searching the corresponding first spatial index file according to the Int offset in the table, thereby querying the vector element points.
Step S160: and inquiring a second vector element point corresponding to the first vector element point according to a preset vector element reference file.
Step S170: and judging whether the first vector element point and the second vector element point are the same element point or not to obtain a query result.
The method for the full-coverage inspection of the vector elements and the administrative regions, provided by the embodiment of the invention, comprises the steps of firstly establishing a first spatial index file according to a vector element file to be inspected, establishing a first spatial grid according to a data range in the vector element file to be inspected, establishing a first element offset attribute table comprising element offset for representing the position of the vector elements in the first spatial index file for a first sub-grid in the first grid, searching the first spatial index file according to the offset in the first element offset attribute table when inquiring the first vector element, extracting the required first vector element point through the first spatial index file, and extracting the required vector element point without traversing all files so as to extract the required vector element point.
In an alternative embodiment, as shown in fig. 3, the default vector element reference file is created by the following process:
step S210: and establishing a second spatial index file according to the vector element file to be stored, wherein in a specific embodiment, the second spatial index file is the same as the first spatial index file, and the positions of the vector elements are recorded.
Step S220: and establishing a second spatial grid according to a data range in the vector element file to be stored, wherein the second spatial grid comprises a plurality of second sub-grids, the size of the second sub-grids is the same as that of the first sub-grids, and the second sub-grids are numbered in the same way as the first sub-grids.
Step S230: and establishing a second element offset attribute table according to the second sub-grid, wherein the second element offset attribute table comprises element offset used for representing the position of the vector element in the second spatial index file. In one embodiment, the second element offset attribute table is shown in table 2:
TABLE 2
Second sub-mesh id1
|
Int offset
|
Second sub-mesh id2
|
Int offset
|
Second sub-mesh id3
|
Int offset |
Wherein, the Int offset is the element offset of the position of the vector element point in the second spatial index file.
Step S240: and packaging the second spatial index file, the second spatial grid and the second element offset attribute table to form a preset vector element reference file. And packaging and storing the three files, and directly extracting corresponding vector element points from the stored preset vector element reference file without performing gridding processing on the administrative division file every time when the file to be checked is checked subsequently.
In an optional embodiment, the method for checking vector elements and administrative regions in full coverage according to the embodiment of the present invention further includes: the same coordinate system is established for the first spatial grid and the second spatial grid, respectively. Specifically, sub-grids with the same number are selected from the first space grid and the second space grid to be respectively used as the origin of the coordinate system of the first space grid and the origin of the coordinate system of the second space grid, and the positive directions and the unit lengths of the two coordinate systems are also the same.
In an alternative embodiment, as shown in fig. 4, the step S160 specifically includes:
step S161: and querying the number of the first sub-grid corresponding to the first vector element point according to the first element offset attribute table, namely querying the element offset corresponding to the first element offset in the first element offset attribute table according to the first vector element point, wherein the sub-grid number corresponding to the element offset is the sub-grid number corresponding to the first vector element point, and the sub-grid number is the first sub-grid id in the table 1.
Step S162: a second sub-grid is looked up with the same number as the first sub-grid. Because the first space grid and the second space grid are constructed in the same way, and the numbering ways of the first sub grid and the second sub grid are also the same, when inquiring the second vector element point corresponding to the first vector element point, only the second sub grid with the same number as the first sub grid needs to be searched first, and then the vector element point inquired according to the second sub grid is the second vector element point corresponding to the first vector element point.
Step S163: and querying a second vector element point according to the searched second sub-grid, the second element offset attribute table and the second spatial index file.
By the method for checking the vector element and the administrative region in the full coverage manner, the second vector element point corresponding to the first vector element point can be quickly found without traversing all vector element points in the preset vector element reference file.
In an alternative embodiment, the first vector element point and the second vector element point each comprise a plurality of picture elements. As shown in fig. 5, the step S170 specifically includes:
step S171: in an optional embodiment, for different types of documents, coordinates of pixels and information points in the vector elements in the coordinate system may also be obtained.
Step S172: and acquiring coordinates of each pixel in the second vector element points in the coordinate system to which the pixel belongs to form a second coordinate set, wherein the coordinate system to which the second vector element points belong is the coordinate system established according to the second spatial grid.
Step S173: and when the number of the coordinates with different values in the first coordinate set and the second coordinate set is less than or equal to a preset threshold value, judging that the first vector element point and the second vector element point are the same element point. In a specific embodiment, when determining whether the two coordinate values are the same, and when the difference between the two coordinate values is within the tolerance accuracy, the two coordinate values may be considered to be the same, and the tolerance accuracy may be set according to actual requirements. The preset threshold may also be set according to actual requirements, and in this embodiment, the threshold is set to 20, that is, when the number of coordinates with different values in the first coordinate set and the second coordinate set is less than or equal to 20, it is determined that the first vector element point and the second vector element point are the same element point.
In an optional embodiment, the step S170 further includes:
step S174: and when the number of the coordinates with different values in the first coordinate set and the second coordinate set is greater than a preset threshold value, judging that the first vector element point and the second vector element point are not the same element point. That is, when the number of coordinates having different values in the first coordinate set and the second coordinate set is greater than 20, it is determined that the first vector element point and the second vector element point are the same element point.
Example 2
An embodiment of the present invention provides a device for checking vector elements and administrative areas in a full coverage manner, as shown in fig. 6, including:
the file obtaining module 110 is configured to obtain a vector element file to be checked and a preset vector element reference file, and the detailed description is described in the above embodiment 1 for the step S110.
The first spatial index file creating module 120 is configured to create a first spatial index file according to the vector element file to be checked, and the detailed description is described in the foregoing embodiment 1 for the step S120.
The first spatial grid establishing module 130 is configured to establish a first spatial grid according to the data range in the vector element file to be checked, where the first spatial grid includes a plurality of first sub-grids, and the detailed description is described in the above embodiment 1 for step S130.
A first element offset attribute table creating module 140, configured to create a first element offset attribute table according to the first sub-grid, where the first element offset attribute table includes element offsets used to characterize positions of vector elements in the first spatial index file, and the detailed description is described in embodiment 1 with reference to step S140.
The first vector element point query module 150 is configured to query the first vector element point according to the element offset and the first spatial index file, and the detailed description is described in the above embodiment 1 for the step S150.
A second vector element point query module 160, configured to query a second vector element point corresponding to the first vector element point according to a preset vector element reference file, for details of which description is given in the above embodiment 1 for the description of step S160.
The element point determining module 170 is configured to determine whether the first vector element point and the second vector element point are the same element point, and obtain a query result, which is described in detail in the above embodiment 1 for the description of step S170.
The device for the full-coverage inspection of the vector elements and the administrative regions, provided by the embodiment of the invention, comprises the steps of firstly establishing a first spatial index file according to a vector element file to be inspected, establishing a first spatial grid according to a data range in the vector element file to be inspected, establishing a first element offset attribute table comprising element offsets for representing the positions of the vector elements in the first spatial index file for a first sub-grid in the first grid, searching the first spatial index file according to the offsets in the first element offset attribute table when inquiring the first vector element points, extracting the required first vector element points through the first spatial index file, and extracting the required vector element points without traversing all files so as to extract the required vector element points.
Example 3
An embodiment of the present invention further provides a computer device, as shown in fig. 7, the computer device mainly includes one or more processors 51 and a memory 52, and fig. 7 takes one processor 51 as an example.
The computer device may further include: an input device 53 and an output device 54.
The processor 51, the memory 52, the input device 53 and the output device 54 may be connected by a bus or other means, and fig. 7 illustrates the connection by a bus as an example.
The processor 51 may be a Central Processing Unit (CPU). The Processor 51 may also be other general purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, or combinations thereof. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The memory 52 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created from use of the vector elements and the device for administrative area full coverage inspection, and the like. Further, the memory 52 may include high speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, memory 52 optionally includes memory remotely located from processor 51, and these remote memories may be connected over a network to a device for full coverage inspection of vector elements and administrative areas. The input device 53 may receive a calculation request (or other numeric or character information) input by a user and generate a key signal input relating to the device in which the vector elements are checked for full coverage of the administrative area. The output device 54 may include a display device such as a display screen for outputting the calculation result.
Example 4
The present invention provides a computer-readable storage medium storing computer instructions, the computer-readable storage medium storing computer-executable instructions, the computer-executable instructions being capable of performing the method of vector element and administrative area full coverage inspection in any of the above method embodiments. The storage medium may be a magnetic Disk, an optical Disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a flash Memory (FlashMemory), a Hard Disk (Hard Disk Drive, abbreviated as HDD), a Solid State Drive (SSD), or the like; the storage medium may also comprise a combination of memories of the kind described above.
It should be understood that the above examples are only for clarity of illustration and are not intended to limit the embodiments. Other variations and modifications will be apparent to persons skilled in the art in light of the above description. And are neither required nor exhaustive of all embodiments. And obvious variations or modifications therefrom are within the scope of the invention.