Disclosure of Invention
In view of the above problems, the present invention has been made to provide a map rendering method, style switching method, related apparatus, and navigation client that overcome or at least partially solve the above problems.
In a first aspect, an embodiment of the present invention provides a map rendering method, including:
acquiring map data corresponding to a current map display window;
Carrying out full analysis on the obtained map data by using a preset full pattern to obtain renderable map data, wherein the full pattern comprises rendering pattern data common to a plurality of rendering patterns;
refreshing the renderable map data using a target rendering style;
and rendering the repairable map data.
In one embodiment, the rendering style data common to a plurality of rendering styles in the full-volume style is a common attribute and an attribute value thereof in each rendering style data;
And carrying out full-quantity analysis on the map data by using a preset full-quantity pattern, wherein the full-quantity analysis comprises the following steps:
analyzing map elements to be rendered of the map data;
and assigning corresponding map elements in the analyzed map data by using the common attributes and attribute values thereof in the rendering style data.
In one embodiment, the style data in the target rendering style is an attribute and an attribute value thereof which are common to the non-plurality of rendering styles corresponding to the displayed style;
refreshing the renderable map data using a target rendering style, comprising:
Traversing the renderable map data, and using each attribute value in the target rendering pattern to assign a value to each corresponding map element in the renderable map data.
In one embodiment, the method further comprises caching the renderable map data;
before the map data corresponding to the current map display window is obtained, the method further comprises the following steps:
judging whether renderable map data exist in the current cache;
If yes, executing a step of refreshing the renderable map data by using a target rendering pattern;
Otherwise, turning to executing the step of acquiring the map data corresponding to the current map display window.
In a second aspect, an embodiment of the present invention provides a method for switching a map style, including:
When an instruction for triggering pattern switching is received, refreshing the renderable map data again by using a target rendering pattern corresponding to the new pattern after switching, wherein the target rendering pattern comprises pattern data which are corresponding to the new pattern after switching and are common to a plurality of rendering patterns;
re-rendering the refreshed renderable map data;
the renderable map data is obtained in advance by acquiring map data corresponding to a current map display window, performing full-scale analysis on the acquired map data by using a preset full-scale pattern to obtain the renderable map data, wherein the full-scale pattern comprises rendering pattern data common to a plurality of rendering patterns.
In one embodiment, the refreshing the renderable map data using the target rendering style corresponding to the new style after switching includes:
Traversing the renderable map data, and carrying out assignment again on each map element corresponding to the renderable map data by using each attribute value in the target rendering pattern corresponding to the new pattern.
In a third aspect, an embodiment of the present invention provides a map rendering apparatus, including:
The loading module is used for acquiring map data corresponding to the current map display window;
the full-quantity analysis module is used for carrying out full-quantity analysis on the acquired map data by using a preset full-quantity pattern to acquire renderable map data, wherein the full-quantity pattern comprises rendering pattern data common to a plurality of rendering patterns;
the refreshing module is used for refreshing the renderable map data by using a target rendering pattern;
and the rendering module is used for rendering the repairable map data.
In one embodiment, the map rendering device further comprises a clipping module, which is used for clipping map data in a range which needs to be displayed in the current display window and determining map data corresponding to the current map display window.
In one embodiment, the rendering style data common to a plurality of rendering styles in the full-volume style is a common attribute and an attribute value thereof in each rendering style data;
The full resolution module comprises:
the analysis sub-module is used for analyzing map elements to be rendered of the map data;
And the assignment sub-module is used for assigning values to corresponding map elements in the analyzed map data by using the common attributes and the attribute values thereof in the rendering style data.
In one embodiment, the style data in the target rendering style is an attribute and an attribute value thereof which are common to the non-plurality of rendering styles corresponding to the displayed style;
The refreshing module is used for traversing the renderable map data and assigning values to corresponding map elements in the renderable map data by using the attribute values in the target rendering pattern.
In one embodiment, the system further comprises a cache module and a judging module;
the caching module is used for caching the renderable map data;
The judging module is used for judging whether the current cache contains renderable map data or not;
the refreshing module is further used for executing the step of refreshing the renderable map data by using the target rendering pattern when the judging module judges that the renderable map data exist;
The loading module is further configured to execute a step of acquiring map data corresponding to the current map display window when the judging module judges that no renderable map data exists.
In a fourth aspect, an embodiment of the present invention provides a map style switching apparatus, including:
the instruction receiving module is used for receiving an instruction for triggering the style switching;
the refreshing module is used for refreshing the renderable map data again by using a target rendering pattern corresponding to the new pattern after switching when the instruction receiving module receives an instruction for triggering pattern switching, wherein the target rendering pattern comprises pattern data which is corresponding to the new pattern after switching and is not common to a plurality of rendering patterns;
The rendering module is used for re-rendering the renderable map data obtained after the refreshing by the refreshing module;
the renderable map data is obtained in advance by acquiring map data corresponding to a current map display window, performing full-scale analysis on the acquired map data by using a preset full-scale pattern to obtain the renderable map data, wherein the full-scale pattern comprises rendering pattern data common to a plurality of rendering patterns.
In one embodiment, the refreshing module is configured to traverse the renderable map data, and re-assign values to corresponding map elements in the renderable map data using the attribute values in the target rendering style corresponding to the new style.
In a fifth aspect, an embodiment of the present invention provides a computer readable storage medium having stored thereon computer instructions that, when executed by a processor, implement the map rendering method described above.
In a sixth aspect, an embodiment of the present invention provides a computer readable storage medium having stored thereon computer instructions which, when executed by a processor, implement the method of map style switching described above.
In a seventh aspect, an embodiment of the present invention provides a navigation client, including a memory, a processor, and computer instructions stored on the memory and executable on the processor, where the instructions, when executed by the processor, are capable of implementing the map rendering method described above.
In a final aspect, an embodiment of the present invention provides a navigation client, including a memory, a processor, and computer instructions stored on the memory and executable on the processor, where the instructions, when executed by the processor, enable the method for map style switching described above.
The technical scheme provided by the embodiment of the invention has the beneficial effects that at least:
According to the map rendering method and the pattern switching method, the map data are acquired, the map data are subjected to full-quantity analysis by using the preset full-quantity pattern, the renderable map data are obtained, the full-quantity pattern comprises rendering pattern data which are common to a plurality of rendering patterns, the renderable map data are refreshed by using the target rendering pattern, the refreshed renderable map data are rendered integrally, on one hand, the analyzed data can be used under any pattern due to the full-quantity analysis of the map data, and then when the pattern is required to be switched, the individualized target rendering pattern corresponding to the new pattern (the pattern data which are common to the non-various patterns and correspond to the new pattern) which is required to be switched can be subjected to pattern re-brushing instead of the map data which is required to be subjected to the re-analysis by using the new rendering pattern, so that the switching process is simpler and faster, the method is also suitable for scenes with animation, the effect of one frame of the renderable map data is achieved, the problem of white blocks and flickering in the existing pattern switching process is solved, and the user experience is improved.
In the above scheme provided by the embodiment of the invention, the full-scale style is the attribute value of the common style extracted from various different rendering styles, and when the full-scale style is used for carrying out full-scale analysis on the map data, the assignment is equivalent to the fact that the part with the commonality in the map is carried out in advance, and when the style needing to be displayed is determined or a new style needs to be switched, the attribute value of the style of the non-commonality part is used for carrying out assignment or reassignment and rendering on the corresponding elements in the renderable map data. When the different modes are switched, the renderable map data obtained after the analysis is completed is unchanged and only needs to be reassigned, so that the problem of inaccurate switching time between the rendering data of the new mode and the rendering data of the old mode in the prior art is solved.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims thereof as well as the appended drawings.
The technical scheme of the invention is further described in detail through the drawings and the embodiments.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
Based on the problems of flickering and white blocking of the switching of the map display modes in the prior art, the use experience of a user is improved.
The map rendering method provided by the embodiment of the invention is described in detail.
Referring to fig. 1, the map rendering method provided by the embodiment of the invention includes the following steps:
S11, acquiring map data corresponding to a current map display window;
s12, carrying out full analysis on the acquired map data by using a preset full-quantity pattern to acquire renderable map data, wherein the full-quantity pattern comprises rendering pattern data common to a plurality of rendering patterns;
S13, refreshing the renderable map data by using the target rendering pattern;
and S14, rendering the repairable map data.
The target rendering style includes style data common to a plurality of rendering styles corresponding to the displayed style, and for example, a rendering style file is used, and the file includes a common attribute and an attribute value thereof in each rendering style data.
The style switching requirements of the map include, but are not limited to, various switching situations in which a user needs to switch from a main map interface to an interface on which a road is planned, switching between a daytime display style of the map and a night display mode of the map, during which style switching, for example, a change in color of a line surface, a change in width of a line surface, and the like occur in elements of the map.
In the above step S11, before the process of obtaining the map data, the map data may be cut according to the range that the current display window (screen or a certain interface) needs to be displayed, so as to determine the map data that is currently needed.
For example, map data is stored in a Tile (called a Tile or a Tile) data format, and it is necessary to determine that 10 tiles are covered according to a screen range 1080×800, and determine how specific Tile IDs of the 10 tiles are, so that the map data is cut out for subsequent processing.
After knowing which tiles are currently needed, before acquiring the map data, it can also be checked whether the renderable map data is currently cached, where the renderable map data is already loaded and parsed before and can be directly taken for rendering. If there is renderable map data, the subsequent rendering process is directly performed. The rendering process will be described in detail below. If there is no renderable map data, continuing to acquire map data corresponding to the current map display window.
And checking whether the renderable map data is currently cached, for example, searching whether the renderable map data exists in a memory cache, wherein the renderable map data is not original block data, but data obtained by analyzing and processing the original block data, and the renderable map data exists in the memory cache (a first-level cache in some systems) after being created, so that the renderable map data can be quickly and directly rendered when the map data of the same area is rendered next time, and the rendering speed and the rendering efficiency are increased.
For example, when map data is loaded for the first time, there may not be any renderable map data in the memory buffer, and as the map rendering process proceeds, the renderable map data is created after the map tile data is acquired and parsed, and the renderable map data is placed in the memory buffer.
In the step S11, the map data corresponding to the current map display window may be obtained through any one or more of, for example, file caching, or offline data, request for network side obtaining, etc., which is not limited in the embodiment of the present invention.
In one embodiment, in the step S12, the full-scale style may be in the form of a full-scale style file, and the common rendering style data in the full-scale style file may be obtained by extracting common attributes of all different map styles, for example, so that the common style data in the full-scale style is an attribute value of a common style in each rendering style data;
Each rendering style refers to a rendering style that may be used by various existing maps.
And carrying out full analysis on map elements to be rendered of the map data by using a preset full-scale pattern, traversing each map block data when implementing, analyzing all elements of each map block data, and then carrying out assignment on corresponding elements in the analyzed data by using attribute values of each common pattern in the full-scale pattern. The embodiment of the invention has the advantages that all data suitable for any style is analyzed in advance no matter what style is adopted later (although the map data is analyzed in full, the map data is not necessarily displayed later), and the map data is ready for rendering and switching of the subsequent style, so that the workload of rendering and switching the rendering is reduced, and the speed and efficiency of switching the style are improved.
After the map block data is subjected to full-scale analysis, the image block after analysis is marked as a state capable of being rendered, and the data after analysis is the map data capable of being rendered.
In one embodiment, in step S13, the target rendering style is a portion of the map style corresponding to the current map data that has a non-common attribute. In implementations, for example, the target rendering style file may exist.
Specifically, in step S13, the renderable map data is traversed, and each attribute value in the target rendering pattern is used to assign a value to each corresponding element in the renderable map data. For example, data for each tile in the renderable map data is traversed and then points, lines, and faces in the tile are assigned using the target rendering style.
In the step S14, the refreshed renderable map data includes not only the common style of each rendering style, but also the specific style of a single rendering style, so that the rendering is directly completed, and the specific rendering process is not repeated.
In a specific implementation, referring to the example shown in fig. 2, the embodiment of the invention may be implemented by a plurality of threads, for example, a main thread is responsible for clipping map data, initiating a search of renderable map data in a first-level cache, if not found, starting a data loading thread, searching a second-level cache and a file cache by the data loading thread to load map data, further starting a data expanding thread (also called a data analyzing thread) after the map data is successfully loaded, completing data expansion (analysis) by the data expanding thread, then marking the map data as a renderable state, and then completing refreshing and rendering of a subsequent style by the main thread.
Referring to the example shown in fig. 3, the main thread initiates style switching according to an instruction, then refreshes a style using a rendering style file of a new style, and then renders the refreshed map data.
Accordingly, based on the map rendering method, when style switching is required, the map style switching method provided by the embodiment of the invention, referring to fig. 4, includes the following steps:
S41, when an instruction for triggering pattern switching is received, refreshing the renderable map data again by using a target rendering pattern corresponding to the new pattern after switching, wherein the target rendering pattern comprises pattern data which are corresponding to the new pattern after switching and are common to a plurality of rendering patterns;
S42, re-rendering the repairable map data.
The meaning of the renderable map data in step S41 and the obtaining process can refer to the description of the flow of fig. 1, and are not described herein.
In one embodiment, step S31 may be implemented by traversing the renderable map data and reassigning each map element corresponding to the renderable map data using each attribute value in the target rendering style corresponding to the new style.
According to the map rendering method and the map style switching method, the acquired map data are subjected to full-quantity analysis by using the preset full-quantity style, the renderable map data are obtained, the target rendering style is used for refreshing the renderable map data, and then the refreshed renderable map data are integrally rendered, so that on one hand, the analyzed data can be ensured to be used under any style due to the full-quantity analysis of the map data, and then when the style is required to be switched, the personalized rendering style (which can adopt a style file mode and contains style data which are corresponding to the new style and are not common to all rendering styles) corresponding to the new style is used for re-brushing the style, and the method is not required to use the new style to re-analyze the map data like the prior art, so that the switching process is simpler and faster, is also applicable to a scene with animation, the problem of white blocks and flickering in the existing style switching process is solved, and the use experience of users is improved.
In the above scheme provided by the embodiment of the invention, the full-scale pattern is extracted from various different rendering patterns and has common attribute and attribute value thereof, when the full-scale pattern is used for carrying out full-scale analysis on the map data, the assignment is equivalent to the fact that the part with the commonality in the map data is carried out in advance, when the target pattern to be displayed is determined or a new pattern needs to be switched, the attribute value of the pattern of the non-commonality part is used again, and the assignment or reassignment and rendering can be carried out on the corresponding map elements in the renderable map data. When the new style is switched, the map data corresponding to the new style is required to be re-analyzed according to the setting of the new style, so that the problems of screen blank or flickering and the like caused by slower rendering process, difficult grasp of new and old rendering data exchange time and the like are solved.
Based on the same inventive concept, the embodiments of the present invention further provide a map rendering device, a map style switching device, and a related navigation client, and because the principles of the problems solved by these devices and terminals are similar to the foregoing map rendering method and style switching method, the implementation of the devices and clients can refer to the implementation of the foregoing method, and the repetition is omitted.
The map rendering device provided by the embodiment of the invention, referring to fig. 5, includes:
The loading module 51 is configured to obtain map data corresponding to a current map display window;
the full-quantity analysis module 52 is configured to perform full-quantity analysis on the acquired map data by using a preset full-quantity pattern, so as to obtain renderable map data, where the full-quantity pattern includes rendering pattern data that is common among a plurality of rendering patterns;
A refresh module 53 for refreshing the renderable map data using a target rendering pattern, wherein the rendering pattern includes pattern data common to non-respective patterns corresponding to the displayed pattern;
and a rendering module 54, configured to render the rendered map data.
In one embodiment, the rendering style data common to a plurality of rendering styles in the full-volume style is a common attribute and an attribute value thereof in each rendering style data;
the full-quantity analysis module 52, as shown in fig. 6, includes:
The parsing sub-module 521 is configured to parse map elements to be rendered of the map data;
And the assignment sub-module 522 is configured to assign a value to a corresponding map element in the parsed map data by using the common attribute and the attribute value thereof in each rendering style data.
In one embodiment, the style data in the target rendering style is an attribute and an attribute value thereof which are common to the non-plurality of rendering styles corresponding to the displayed style;
Accordingly, the refreshing module 53 is configured to traverse the renderable map data, and assign a value to each corresponding map element in the renderable map data by using each attribute value in the target rendering style.
In one embodiment, the map rendering apparatus, as shown in fig. 5, further includes a buffer module 55 and a judging module 56, wherein:
a caching module 55, configured to cache the renderable map data;
a judging module 56, configured to judge whether renderable map data exists in the current cache;
The refreshing module 53 is further configured to perform a step of refreshing the renderable map data using a target rendering style when the judging module 56 judges that the renderable map data exists;
The loading module 51 is further configured to execute a step of acquiring map data corresponding to the current map display window when the judging module 56 judges that there is no renderable map data.
The map rendering device, referring to fig. 5, further includes a clipping module 57, configured to clip map data in a range that needs to be displayed in the current display window, and determine map data corresponding to the current map display window.
The device for switching the map style provided by the embodiment of the invention, referring to fig. 7, comprises:
an instruction receiving module 71, configured to receive an instruction for triggering pattern switching;
a refreshing module 72, configured to, when the instruction receiving module receives an instruction for triggering a style switch, refresh the renderable map data again using a target rendering style corresponding to the new style after the switch, where the target rendering style includes style data that is common to a plurality of rendering styles and corresponds to the new style after the switch;
a rendering module 73, configured to re-render the renderable map data obtained after the refreshing by the refreshing module;
the renderable map data is obtained in advance by acquiring map data corresponding to a current map display window, performing full-scale analysis on the acquired map data by using a preset full-scale pattern to obtain the renderable map data, wherein the full-scale pattern comprises rendering pattern data common to a plurality of rendering patterns.
In one embodiment, the refresh module 72 is configured to traverse the renderable map data and re-assign a value to each corresponding map element in the renderable map data using each attribute value in the target rendering style corresponding to the new style.
The embodiment of the invention also provides a computer readable storage medium, wherein computer instructions are stored on the computer readable storage medium, and the instructions realize the map rendering method when being executed by a processor.
The embodiment of the invention also provides another computer readable storage medium, wherein computer instructions are stored on the computer readable storage medium, and the instructions are executed by a processor to realize the map style switching method.
The embodiment of the invention also provides a navigation client, which comprises a memory, a processor and computer instructions stored on the memory and capable of running on the processor, and is characterized in that the instructions can realize the map rendering method when being executed by the processor.
The embodiment of the invention also provides a navigation client, which comprises a memory, a processor and computer instructions stored on the memory and capable of running on the processor, and is characterized in that the method for switching the map style can be realized when the instructions are executed by the processor.
It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, magnetic disk storage, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. 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.
It will be apparent to those skilled in the art that various modifications and variations can be made to the present invention without departing from the spirit or scope of the invention. Thus, it is intended that the present invention also include such modifications and alterations insofar as they come within the scope of the appended claims or the equivalents thereof.