Disclosure of Invention
The embodiment of the application aims to provide a large-scale vector data visualization method, a system, a processor and a machine-readable storage medium based on Cesium, so as to improve the transmission efficiency and the dynamic loading efficiency of the large-scale vector data.
In order to achieve the above purpose, the first aspect of the present application provides a method for visualizing large-scale vector data based on Cesium, which includes preprocessing acquired space vector data, slicing the preprocessed space vector data to obtain a multi-level vector tile group, wherein all vector tiles in any level can be spliced into complete space vector data, vector tiles in the same level are equal in size, vector tiles in different levels are different in size, monitoring an interaction event of a user, loading vector tiles in a corresponding position and a corresponding level according to the interaction event, rendering the loaded vector tiles, and further achieving visualization of the space vector data, wherein the interaction event includes scaling and translation.
Based on the first aspect, in the embodiment of the application, the data format of the acquired space vector data comprises SHAPEFILE, POSTGIS and GeoJSON, and the preprocessing of the acquired space vector data comprises the step of converting the space vector data in the SHAPEFILE, POSTGIS or GeoJSON format into the space vector data in the MVT format.
Based on the first aspect, in the embodiment of the application, the step of realizing the visualization of the space vector data comprises the steps of analyzing MVT data, extracting geometric data and attribute data, and rendering the geometric data as Cesium layers after the extraction is completed, wherein each geometric object is drawn as a PRIMITIVE object of Cesium, so that the visualization of the space vector data is realized.
Based on the first aspect, in the embodiment of the application, the method further comprises caching the vector tiles loaded in the last N times, wherein N is not more than the maximum vector tile number.
Based on the first aspect, the method further comprises the steps of setting position numbers for all vector tiles in any hierarchy, wherein the position numbers comprise row numbers and column numbers of the vector tiles, loading the vector tiles of the corresponding positions and the corresponding hierarchies according to the interaction event comprises the steps of determining the hierarchy of the vector tiles to be scheduled according to the scaling degree of the current interaction view area, calculating the position numbers of the vector tiles to be scheduled according to the range of the current interaction view area, and loading the vector tiles of the corresponding hierarchies and the corresponding position numbers.
Based on the first aspect, in the embodiment of the application, the method further comprises the steps of predicting the view browsing range of the user, loading vector tiles in the predicted view browsing range in advance, and caching.
The application provides a large-scale vector data visualization system based on Cesium, which comprises a preprocessing module, a slicing module, a Cesium module and a processing module, wherein the preprocessing module is used for preprocessing acquired space vector data, the slicing module is used for slicing the preprocessed space vector data to obtain a multi-level vector tile group, all vector tiles in any level can be spliced into complete space vector data, vector tiles in the same level are equal in size, vector tiles in different levels are different in size, the Cesium module is used for monitoring interaction events of a user, loading vector tiles in corresponding positions and corresponding levels according to the interaction events, rendering the loaded vector tiles, and further realizing visualization of the space vector data, and the interaction events comprise scaling and translation.
Based on the second aspect, in the embodiment of the application, the system further comprises a prediction module for predicting the view browsing range of the user, and a preloading module for preloading and caching vector tiles in the predicted view browsing range in advance.
In a third aspect, the present application provides a processor configured to perform the above-described method of visualizing large-scale vector data based on Cesium.
In a fourth aspect, the present application provides a machine-readable storage medium having stored thereon instructions that, when executed by a processor, cause the processor to be configured to perform the above-described method of visualizing large-scale vector data based on Cesium.
The technical scheme provided by the application has at least the following beneficial effects:
(1) MVT is a slice format, the data volume is smaller, vector data can be transmitted in a block mode, and the bandwidth required by loading the whole data set is reduced. It allows on-demand loading compared to conventional vector data formats, especially for large-scale data sets.
(2) And the real-time interactivity is improved, namely the real-time interactivity of the large-scale vector data in Cesium can be effectively enhanced by using MVT to conduct data rendering. In map or scene browsing in a large range, the MVT can dynamically load and display vector information of each tile, so that a user can obtain visual feedback in real time during operations such as zooming, translation and the like, and smooth operation experience is maintained.
(3) And the client pressure is reduced, the MVT format is preprocessed into tile data in the transmission process, and the client only needs to process a smaller tile range, so that the burden of memory and calculation is reduced. Cesium can better optimize the memory use and improve the stability of large-scale data processing when the MVT is combined to load large-scale vector data.
In summary, the large data vector data visualization technology based on Cesium can efficiently acquire, parse, convert, render and interact with MVT vector tile data, and provide the visualization capability of large-scale vector data in a three-dimensional earth scene in combination with the three-dimensional engine of Cesium.
Additional features and advantages of embodiments of the application will be set forth in the detailed description which follows.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more apparent, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it should be understood that the detailed description described herein is merely for illustrating and explaining the embodiments of the present application, and is not intended to limit the embodiments of the present application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
It should be noted that, if directional indications (such as up, down, left, right, front, rear, etc.) are involved in the embodiment of the present application, the directional indications are merely used to explain the relative positional relationship, movement conditions, etc. between the components in a specific posture (as shown in the drawings), and if the specific posture is changed, the directional indications are correspondingly changed.
In addition, if there is a description of "first", "second", etc. in the embodiments of the present application, the description of "first", "second", etc. is for descriptive purposes only and is not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include at least one such feature. In addition, the technical solutions of the embodiments may be combined with each other, but it is necessary to base that the technical solutions can be realized by those skilled in the art, and when the technical solutions are contradictory or cannot be realized, the combination of the technical solutions should be considered to be absent and not within the scope of protection claimed in the present application.
Examples
A method for visualizing large-scale vector data based on Cesium, the method comprising:
s1, preprocessing the acquired space vector data;
specifically, vector data to be published is imported into GeoServer, supported data formats include SHAPEFILE, POSTGIS, GEOJSON and the like, and space vector data in SHAPEFILE, POSTGIS or GeoJSON format is converted into space vector data in MVT format by using a special tool or library (for example tippecanoe or MAPSHAPER of Mapbox).
S2, slicing the preprocessed space vector data to obtain a multi-level vector tile group, wherein all vector tiles in any level can be spliced into complete space vector data, the vector tiles in the same level are equal in size (influence on smoothness of loading tiles is avoided), and the vector tiles in different levels are different in size;
Specifically, geoServer is utilized to provide storage and slicing services, generate pbf data format and release MVT services. In Maputnik, the MVT service published in GeoServer is added as a data source. MVTURL provided by GeoServer is filled into the data source configuration by the data source configuration. And configuring corresponding patterns for the loaded MVT data sources, wherein the patterns comprise line colors, widths, filling patterns and the like under different zoom levels. After the pattern configuration is completed, the derived pattern is a JSON file.
The vector tile set is a vector slice data set of a multi-level pyramid structure. Layer 0 is a single tile containing all elements, typically 256 pixels in length and width, and the entire vector space is contained in the tile 1, and the tile 1 is divided into four tiles, where the size of each tile is 256×256, but the resolution of the picture is doubled with respect to layer 0. By analogy, the whole space vector data is divided into tiles of different levels, and the more the levels are divided, the better the number of pictures increases exponentially with the increase of the levels, when the levels are excessively large, the number of the tiles also increases sharply, and the pressure is caused to data storage.
S3, monitoring an interaction event of a user, loading vector tiles at corresponding positions and corresponding levels according to the interaction event, and rendering the loaded vector tiles to further realize visualization of space vector data, wherein the interaction event comprises scaling and translation.
In this embodiment, the Cesium module may be used to implement visualization of space vector data, so as to achieve the purposes of loading large-scale vector data efficiently and improving resolution support. Cesium, however, supports mainly 3dtile and GeoJSON, cesium cannot directly support mvt data service loading. Therefore, in this embodiment, first, MVTImageryProvider is used to request vector tile data of a corresponding level from the server, the vector tile data is obtained in the form of pbf file (see step S2), the geometric objects and attribute data are extracted, after the extraction is completed, the geometric data are rendered as Cesium layers, and each geometric object (point, line, plane) is drawn as PRIMITIVE objects of Cesium. When a user moves, zooms or rotates the camera, the tiles are dynamically loaded and rendered according to the level and the position of the requested tiles.
Specifically, in order to accurately calculate the corresponding vector tile when loading the vector tile data, in this embodiment, for any hierarchy, position numbers are set for all vector tiles in the hierarchy, where the position numbers include row numbers and column numbers of the vector tiles, and an index relationship is established between a storage address of the vector tile and the position numbers, that is, a physical address of the vector tile can be located through the position numbers of the vector tile.
Loading the vector tiles of the corresponding positions and the corresponding levels according to the interaction event comprises determining the levels of the vector tiles to be scheduled according to the zoom degree of the current interaction view area (according to the zoom operation of a user in the interaction view area), calculating the position numbers of the vector tiles to be scheduled according to the range of the current interaction view area, and loading the vector tiles of the corresponding levels and the corresponding position numbers.
Further, the method further comprises the step of caching the vector tiles loaded in the last N times, wherein N is not more than the maximum vector tile number, and the number of N is preferably 5-10 in an exemplary manner so as to avoid the influence on the smoothness of system operation due to excessive cache occupation. But properly caches partial data, reduces the time for reloading vector tile data and improves the speed of vector tile display.
Further, the method further comprises the steps of predicting the view browsing range of the user, loading vector tiles in the predicted view browsing range in advance, and caching.
The scheduling of vector tiles should also take full advantage of the optimization mechanism of the computer and the caching mechanism of the browser. During the interactive operation, the request for data is often triggered after the user operation. In this embodiment, based on the usage habit of the user and the current movement track in the interactive view area, the next operation of the user can be prejudged, the predicted view browsing range data is requested in advance and stored in the (slow) memory, so that the data acquisition time is reduced, and the display speed is improved. The data read-write efficiency in the memory is far greater than the read-write speed of the mechanical hard disk, so that frequent operation on the mechanical hard disk is avoided as much as possible in the scheduling process. And for the repeatedly operated area, the area is locally stored in a file cache or memory cache mode, so that the interactive operation with a server or a hard disk is reduced, and the scheduling time is shortened.
Examples
The application provides a large-scale vector data visualization system based on Cesium, as shown in fig. 2, which comprises a preprocessing module 1, a slicing module 2, a Cesium module 3 and a processing module, wherein the preprocessing module 1 is used for preprocessing acquired space vector data, the slicing module 2 is used for slicing the preprocessed space vector data to obtain a multi-level vector tile group, all vector tiles in any level can be spliced into complete space vector data, the vector tiles in the same level are equal in size, the vector tiles in different levels are different in size, and the Cesium module 3 is used for monitoring interaction events of a user, loading vector tiles in corresponding positions and corresponding levels according to the interaction events, and rendering the loaded vector tiles to further realize visualization of the space vector data.
Specifically, the system further comprises a prediction module 4 for predicting the view browsing range of the user, and a preloading module 5 for preloading and caching vector tiles in the predicted view browsing range in advance.
The method described in embodiment 1 above can be implemented using the visualization system provided in this embodiment.
The large-scale vector data visualization system based on Cesium further comprises a processor and a memory, wherein the preprocessing module 1, the slicing module 2, the Cesium module 3, the prediction module 4, the preloading module 5 and the like are all stored in the memory as program units, and the processor executes the program modules stored in the memory to realize corresponding functions.
The processor includes a kernel, and the kernel fetches the corresponding program unit from the memory. The kernel can be provided with one or more than one, and the visualization method based on Cesium large-scale vector data is realized by adjusting kernel parameters.
The memory may include volatile memory, random Access Memory (RAM), and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM), among other forms in computer readable media, the memory including at least one memory chip.
The embodiment of the application provides a storage medium, wherein a program is stored on the storage medium, and the program is executed by a processor to realize the large-scale vector data visualization method based on Cesium.
In this embodiment, there is also provided a computer device, which may be a terminal, and an internal structure diagram thereof may be as shown in fig. 3. The computer apparatus includes a processor a01, a network interface a02, a display screen a04, an input device a05, and a memory (not shown in the figure) which are connected through a system bus. Wherein the processor a01 of the computer device is adapted to provide computing and control capabilities. The memory of the computer device includes an internal memory a03 and a nonvolatile storage medium a06. The nonvolatile storage medium a06 stores an operating system B01 and a computer program B02. The internal memory a03 provides an environment for the operation of the operating system B01 and the computer program B02 in the nonvolatile storage medium a06. The network interface a02 of the computer device is used for communication with an external terminal through a network connection. The computer program, when executed by the processor a01, implements a method of visualizing large-scale vector data based on Cesium. The display screen a04 of the computer device may be a liquid crystal display screen or an electronic ink display screen, and the input device a05 of the computer device may be a touch layer covered on the display screen, or may be a key, a track ball or a touch pad arranged on a casing of the computer device, or may be an external keyboard, a touch pad or a mouse.
It will be appreciated by those skilled in the art that the structure shown in FIG. 3 is merely a block diagram of some of the structures associated with the present inventive arrangements and is not limiting of the computer device to which the present inventive arrangements may be applied, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In one typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, etc., such as Read Only Memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
Computer-readable media include both permanent and non-permanent, removable and non-removable media, and information storage may be implemented by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transitorymedia), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus 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 apparatus. Without further limitation, an element defined by the phrase "comprising one does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises an element.
The foregoing is merely exemplary of the present application and is not intended to limit the present application. Various modifications and variations of the present application will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. which come within the spirit and principles of the application are to be included in the scope of the claims of the present application.