Large-batch label interaction method in domestic environment
By constructing a label space index tree in the auxiliary thread and quickly filtering selected labels, the problem of low interaction efficiency of large batches of labels in a domestic environment is solved, and fast response and efficient editing are achieved.
Patent Information
- Application Number
- CN202410743505.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-11
- Publication Date
- 2024-09-10
Smart Images

Figure CN118628624A
Abstract
Description
Technical Field
[0001] The invention relates to a large-scale label interaction method under a domestic environment. Background Art
[0002] With the rapid development of domestic hardware, domestic operating systems are becoming increasingly powerful, and digital map applications in the domestic environment are becoming more mature. As a basic means of expressing map data, the number of map symbols will inevitably continue to grow during use, which will in turn cause an increase in the load of hardware resources, and will eventually be directly reflected in the interactive experience with the map symbols. Compared with the software and hardware of non-autonomous platforms, there is still a certain gap in the domestic environment. How to achieve the same interactive efficiency in the domestic environment as in the non-autonomous platform has become particularly important.
[0003] The traditional method of drawing labels is to hand over the creation of labels to the main thread, and hand it over to the graphics processor to directly draw it as a vector or raster graphic. In order to ensure the timely response of interactive editing, when it is directly drawn as a vector graphic, when the number of labels is small, this method can still meet the needs of user map interaction; but when the number of labels is large, if all the creation work is still handed over to the main thread, it will greatly increase the CPU load, and at the same time affect the response speed of other operations in the main thread, slowing down the response efficiency of map drawing and interaction. In order to reduce the impact of large-scale label drawing on map drawing efficiency, when it is directly drawn as a raster graphic, when interacting and editing with the labels, the editing and interaction results cannot respond in time, which still affects the interactive experience with the labels on the map.
[0004] In addition, when the mouse is used to operate the labels on the map, the most appropriate label is often calculated by weighting the distance between the mouse position and the label position. However, this operation often requires traversing all the labels, and when the labels are composed of more complex graphics or there are a large number of labels, it is more likely to expose the problem of long response time for the selection function.
[0005] In summary, a method is needed to improve the efficiency of large-scale labeling interaction on the map in a localized environment. Summary of the invention
[0006] Purpose of the invention: The technical problem to be solved by the present invention is to provide a method for mass label interaction in a domestic environment in view of the shortcomings of the prior art, comprising the following steps:
[0007] Step 1, in the auxiliary thread, obtain the labeled original graphic data, hand it over to the graphics processor for processing, and construct it into a raster graphic;
[0008] Step 2: For the labels that have been constructed as raster graphics, in the auxiliary thread, the minimum enclosing longitude and latitude rectangle data of the labels is updated regularly and constructed as a label space index tree;
[0009] Step 3, when selecting a military symbol by mouse for interaction, the symbol space index tree is calculated based on the position of the mouse input, and the symbol at the mouse position is located and selected;
[0010] Step 4: The selected labeled data is moved from the auxiliary thread to the main thread for real-time calculation and update of the construction results, and is handed over to the graphics processor for processing to obtain the drawing results and construct them into vector graphics.
[0011] Step 1 includes:
[0012] Step 1-1, when a large number of static label creation messages are received, in the auxiliary thread, according to the unique identification code provided in the creation message, the original graphic data of the label to be created is determined through the label library;
[0013] Step 1-2: The original graphic data in the label library is rendered into raster graphics by the graphics engine, displayed on the map, and updated regularly.
[0014] Step 2 includes:
[0015] Step 2-1, for each static label, according to the size and position of the static label, obtain the latitude and longitude position (Lon left , Lat top ) and the latitude and longitude of the lower right corner (Lon right , Lat bottom ), constructed as a statically labeled minimum enclosing longitude and latitude rectangle Polygon i ={(Lon left , Lat top ),(Lon right , Lat bottom )}, where Polygon i Represents the minimum enclosing longitude and latitude rectangle of the i-th static label;
[0016] Step 2-2, obtaining the minimum enclosing latitude and longitude grid rectangle covering i static labels;
[0017] Step 2-3, construct the label space index tree, and pass the label space index tree to the main thread for use in the main thread.
[0018] Step 2-2 includes: the minimum enclosing longitude and latitude rectangle Polygon of all static labels i The composition set PM = {Polygon 1, Polygon2, …, Polygonn}; Take out i statically labeled minimum enclosing longitude and latitude rectangles Polygon from the set PM i Subset PM t ; Then compare the subset PM t Take out the leftmost longitude Lon left , the top latitude Lat top , the rightmost longitude Lon right , the lowest latitude Lat bottom , thus obtaining the minimum enclosing graticule rectangle R covering i static labels i ={(Lon left , Lat top ),(Lon right , Lat bottom )}.
[0019] Steps 2-3 include: creating each statically labeled Plot i The corresponding minimum enclosing graticule rectangle Polygon i The bidirectional mapping relationship (Polygon i , Plot i ), using the minimum enclosing longitude and latitude rectangle data as the index, construct the minimum enclosing longitude and latitude rectangle data of all static labels into a label space index tree; according to the calculation method of step 2-2, obtain the minimum enclosing longitude and latitude rectangle covering all static labels as the root node, and then take the minimum enclosing longitude and latitude rectangle of the static labels of half of the root node as the child node, and as the parent node of the next level, and then take the static labels of half of the parent node to repeat the process of constructing child nodes until the minimum enclosing longitude and latitude rectangle of all labels is the leaf node.
[0020] Step 3 includes:
[0021] Step 3-1: When the user clicks the label with the mouse, the mouse minimum enclosing longitude and latitude rectangle is constructed according to the mouse position and the selection tolerance. left , Lat top ),(Lon right , Lat bottom )};
[0022] Step 3-2, establishing a candidate label set;
[0023] Step 3-3, when the number of labels in the candidate label set is greater than or equal to one, a distance weighted judgment is performed based on the mouse position and the label position.
[0024] Step 3-2 includes: searching and filtering out the labeled minimum enclosing longitude and latitude rectangles that intersect or contain the mouse minimum enclosing longitude and latitude rectangle according to the labeled space index tree, and assigning the corresponding n labeled Plot1, Plot2, ..., Plot n Included in the alternative label set Plot alter ={Plot1, Plot2,…,Plot n}.
[0025] Step 3-3 includes: calculating the mouse position and the label position according to the following formula to perform distance weighted judgment:
[0026]
[0027] where d i is the distance between the screen position of the mouse click and the screen position of the i-th label in the candidate label set, d x is the distance between the mouse click position and the screen position of the xth label in the candidate label set, and f(x) is the distance weight of the xth label to the mouse position; the label with the smallest distance weight to the mouse position is taken from the candidate label set and selected.
[0028] Step 4 includes:
[0029] Step 4-1, when the label is in the selected state, the auxiliary thread suspends drawing the selected label, and the main thread draws it as a vector graphic via the graphics processor;
[0030] Step 4-2, when the label is selected, drag the control point of the label with the mouse to change the position, size and direction of the label, and calculate the minimum enclosing longitude and latitude rectangle of the label in real time according to the method in step 2-1, and update the label space index tree.
[0031] The present invention also provides a storage medium storing a computer program or instruction. When the computer program or instruction is run on a computer, the steps of the method described are executed.
[0032] Compared with the prior art, the present invention has the following beneficial effects: (1) Compared with the traditional method of placing the work of constructing and drawing data in the main thread, the graphics construction work of static labels is carried out through an auxiliary thread and directly constructed as a raster graphic, which can reduce the burden of the main thread and avoid causing the main thread to freeze. (2) Compared with the method of directly using the distance weighted method to traverse all labels and then calculate the label closest to the mouse click, the label latitude and longitude spatial index tree can be used to quickly screen out the candidate label set, and then perform distance weighted calculation to quickly select the label. (3) After the label is selected, the drawing work of the label is moved to the main thread, and the drawing result is converted from a raster graphic to a vector graphic, ensuring that the drawing result can be quickly reflected in the process of editing the label, thereby improving the interaction efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments, and the above and / or other advantages of the present invention will become more clear.
[0034] Figure 1 The figure is a schematic diagram of the overall process of the method of the present invention.
[0035] Figure 2 Schematic diagram of a selected portion of the process of the present invention.
[0036] Figure 3 The figure is a schematic diagram of the method of the present invention.
[0037] Figure 4 The figure shows a schematic diagram of the spatial index in the method of the present invention.
[0038] Figure 5 It is a schematic diagram of spatial index data in the method of the present invention. DETAILED DESCRIPTION
[0039] like Figure 1 , Figure 2 As shown, the method for optimizing the interaction efficiency of large-scale labeling in a localized environment described in the present invention includes the following steps:
[0040] Step 1, in the auxiliary thread, obtain the labeled original graphic data, hand it over to the graphics processor for processing, and construct it into a raster graphic;
[0041] Step 2: For the labels that have been constructed as raster graphics, in the auxiliary thread, the minimum enclosing longitude and latitude rectangle data of the labels is updated regularly and constructed as a label space index tree;
[0042] Step 3, when selecting a military symbol by mouse for interaction, the symbol space index tree is calculated based on the position of the mouse input, and the symbol at the mouse position is located and selected;
[0043] Step 4: The selected labeled data is moved from the auxiliary thread to the main thread for real-time calculation and update of the construction results, and is handed over to the graphics processor for processing to obtain the drawing results and construct them into vector graphics.
[0044] Step 1 includes:
[0045] Step 1-1, when a large number of static label creation messages are received, in the auxiliary thread, according to the unique identification code provided in the creation message, the original graphic data of the label to be created is determined through the label library;
[0046] Step 1-2: The original graphic data in the label library is rendered into raster graphics by the graphics engine, displayed on the map, and updated regularly, such as Figure 3 As shown, take some of the labels P1, P2, P3, and P4 as examples, and draw the coordinates of longitude and latitude of P1 (91, 23.5), P2 (94.5, 21.5), P3 (98, 27), and P4 (99, 22). The drawing effect is as follows Figure 3
[0047] shown.
[0048] Step 2 includes:
[0049] Step 2-1, for each static label, according to the size and position of the static label, obtain the latitude and longitude position (Lon left , Lat top ) and the latitude and longitude of the lower right corner (Lon right , Lat bottom ), constructed as a statically labeled minimum enclosing longitude and latitude rectangle Polygon i ={(Lon left , Lat top ),(Lon right , Lat bottom )}, where Polygon i Represents the minimum enclosing longitude and latitude rectangle of the i-th static label.
[0050] Step 2-2: The minimum enclosing longitude and latitude rectangle Polygon of all static labels i The composition set PM = {Polygon 1, Polygon 2,… Polygon n}. Take i statically labeled minimum enclosing longitude and latitude rectangles Polygon from the set PM to form a subset PM t . Then compare the subset PM t Take out the leftmost longitude Lon left , the top latitude Lat top, the rightmost longitude Lon right , the lowest latitude Lat bottom , we can get the minimum enclosing grid rectangle R covering this number i i ={(Lon left , Lat top ),(Lon right , Lat bottom )}.
[0051] Step 2-3, create each numbered Plot i The corresponding minimum enclosing graticule rectangle Polygon i The bidirectional mapping relationship (Polygon i , Plot i ), using the minimum enclosing longitude and latitude rectangle data as the index, construct the minimum enclosing longitude and latitude rectangle data of all labels into a labeled spatial index tree. According to the calculation method of step 2-2, obtain the minimum enclosing longitude and latitude rectangle covering all static labels as the root node, and then take the minimum enclosing longitude and latitude rectangle of half of the static labels of the root node as the child node, and as the parent node of the next level, and then take the static labels of half of the parent node to repeat the process of constructing child nodes until the minimum enclosing longitude and latitude rectangle of all labels is the leaf node. Pass the labeled spatial index tree to the main thread for use in the main thread. Spatial index construction is as follows: Figure 4 and Figure 5 shown.
[0052] Step 3 includes:
[0053] Step 3-1, when the user clicks the label with the mouse, the mouse minimum enclosing longitude and latitude rectangle Mouse = {(91.5, 22.2), (92.1, 22.8)} is constructed according to the mouse position (91.8, 22.5) and the selection tolerance 0.3.
[0054] Step 3-2, based on the mouse minimum enclosing longitude and latitude rectangle, according to the label space index tree, search and filter out the label minimum enclosing longitude and latitude rectangle that intersects with or contains the mouse minimum enclosing longitude and latitude rectangle, and include the corresponding label into the candidate label set Plot alter ={P1,P2}.
[0055] Step 3-3, when the number of labels in the candidate label set is greater than or equal to one, the mouse position and the label position are calculated according to the following formula for distance weighted judgment:
[0056]
[0057] where d iis the Euclidean distance between the screen position of the mouse click and the screen position of the i-th label in the candidate label set, d x is the distance between the mouse click position and the xth label screen position in the candidate label set, and f(x) is the distance weight of the xth label to the mouse position. According to the calculation results, the weight of P1 is 0.307, and the weight of P2 is 0.693. The label with the smallest distance weight to the mouse position is P1 from the candidate label set, and P1 is selected.
[0058] Step 4 includes:
[0059] Step 4-1, when the label is in the selected state, the auxiliary thread suspends drawing the selected label, and the main thread draws it as a vector graphic via the graphics processor;
[0060] Step 4-2, when the label is selected, drag the control point of the label with the mouse to change the position, size and direction of the label, and calculate the minimum enclosing longitude and latitude rectangle of the label in real time according to the method in step 2-1, and update the label space index tree.
[0061] In a specific implementation, the present application provides a computer storage medium and a corresponding data processing unit, wherein the computer storage medium can store a computer program, and when the computer program is executed by the data processing unit, the invention content of a large-scale label interaction method in a domestic environment provided by the present invention and some or all steps in each embodiment can be executed. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0062] Those skilled in the art can clearly understand that the technical solutions in the embodiments of the present invention can be implemented by means of computer programs and their corresponding general hardware platforms. Based on this understanding, the technical solutions in the embodiments of the present invention are essentially or partly contributed to the prior art can be embodied in the form of a computer program, i.e., a software product, which can be stored in a storage medium and includes several instructions for enabling a device including a data processing unit (which can be a personal computer, a server, a single-chip microcomputer, a MUU or a network device, etc.) to execute the methods described in various embodiments of the present invention or certain parts of the embodiments.
[0063] The present invention provides a method for mass label interaction in a domestic environment. There are many methods and ways to implement the technical solution. The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the protection scope of the present invention. All components not specified in this embodiment can be implemented by existing technologies.
Claims
1. A large-scale labeling interaction method in a domestic environment, characterized in that: The following steps are involved: The steps include: Step 1, in the auxiliary thread, obtain the labeled original graphic data, hand it over to the graphics processor for processing, and construct it into a raster graphic; Step 2: For the labels that have been constructed as raster graphics, in the auxiliary thread, the minimum enclosing longitude and latitude rectangle data of the labels is updated regularly and constructed as a label space index tree; Step 3, when selecting a military symbol by mouse for interaction, the symbol space index tree is calculated based on the position of the mouse input, and the symbol at the mouse position is located and selected; Step 4: The selected labeled data is moved from the auxiliary thread to the main thread for real-time calculation and update of the construction results, and is handed over to the graphics processor for processing to obtain the drawing results and construct them into vector graphics.
2. The method according to claim 1, characterized in that Step 1 includes: Step 1-1, when a large number of static label creation messages are received, in the auxiliary thread, according to the unique identification code provided in the creation message, the original graphic data of the label to be created is determined through the label library; Step 1-2: The original graphic data in the label library is rendered into raster graphics by the graphics engine, displayed on the map, and updated regularly.
3. The method according to claim 2, characterized in that Step 2 includes: Step 2-1, for each static label, according to the size and position of the static label, obtain the latitude and longitude position (Lon left , Lat top ) and the latitude and longitude of the lower right corner (Lon right , Lat bottom ), constructed as a statically labeled minimum enclosing longitude and latitude rectangle Polygon i ={(Lon left , Lat top ),(Lon right , Lat bottom )}, where Polygon i Represents the minimum enclosing longitude and latitude rectangle of the i-th static label; Step 2-2, obtaining the minimum enclosing latitude and longitude grid rectangle covering i static labels; Step 2-3, construct the label space index tree, and pass the label space index tree to the main thread for use in the main thread.
4. The method according to claim 3, characterized in that Step 2-2 includes: the minimum enclosing longitude and latitude rectangle Polygon of all static labels i The composition set PM = {Polygon 1, Polygon2, …, Polygon n }; Take out i statically labeled minimum enclosing longitude and latitude rectangles Polygon from the set PM i Subset PM t ; Then compare the subset PM t Take out the leftmost longitude Lon left , the top latitude Lat top , the rightmost longitude Lon right , the lowest latitude Lat bottom , thus obtaining the minimum enclosing graticule rectangle R covering i static labels i ={(Lon left , Lat top ),(Lon right , Lat bottom )}.
5. The method according to claim 4, characterized in that Steps 2-3 include: creating each statically labeled Plot i The corresponding minimum enclosing graticule rectangle Polygon i The bidirectional mapping relationship (Polygon i , Plot i ), using the minimum enclosing longitude and latitude rectangle data as the index, construct the minimum enclosing longitude and latitude rectangle data of all static labels into a label space index tree; according to the calculation method of step 2-2, obtain the minimum enclosing longitude and latitude rectangle covering all static labels as the root node, and then take the minimum enclosing longitude and latitude rectangle of the static labels of half of the root node as the child node, and as the parent node of the next level, and then take the static labels of half of the parent node to repeat the process of constructing child nodes until the minimum enclosing longitude and latitude rectangle of all labels is the leaf node.
6. The method according to claim 5, characterized in that Step 3 includes: Step 3-1: When the user clicks the label with the mouse, the mouse minimum enclosing longitude and latitude rectangle is constructed according to the mouse position and the selection tolerance. left , Lat top ),(Lon right , Lat bottom )}; Step 3-2, establishing a candidate label set; Step 3-3, when the number of labels in the candidate label set is greater than or equal to one, a distance weighted judgment is performed based on the mouse position and the label position.
7. The method according to claim 6, characterized in that Step 3-2 includes: searching and filtering out the labeled minimum enclosing longitude and latitude rectangles that intersect or contain the mouse minimum enclosing longitude and latitude rectangle according to the labeled space index tree, and assigning the corresponding n labeled Plot1, Plot2, ..., Plot n Included in the alternative label set Plot alter ={Plot1, Plot2,…,Plot n }.
8. The method according to claim 7, characterized in that Step 3-3 includes: calculating the mouse position and the label position according to the following formula to perform distance weighted judgment: where d i is the distance between the screen position of the mouse click and the screen position of the i-th label in the candidate label set, d x is the distance between the mouse click position and the screen position of the xth label in the candidate label set, and f(x) is the distance weight of the xth label to the mouse position; the label with the smallest distance weight to the mouse position is taken from the candidate label set and selected.
9. The method according to claim 8, characterized in that Step 4 includes: Step 4-1, when the label is in the selected state, the auxiliary thread suspends drawing the selected label, and the main thread draws it as a vector graphic via the graphics processor; Step 4-2, when the label is selected, drag the control point of the label with the mouse to change the position, size and direction of the label, and calculate the minimum enclosing longitude and latitude rectangle of the label in real time according to the method in step 2-1, and update the label space index tree.
10. A storage medium, characterized in that: A computer program or instruction is stored, and when the computer program or instruction is run on a computer, the steps of the method according to any one of claims 1 to 9 are executed.
