Disclosure of Invention
The invention mainly aims to provide a geographic space data loading method, equipment and a storage medium based on a rarefying algorithm, and aims to solve the technical problems in the prior art.
In order to achieve the above object, the present invention provides a geographic space data loading method based on a rarefaction algorithm, which comprises the following steps:
acquiring geospatial data to be loaded, and acquiring curve points which accord with curve characteristics in the data to be loaded;
marking the rarefaction state of the head and tail points of the curve in the curve points as reserved;
calculating the point distance between two adjacent curve points in other curve points except the head point and the tail point of the curve, comparing the point distance with a first length threshold value, and if the point distance is smaller than the first length threshold value, marking the thinning state of the next curve point as deleted; otherwise, taking the latter curve point as the former curve point of the next two adjacent curve points to be compared until all the curve points are traversed;
deleting the curve point marked as deleted in the rarefaction state from the geospatial data to be loaded to obtain new geospatial data to be loaded;
and loading the new geospatial data to be loaded.
Optionally, the step of deleting the curve point marked as deleted in the rarefaction state from the geospatial data to be loaded to obtain new geospatial data to be loaded includes:
deleting the curve points marked as deleted in the rarefaction state from the geospatial data to be loaded;
calculating the distances from each curve point which is not marked to be deleted to the head and tail points of the curve one by one, and comparing whether the maximum distance in the distances is smaller than a second length threshold value or not;
if the maximum distance in the distances is smaller than a second length threshold, marking the rarefaction states of all curve points between the head point and the tail point of the curve as deleted;
and deleting the curve point marked as deleted in the rarefaction state from the geospatial data to be loaded to obtain new geospatial data to be loaded.
Optionally, the step of loading the new geospatial data to be loaded includes:
determining the number N of threads corresponding to the new geospatial data to be loaded;
and enabling N threads to load the new geospatial data to be loaded.
Optionally, the step of determining the number N of threads corresponding to the new geospatial data to be loaded includes:
acquiring the data volume of the new geospatial data to be loaded;
and determining the number N of threads corresponding to the data size based on the preset mapping relation between the data size and the number of threads.
In addition, to achieve the above object, the present invention further provides a geographic space data loading device based on rarefying algorithm, where the geographic space data loading device based on rarefying algorithm includes: the system comprises a memory, a processor and a geographic space data loading program based on the thinning algorithm, wherein the geographic space data loading program based on the thinning algorithm is stored on the memory and can run on the processor, and when being executed by the processor, the geographic space data loading program based on the thinning algorithm realizes the steps of the geographic space data loading method based on the thinning algorithm.
In addition, in order to achieve the above object, the present invention further provides a storage medium, where the geographic space data loading program based on the rarefying algorithm is stored, and when being executed by a processor, the geographic space data loading program based on the rarefying algorithm implements the steps of the geographic space data loading method based on the rarefying algorithm.
In the invention, geospatial data to be loaded is acquired, and curve points which accord with curve characteristics in the data to be loaded are acquired; marking the rarefaction state of the head and tail points of the curve in the curve points as reserved; calculating the point distance between two adjacent curve points in other curve points except the head point and the tail point of the curve, comparing the point distance with a first length threshold value, and if the point distance is smaller than the first length threshold value, marking the thinning state of the next curve point as deleted; otherwise, taking the latter curve point as the former curve point of the next two adjacent curve points to be compared until all the curve points are traversed; deleting the curve point marked as deleted in the rarefaction state from the geospatial data to be loaded to obtain new geospatial data to be loaded; and loading the new geospatial data to be loaded. The invention simplifies the data volume of the geographic space data to be loaded, saves the storage space and improves the processing speed of the data when in use.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
As shown in fig. 1, fig. 1 is a schematic structural diagram of a geographic space data loading device based on a rarefaction algorithm in a hardware operating environment according to an embodiment of the present invention.
As shown in fig. 1, the geographic spatial data loading device based on the thinning algorithm may include: aprocessor 1001, such as a CPU, anetwork interface 1004, auser interface 1003, amemory 1005, acommunication bus 1002. Wherein acommunication bus 1002 is used to enable connective communication between these components. Theuser interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard), and theoptional user interface 1003 may also include a standard wired interface, a wireless interface. Thenetwork interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). Thememory 1005 may be a high-speed RAM memory or a non-volatile memory (e.g., a magnetic disk memory). Thememory 1005 may alternatively be a storage device separate from theprocessor 1001.
Those skilled in the art will appreciate that the rarefaction algorithm-based geospatial data loading apparatus architecture illustrated in fig. 1 does not constitute a limitation of rarefaction algorithm-based geospatial data loading apparatus and may include more or fewer components than illustrated, or some components in combination, or a different arrangement of components.
As shown in fig. 1, thememory 1005, which is a type of computer storage medium, may include an operating system, a network communication module, a user interface module, and a geographic data loader based on a thinning algorithm.
In the geographic space data loading device based on the rarefaction algorithm shown in fig. 1, thenetwork interface 1004 is mainly used for connecting with a background server and performing data communication with the background server; theuser interface 1003 is mainly used for connecting a client (user side) and performing data communication with the client; and theprocessor 1001 may be configured to invoke the rarefaction algorithm-based geospatial data loader stored in thememory 1005 and perform the following operations:
acquiring geospatial data to be loaded, and acquiring curve points which accord with curve characteristics in the data to be loaded;
marking the rarefaction state of the head and tail points of the curve in the curve points as reserved;
calculating the point distance between two adjacent curve points in other curve points except the head point and the tail point of the curve, comparing the point distance with a first length threshold value, and if the point distance is smaller than the first length threshold value, marking the thinning state of the next curve point as deleted; otherwise, taking the latter curve point as the former curve point of the next two adjacent curve points to be compared until all the curve points are traversed;
deleting the curve point marked as deleted in the rarefaction state from the geospatial data to be loaded to obtain new geospatial data to be loaded;
and loading the new geospatial data to be loaded.
Further, theprocessor 1001 may call the geographic spatial data loader based on the thinning algorithm stored in thememory 1005, and also perform the following operations:
deleting the curve points marked as deleted in the rarefaction state from the geospatial data to be loaded;
calculating the distances from each curve point which is not marked to be deleted to the head and tail points of the curve one by one, and comparing whether the maximum distance in the distances is smaller than a second length threshold value or not;
if the maximum distance in the distances is smaller than a second length threshold, marking the rarefaction states of all curve points between the head point and the tail point of the curve as deleted;
and deleting the curve point marked as deleted in the rarefaction state from the geospatial data to be loaded to obtain new geospatial data to be loaded.
Further, theprocessor 1001 may call the geographic spatial data loader based on the thinning algorithm stored in thememory 1005, and also perform the following operations:
determining the number N of threads corresponding to the new geospatial data to be loaded;
and enabling N threads to load the new geospatial data to be loaded.
Further, theprocessor 1001 may call the geographic spatial data loader based on the thinning algorithm stored in thememory 1005, and also perform the following operations:
acquiring the data volume of the new geospatial data to be loaded;
and determining the number N of threads corresponding to the data size based on the preset mapping relation between the data size and the number of threads.
Referring to fig. 2, fig. 2 is a flowchart illustrating a geospatial data loading method based on a rarefaction algorithm according to a first embodiment of the present invention.
In one embodiment, the geographic space data loading method based on the rarefaction algorithm comprises the following steps:
step S10, acquiring geospatial data to be loaded, and acquiring curve points which accord with curve characteristics in the data to be loaded;
step S20, marking the rarefaction state of the head and tail points of the curve in the curve points as reserved;
step S30, calculating the point distance between two adjacent curve points in other curve points except the head point and the tail point of the curve, comparing the point distance with a first length threshold value, and if the point distance is smaller than the first length threshold value, marking the rarefaction state of the latter curve point as deleted; otherwise, taking the latter curve point as the former curve point of the next two adjacent curve points to be compared until all the curve points are traversed;
step S40, deleting the curve points marked as deleted in the rarefaction state from the geospatial data to be loaded to obtain new geospatial data to be loaded;
in this embodiment, the curve point marked as deleted in the rarefaction state is deleted from the geospatial data to be loaded, and the obtained new geospatial data to be loaded has a smaller data volume, thereby being more beneficial to data loading.
And step S50, loading the new geospatial data to be loaded.
In the embodiment, geospatial data to be loaded is acquired, and curve points which accord with curve characteristics in the data to be loaded are acquired; marking the rarefaction state of the head and tail points of the curve in the curve points as reserved; calculating the point distance between two adjacent curve points in other curve points except the head point and the tail point of the curve, comparing the point distance with a first length threshold value, and if the point distance is smaller than the first length threshold value, marking the thinning state of the next curve point as deleted; otherwise, taking the latter curve point as the former curve point of the next two adjacent curve points to be compared until all the curve points are traversed; deleting the curve point marked as deleted in the rarefaction state from the geospatial data to be loaded to obtain new geospatial data to be loaded; and loading the new geospatial data to be loaded. Through the embodiment, the data volume of the geographic space data to be loaded is reduced, the storage space is saved, and the processing speed of the data in use is improved.
Further, in an embodiment of the geographic spatial data loading method based on the rarefaction algorithm, step S40 includes:
deleting the curve points marked as deleted in the rarefaction state from the geospatial data to be loaded;
calculating the distances from each curve point which is not marked to be deleted to the head and tail points of the curve one by one, and comparing whether the maximum distance in the distances is smaller than a second length threshold value or not;
if the maximum distance in the distances is smaller than a second length threshold, marking the rarefaction states of all curve points between the head point and the tail point of the curve as deleted;
and deleting the curve point marked as deleted in the rarefaction state from the geospatial data to be loaded to obtain new geospatial data to be loaded.
In the embodiment, the data subjected to the first thinning processing is subjected to the second thinning processing, so that the obtained new geographic space data to be loaded is more simplified, the data volume is smaller, the storage space is further saved, and the processing speed of the data in use is improved.
Further, in an embodiment of the geographic spatial data loading method based on the rarefaction algorithm, step S50 includes:
determining the number N of threads corresponding to the new geospatial data to be loaded;
in this embodiment, the step of determining the number N of threads corresponding to the new geospatial data to be loaded includes: acquiring the data volume of the new geospatial data to be loaded; and determining the number N of threads corresponding to the data size based on the preset mapping relation between the data size and the number of threads.
And enabling N threads to load the new geospatial data to be loaded.
In this embodiment, if the mapping relationship between the preset data size and the thread number is: the number of threads corresponding to the data amount of 0 to 1G is 1, the number of threads corresponding to the data amount of 1 to 2G is 2, and the number of threads corresponding to the data amount of 2 to 3G is 3. If the data size of the new geospatial data to be loaded is 1.5G, and the number of threads N is 2, 2 threads are enabled to load the new geospatial data to be loaded.
In the embodiment, the N threads are determined according to the data size of the new geospatial data to be loaded, and the N threads are enabled to load the data, so that the loading speed is increased.
In addition, an embodiment of the present invention further provides a storage medium, where a geographic space data loader based on a rarefaction algorithm is stored in the storage medium, and when being executed by a processor, the geographic space data loader based on the rarefaction algorithm implements the steps of the geographic space data loading method based on the rarefaction algorithm in the above embodiments.
The storage medium of the present invention is a computer-readable storage medium, and the specific embodiment of the storage medium of the present invention is substantially the same as each embodiment of the geographic space data loading method based on the rarefying algorithm, and is not described herein again.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for causing a terminal device to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.