Method and system for placing labels inside polygonal areas
By generating Voronoi graphs and simplified paths in complex polygon areas, calculating the maximum allowable height and font size of the label, and adjusting the overlap between the label geometric center and the simplified path, the problems of unnatural label placement, insufficient aesthetics and adaptability in the prior art are solved, and an efficient and beautiful label layout is achieved.
Patent Information
- Application Number
- CN202411909452.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2044-12-24
AI Technical Summary
Existing tag placement algorithms, such as polylable and polylable+ algorithms, are difficult to ensure that the tag position is closely fitted with boundaries or simplified paths in complex polygons, resulting in unnatural label placement results, insufficient aesthetics and adaptability.
By processing the boundaries of polygonal regions, generating distribution points, calculating Voronoi graphs, planning and optimizing simplified paths, calculating the maximum allowable height and font size of the label, and adjusting the label to the maximum font size so that its geometric center coincides with the geometric center of the simplified path, to achieve optimal placement of the label.
It realizes efficient and beautiful placement of tags in complex polygon areas, improves visual effects and user experience, and is suitable for various complex polygons, with better adaptability and promotional value.
Smart Images

Figure CN119338100B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of label placement, and in particular to a method and system for placing labels inside a polygonal area. Background Art
[0002] Label placement is a technique used to select the best location to display labels in a visualization to achieve aesthetic, readable, and relevant information. Its purpose is to ensure that the labels in the visualization are readable and clearly associated with the labeled features, while avoiding occlusion and label overlap, improving the efficiency of information communication and user experience. In applications such as map annotation and data visualization, the accuracy and aesthetics of label placement are crucial. A good label placement algorithm should ensure that the labels are readable inside the graphics, fit closely to the graphics boundaries or curve features, and avoid occlusion and overlap between labels.
[0003] In the existing label placement algorithms, polylable Algorithms and polylable +Algorithms are widely used. Here is a brief summary of the two algorithms:
[0004] 1. Polygon interior label placement method based on non-contact point method ( polylable algorithm)
[0005] Polygon interior label placement method based on non-contact point method ( polylable The algorithm was first proposed by Vladimir. Its core idea is to find the point farthest from the boundary by calculating the "Pole of Inaccessibility" inside the polygon, so as to determine the best location for label placement. This method gradually approaches the optimal location through recursive segmentation and priority queue, and is suitable for implementing label placement in polygons with simple geometric shapes. However, polylable The algorithm mainly places labels based on geometric rules. It is difficult to ensure that the label position fits closely with the boundary or simplified path in complex polygons (such as polygons with multiple holes or concave and convex shapes). The placement results are often difficult to accurately reflect the geometric characteristics of the polygons. Visually, the label position is stiff and unnatural, and there is a lack of sufficient consideration of the polygon curve characteristics. It is difficult to meet users' requirements for aesthetics and adaptability.
[0006] 2. Skeleton-based polygon interior label placement method ( polylable + Algorithm)
[0007] A skeleton-based method for placing labels inside polygons ( polylable + algorithm) is in polylable A method based on the algorithm to improve the polylableThe algorithms are different. polylable + The algorithm comprehensively considers the geometric features of polygons to achieve a better balance between visual effects and computational efficiency. By introducing geometric feature analysis and path simplification, polylable + The algorithm improves the accuracy of label placement and the smoothness of layout to a certain extent. However, polylable + The introduction of geometric features in the algorithm increases the flexibility of label placement, but when dealing with complex or irregular polygons (such as elongated shapes or polygons with complex boundaries), the label position may still be offset or unsatisfactory. In addition, in order to improve the accuracy of label placement, polylable + The algorithm introduces more geometric feature calculations and path optimization processes, which improves accuracy while significantly increasing the computational cost. This disadvantage of high computational cost is more obvious, especially in polygons with complex shapes.
[0008] In summary, the existing polylable and polylable +It is difficult for the algorithm to take into account adaptability, aesthetics and efficiency at the same time. They have their own limitations and cannot meet the high requirements of complex polygon label placement. This problem urgently needs a method with better performance. Summary of the invention
[0009] In view of the deficiencies in the prior art, the present invention aims to provide a method and system for placing labels inside a polygonal area.
[0010] In order to achieve the above object, the present invention provides the following technical solutions:
[0011] Methods for placing labels inside polygonal areas include:
[0012] Process the border of the polygonal area to generate several distribution points, and calculate and generate Voronoi picture;
[0013] Based on the Voronoi Graph planning and optimization to obtain a simplified path of the polygonal area;
[0014] Calculate the minimum vertical distance from the simplified path to the boundary, calculate the maximum allowable height of the polygonal area where the label can be placed based on the minimum vertical distance, and calculate the maximum font size of the polygonal area where the label can be placed based on the maximum allowable height;
[0015] The label is adjusted to the maximum font size, its geometric center is aligned with the geometric center of the simplified path, and the label is placed within the polygonal area based on the simplified path.
[0016] In the present invention, preferably, the total length of the border of the polygon is calculated, and a number of the distribution points are generated by equidistant sampling.
[0017] In the present invention, preferably, the generation Voronoi The specific steps are as follows:
[0018] Calculate the boundary lines of adjacent distribution points;
[0019] Calculation Voronoi vertex;
[0020] in accordance with Voronoi The vertex corresponding to Voronoi The cells are connected into closed polygons;
[0021] According to the boundary line, the infinitely extended boundary line is intercepted to form a closed area and generate Voronoi picture.
[0022] In the present invention, preferably, the specific steps of obtaining the simplified path of the polygonal area include:
[0023] Associating the nodes in the polygonal area with the weights of the adjacent nodes and the connecting edges between the two nodes;
[0024] According to the weight of the connecting edge, the optimal path between nodes is selected according to the fitness formula;
[0025] The optimal path is simplified in combination with the radial distance, thereby obtaining a simplified path of the polygonal area.
[0026] In the present invention, preferably, the connection table is used to construct Voronoi A graph of all nodes and edges in the graph, thereby associating the nodes in the polygonal area with their adjacent nodes and the weights of the connecting edges between two nodes.
[0027] In the present invention, preferably, the specific steps of selecting the optimal path between nodes include:
[0028] Use Dijkstra's algorithm to find the shortest path between each pair of surrounding nodes;
[0029] Through the fitness formula: , select the path corresponding to the maximum value of each node's fitness as the optimal path, where is the total path length, is the tortuosity,
[0030] = , Value according to The value of for hour, is 2, when for hour, is 4.
[0031] In the present invention, preferably, the specific steps of simplifying the optimal path include:
[0032] Determine the starting point of the optimal path, traverse all other points, calculate the Euclidean distance between the node and the previous node, and when the Euclidean distance is greater than the tolerance value tolerance , then add the point to the simplified point set simplified_points In this simplified point set simplified_points The points in further divide the optimal path;
[0033] Divide the optimal path into several segments, calculate the vertical distances from all points in each segment to the corresponding starting and ending points of the segment, and record the point with the largest vertical distance. ;
[0034] When the vertical distance is greater than the tolerance value tolerance When , the corresponding point Split the original segment into two new segments;
[0035] When the vertical distance is less than the tolerance value tolerance , the original segments are retained and a simplified path for the polygonal area is generated.
[0036] In the present invention, preferably, the points on the simplified path are calculated To several points on the boundary The minimum value of these distances is taken as the point Minimum distance to border , ;
[0037] Calculate the maximum allowed height , , is the maximum allowed width of the step, The minimum aspect ratio of the text;
[0038] Update the maximum value between widths ,
[0039] ,in, is the increment of each step;
[0040] Will Convert to pixels: = , get the maximum font size, where For every 100 pixels of width.
[0041] The system for placing labels inside a polygonal area comprises a segmentation unit, a simplified path extraction unit, a font size calculation unit and a label placement unit connected in sequence, wherein the segmentation unit is used to segment the polygonal area and generate Voronoi picture, Voronoi The simplified path extraction unit is input into the figure, and the simplified path of the polygonal area is obtained through calculation. The font size calculation unit calculates the maximum font size for placing the label based on the simplified path and the polygonal area. The label placement unit adjusts the current label with reference to the maximum font size obtained by the font size calculation unit, and places the label in the polygonal area after adjustment.
[0042] Compared with the prior art, the present invention has the following beneficial effects:
[0043] The method of the present invention is applicable to various complex polygonal areas, and can determine the optimal label placement position and the maximum font size within the polygonal area. It shows excellent performance in terms of visual aesthetics, user experience and scene adaptability, and has better adaptability and promotion value in practical applications; it shows a high degree of flexibility when processing complex geometric structures, and the label layout can adapt to the shape characteristics of the polygon while maintaining a high generation efficiency, thereby meeting the requirements for efficiency and accuracy in practical applications; the system of the present invention can allow users to adjust the label layout effect according to actual needs through intuitive algorithm parameter adjustment (such as the number of nodes, offset, font size), thereby achieving more flexible label management, and users can easily achieve the optimal label layout in polygons of different complexities, greatly improving the ease of operation and overall user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 It is a schematic diagram of the flow of the method for placing labels inside a polygonal area according to the present invention.
[0045] Figure 2 for Voronoi Schematic diagram of the graph generation process.
[0046] Figure 3 Generate a flow diagram to simplify the path.
[0047] Figure 4 This is a flowchart of label font size calculation and placement.
[0048] Figure 5 for Schematic diagram comparing the impact of parameters.
[0049] Figure 6 for Schematic diagram comparing the impact of parameters.
[0050] Figure 7 for Schematic diagram comparing the impact of parameters.
[0051] Figure 8 for Schematic diagram of parameter impact versus impact.
[0052] Fig. 9 for Schematic diagram of parameter impact versus impact.
[0053] Fig.10 The figure is a schematic diagram comparing the results of the method of the present invention, the polylable method and the polylable+ method on polygons with a large aspect ratio.
[0054] Fig.11 It is another schematic diagram comparing the results of the method of the present invention, the polylable method and the polylable+ method on polygons with a large aspect ratio.
[0055] Fig.12 The figure is a schematic diagram for comparing the results of the present invention, the polylable method and the polylable+ method on polygons with complex outer contours.
[0056] Fig.13 It is another schematic diagram for comparing the results of the present invention, the polylable method and the polylable+ method on a polygon with a complex outer contour.
[0057] Fig.14 It is a schematic diagram for comparing the results of the present invention, the polylable method and the polylable+ method on uneven polygons.
[0058] Fig.15 It is a schematic diagram for comparing the results of the present invention, the polylable method and the polylable+ method on uneven polygons.
[0059] Fig.16 It is another schematic diagram for comparing the results of the present invention, the polylable method and the polylable+ method on uneven polygons. DETAILED DESCRIPTION
[0060] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0061] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which the present invention belongs. The terms used herein in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.
[0062] Please also see Figures 1 to 4 A preferred embodiment of the present invention provides a method for placing labels inside a polygonal area. First, the polygonal area is transformed into evenly distributed points. Then, the generated points are calculated. Voronoi Figure, next Voronoi All edges of the figure are clipped to the boundary of the polygon, through the clipping Voronoi The method proposed in this invention shows significant advantages in adaptability, visual effects and processing efficiency, and is applicable to various complex polygonal areas, and has better adaptability and promotion value in practical applications. The specific steps include:
[0063] S1. Process the boundary of the polygonal area to generate several distribution points, and calculate and generate Voronoi picture, Voronoi After the graph is generated, its boundaries are clipped to the polygon, which can accurately segment the sub-regions of the polygon area. It is suitable for complex or elongated polygonal areas and helps to find the most suitable area for label placement;
[0064] S2. Based on the Voronoi The simplified path of the polygonal area is obtained by graph planning and optimization. The simplified path fits the geometric features of the polygonal area and is a reference line for subsequent label placement, so that the subsequent label placement is more harmonious.
[0065] S3. Calculate the minimum vertical distance from the simplified path to the boundary, calculate the maximum allowable height of the polygonal area where the label can be placed based on the minimum vertical distance, and calculate the maximum font size of the label that can be placed in the polygonal area based on the maximum allowable height, thereby maximizing label placement and improving label readability and layout aesthetics;
[0066] S4. Adjust the label to the maximum font size, make its geometric center coincide with the geometric center of the simplified path, and place the label in the polygonal area based on the simplified path.
[0067] For details, see Figure 2 In step S1, the geographical coordinates of the polygon are converted into two-dimensional plane coordinates, and the distance between the two points of the plane coordinates is calculated using the Euclidean distance formula between two points based on the two-dimensional plane coordinates. The formula is: ,in( )and( ) are the coordinates of the two points, Then the total length of the border of the polygon is calculated, and the border of the polygon area is sampled at equal intervals to generate a number of distribution points, the number of which can be set according to actual needs.
[0068] Specifically, according to the generated nodes, Voronoi The specific steps are as follows:
[0069] S11. Calculate the boundary line of adjacent distribution points: The boundary line is the perpendicular bisector between two adjacent distribution nodes. Voronoi In the figure, any two distribution points ( )and( ) is the line that bisects the distance between two distribution points, and the formula is: , after sorting, we get the linear equation representing the boundary: , this equation defines the two nodes Voronoi Regional boundaries. Connecting the regional boundaries of the distribution points is the corresponding Voronoi The boundary of the graph.
[0070] S12. Calculation and determination Voronoi Vertex: At Voronoi In the figure, Voronoi A vertex is the intersection of three or more boundary lines, each Voronoi A vertex is equidistant from three or more nodes and is obtained by solving a multi-equation system consisting of multiple linear equations as above. Voronoi The coordinates of the vertex.
[0071] S13. Basis Voronoi The vertex corresponding to Voronoi The units are connected into closed polygons: For each distribution node, its corresponding Voronoi The cells are connected to form a closed polygon which can be drawn using the points where the perpendicular bisectors of the distribution points or the equidistant lines intersect.
[0072] S14, intercept the infinitely extended boundary line according to the boundary line to form a closed area, generate Voronoi picture.
[0073] For details, see Figure 3 In step S2, the simplified path of the polygonal area is obtained by:
[0074] S21, associating the nodes in the polygonal area with the adjacent nodes and the weights of the connecting edges between the two nodes;
[0075] S22, selecting the optimal path between nodes according to the weight of the connecting edge according to the fitness formula;
[0076] S23. Simplify the optimal path by combining the radial distance and the Douglas-Peucker algorithm, so as to obtain a simplified path of the polygonal area.
[0077] In this embodiment, step S21 uses the connection table to construct Voronoi A graph of all nodes and edges in the graph, thereby associating the nodes in the polygonal area with their adjacent nodes and the weights of the connecting edges between two nodes. The specific steps are:
[0078] S210, initialize the node array with an empty array storage Voronoi Nodes of the graph;
[0079] S211, double traversing the edges and the nodes of the edges to process each node one by one;
[0080] S212, node check and deduplication, for each node, check whether the node already exists in the nodes set and ensure that the processed node is the first node or not a pruned node. If the node already exists in the nodes, match its id with the existing node to make it uniquely identified in the graph structure;
[0081] S213, when the node is If it does not exist, create a unique , and initialize the adjacency list The attribute is an empty object to store the adjacency list of the node. Next, add the node to gather;
[0082] S214, update the node connection information to connect the two nodes of each edge. Each node in the adjacency list The priority is updated to: ,in, From the start point to the node The distance For edge The weight of
[0083] S215. Create a new empty graph instance , traverse For each node in the array, receive the id of each node and its adjacency list , add it to In the adjacency list of , each node and its adjacency list are added to the graph structure.
[0084] In this embodiment, the specific steps of step S22, selecting the optimal path between nodes, include:
[0085] Use the jkstra algorithm to calculate and find the shortest path between each pair of surrounding nodes, using the fitness formula: , select the path corresponding to the maximum value of each node's fitness as the optimal path, where is the total path length, is the tortuosity,
[0086] = , Value according to The value of for hour, is 2, when for hour, is 4, It is set by the user according to actual needs.
[0087] In this implementation, the specific steps of selecting the optimal path between nodes include:
[0088] create gather, Priority queues and , The collection is used to record the nodes that have been visited. The priority queue is used to dynamically track the shortest path currently found. Used to record the preceding node of the path;
[0089] Set the starting node The priority is 0 and put it in Priority queue;
[0090] from The priority queue extracts the node with the lowest priority. If the node is the target node , then the path search is completed, otherwise, all its unvisited neighbor nodes are added Priority queue, update path;
[0091] Traverse to the target node or the queue is empty.
[0092] In this embodiment, step S23, simplifying the optimal path, specifically includes:
[0093] S231, determine the starting point of the optimal path, traverse all other nodes, calculate the Euclidean distance between the node and the previous node, and when the Euclidean distance is greater than the tolerance value tolerance , then add the point to the simplified point set simplified_points In this simplified point set simplified_points The points in further divide the optimal path;
[0094] S232: Divide the optimal path into several segments, calculate the vertical distances from all points in each segment to the starting point and the end point corresponding to the segment, and record the point with the largest vertical distance. ;
[0095] S233, when the vertical distance is greater than the tolerance value tolerance When , the corresponding point Split the original segment into two new segments;
[0096] S234, when the vertical distance is less than the tolerance value tolerance , the original segments are retained and a simplified path for the polygonal area is generated.
[0097] In this implementation, see Figure 4 , in step S3, the specific steps are:
[0098] S31. Calculate points on the simplified path To several points on the boundary The minimum value of these distances is taken as the point Minimum distance to border , ;
[0099] S32. Calculate the maximum allowable height , , is the maximum allowed width of the step, The minimum aspect ratio of the text;
[0100] S33, update the maximum value between widths ,
[0101] ,in, The increment of each step is a customizable value;
[0102] S34, will Convert to pixels: = , get the maximum font size, where The best-fit method for node traversal can efficiently process large amounts of node data to achieve beautiful and accurate layout effects, thereby effectively reconstructing simplified paths for polygons and placing labels.
[0103] In this embodiment, in step S4, the specific steps are:
[0104] Based on the path length Choose the appropriate text offset based on the specific needs of the label text , the offset is given by the formula Perform dynamic calculations, where , is a dynamic offset factor that controls the starting position of the label relative to the path, ensuring that the labels have a suitable distribution on the path.
[0105] Path geometry center coordinates ,in , , is the number of path vertices, and are the coordinates of the path vertices; the coordinates of the label geometric center ,in In practical applications, the width of the text and height It can be obtained through the text rendering engine. Specifically, the difference between the path geometric center coordinates and the label geometric center coordinates is obtained by calculation. , , to adjust the initial position of the label for ,in , , ensuring that the geometric center of the label coincides with the geometric center of the path. This adjustment process effectively eliminates any potential offset and places the label in the exact center of the path.
[0106] Finally, the process binds the label text to the geometric features of the path through the text rendering engine, so that the label layout can naturally adapt to the curved shape of the path. The label will bend along the tangent direction of the path so that the label text is consistent with the curved shape of the path, thereby ensuring that the label visually fits the shape of the path and maintains overall visual consistency and fluidity. This curved arrangement not only takes into account the geometric features of the path, but also fully considers the text content of the label and its interaction with the path, ensuring that the label presentation effect is more natural and harmonious.
[0107] After completing the maximum font size adjustment, geometric center alignment, and offset setting, the label will eventually be accurately placed on the path. Taking into account the spatial relationship between the label and the path, the reasonable layout of the label on the path is ensured by precise alignment of the geometric center, dynamic adjustment of the offset, and curved arrangement of the label text along the path. Ultimately, through this series of optimizations, the readability and visual performance of the label can be significantly improved, the overall user experience can be enhanced, and a high degree of fit between the label and the path form can be achieved.
[0108] The system for placing labels inside a polygonal area comprises a segmentation unit, a simplified path extraction unit, a font size calculation unit and a label placement unit connected in sequence, wherein the segmentation unit is used to segment the polygonal area and generate picture, The simplified path extraction unit is input into the figure, and the simplified path of the polygonal area is obtained through calculation. The font size calculation unit calculates the maximum font size for placing the label based on the simplified path and the polygonal area. The label placement unit adjusts the current label with reference to the maximum font size obtained by the font size calculation unit, and places the label in the polygonal area after adjustment.
[0109] Specifically, the segmentation unit is provided with a node construction module and Voronoi The graph generation module, in which the node construction module is used to generate a specified number of points by sampling the border of the polygonal area. The specified number can adjust the number of nodes in the graph structure according to the needs to control the complexity of the graph and adjust the level of detail of the label layout. Voronoi The graph generation module processes the boundary nodes constructed by the node construction module to generate polygonal areas. Voronoi picture.
[0110] Specifically, the simplified path extraction unit includes an adjacency table module, a path planning module and a path optimization module, wherein the adjacency table module adds each node and the adjacency table to Voronoi In the graph structure of the graph, the path planning module is equipped with the Dijkstra algorithm for path planning. The path optimization module is equipped with a variety of path optimization strategies, including the longest path optimization strategy, the linearity optimization strategy, and the linearity optimization strategy. There are corresponding matching optimization algorithms. The corresponding optimization strategy can be selected according to actual needs to optimize the path to obtain a simplified path in the polygonal area.
[0111] Specifically, the font size calculation unit includes a minimum distance calculation module, a maximum height and width calculation module and a maximum font size calculation unit. The minimum distance calculation module is used to calculate the minimum distance between the simplified path and the boundary. The maximum height and width calculation module calculates the maximum height and width of the label placement based on the minimum distance. The maximum font size calculation unit calculates the maximum font size of the label based on the maximum width and height.
[0112] Specifically, the label placement unit includes a font size adjustment module and a label placement module. The font size adjustment module adjusts the size of the label to be placed according to the maximum font size. After the size is adjusted, the label placement module calculates and determines the initial position of the label so that the geometric center of the label coincides with the geometric center of the path, and bends the label text along the tangent direction of the path so that the label text is consistent with the curved shape of the path, and the label text is placed in the polygonal area.
[0113] In this embodiment, the placement system also includes an interactive unit and a display unit. The interactive unit is used to provide a channel for users to set parameters of each unit to facilitate fine-tuning of the parameters. The adjustable parameters include the number of nodes, optimization strategy, simplification tolerance, measurement steps and text offset. The display unit is used to display the placement effect of the label in the polygonal area in real time. When the parameters are adjusted, the label placement effect under the current parameters is immediately displayed to provide a more intuitive placement effect, which is convenient for users to adjust and achieve the best label placement effect.
[0114] The advantages and specific effects of the method provided by the present invention are described with specific embodiments:
[0115] 1. Intuitive and flexible parameters
[0116] Different visual effects can be obtained by adjusting parameters, and the visualization scale can be easily adjusted according to actual needs. By adjusting the number of nodes, optimization strategy, simplification tolerance, measurement steps and text offset, users can intuitively and simply control the number of nodes and the generation effect of the picture. This flexibility not only improves the applicability of the algorithm, but also makes the present invention easier to operate and control in practical applications, and can be adjusted to meet the diverse needs of different users. The physical meaning of each parameter and its impact on the image effect are as follows:
[0117] 1. : The number of nodes affects the accuracy and amount of calculation. The default value is 50.
[0118] Parameter participation Voronoi The graph generation process affects the accuracy of the simplified path, which is determined by Figure 5 It can be seen that the larger the parameter value and the more nodes there are, the greater the label placement accuracy will be, but the corresponding amount of calculation will also increase.
[0119] 2. : Simplification tolerance, affects the degree of simplification of the optimal line, the default value is 8.
[0120] Parameters involved in simplifying the best line process affect the position of the labels. Figure 6 It is known that suitable The parameters can balance the display of labels and polygon geometric features.
[0121] 3. : The number of measurement steps controls the density of path measurement points. The default value is 8.
[0122] Affects accuracy and computational cost. Figure 7 It can be seen that the smaller the parameter value, the greater the density of path measurement points and the greater the label placement accuracy, but the corresponding calculation amount will also increase.
[0123] 4. : Text offset, which controls the degree to which the label is offset from the center. The default value is 0.5.
[0124] Affects the final position of the note. Users can change the offset according to different needs. Figure 8 It can be seen that choosing the right The value maximizes the placement of the label inside the polygon.
[0125] 5. : Optimization strategy, controlling the selection of the optimal path.
[0126] Influences the selection of the optimal path. Users can change the optimal path according to different needs. If you care a little about straightness, the k value is 2. If you care a lot about straightness, the k value is 4. Fig. 9 It is known that choosing the appropriate A value that maximizes the accuracy of labeling within polygons.
[0127] The method can be used for complex polygons of various shapes. The present invention has excellent visual effects. It can be seen from the result test comparison chart that the method of the present invention is applicable to different polygons, especially when the polygon has a large aspect ratio, a complex outer contour, an uneven edge, and a hole inside, and has better adaptability and effect than other methods. Fig.10 , 11 As shown, for polygons with a large aspect ratio, the polygon region interior label placement algorithm can place labels inside the polygon, which conforms well to the polygon geometric features and has a good visual effect.
[0128] like Fig.12 , 13 As shown, for polygons with complex outer contours, the method of the present invention can better place the label close to the polygon shape characteristics and curve features, and has a good visual effect.
[0129] like Fig.14 As shown, for uneven polygons, the method of the present invention can effectively fit the polygon curve features and make the labels evenly distributed inside the polygon.
[0130] like Fig.15 , 16 As shown, for concave polygons and polygons with holes, the method of the present invention can better place the label close to the polygon shape characteristics and curve features, and has a good visual effect.
[0131] In summary, compared with the existing methods, the method of the present invention can place the label inside the polygon while making the label conform to the polygon shape characteristics and curve features, especially when the polygon has a large length and width ratio, a complex outer contour, uneven edges, and an overall concave polygon with holes inside, the method of the present invention can provide better visual effects.
[0132] Through user evaluation tests, the visual aesthetics, ease of use, and adaptability to complex scenarios of the method of the present invention and the existing polyable and polyable+ methods in scenarios of different complexity were quantitatively analyzed, and the performance of the three algorithms in terms of aesthetics, adaptability, etc. was comprehensively evaluated by combining subjective scoring and evaluation. The evaluation process was tested by multiple users who were sensitive to label clarity and aesthetics. The evaluation process includes three test scenarios with increasing complexity. After completing the label placement tasks of the three algorithms, the users scored and analyzed the results based on the following indicators. The evaluation indicators are as follows:
[0133] 11. Visual aesthetics
[0134] Definition: Measures the harmony of label placement results with polygon geometry and the overall visual effect, including whether visual noise, unnecessary overlap, and the intuitiveness of label layout are avoided.
[0135] Scoring criteria: The user's subjective scoring is used, and the scoring is based on whether it meets the user's psychological expectations and whether it is in an ideal visual position. The scoring range is 1-5 points (1 means completely unattractive and 5 means very beautiful).
[0136] 2. Ease of use
[0137] Definition: Measures the user's ease of use of the algorithm, the flexibility of parameter adjustment functions, and the timeliness of system feedback.
[0138] Rating criteria: User feedback was collected through a questionnaire survey with a rating range of 1-5 (1 means very dissatisfied and 5 means very satisfied).
[0139] 3. Adaptability to complex scenarios
[0140] Definition: Evaluates the adaptability of an algorithm when processing complex polygons (such as polygons with internal holes, concave and convex boundaries, or slender shapes), including the ability to maintain consistency and accuracy of geometric features of different forms, and the ability to flexibly respond to complex polygon structures.
[0141] Scoring criteria: The algorithms are scored by comparing their placement accuracy and the degree of fit to geometric features in highly complex shape scenes to quantify their performance differences in complex scenes.
[0142] Through the comprehensive evaluation of the above indicators, we can quantitatively compare the performance of different algorithms in terms of visual effects, user experience and complex scenarios, and provide a scientific basis for the practical application of optimization algorithms.
[0143] The average user ratings are collected as shown in Table 1 below. The method of the present invention can generate highly aesthetic label layouts in polygons of different complexities, especially in irregular, slender or complex-boundary polygon scenes, and its visual effect is significantly better than existing algorithms. Through intuitive algorithm parameter adjustment (such as the number of nodes, offset, font size), this method allows users to adjust the label layout effect according to actual needs, thereby achieving more flexible label management. Users can easily achieve the optimal label layout in polygons of different complexities, greatly improving the ease of operation and overall user experience.
[0144] Table 1
[0145]
[0146] It has shown significant advantages in three key indicators:
[0147] Visual aesthetics is an indicator that measures whether the label layout meets the user's psychological expectations and can be presented in an ideal visually harmonious position. In terms of visual aesthetics, this method received an average score of 4.8 points, which is superior to the 3.6 points of the polylable algorithm and the 4.0 points of the polylable+ algorithm. Users particularly mentioned that the labels generated by this method in irregular polygonal scenes are not only clear and readable, but also highly consistent with the geometric features of the polygons in terms of visuality, which meets the user's psychological expectations and is placed in an ideal visually harmonious position to achieve visual harmony and aesthetic optimization of the layout.
[0148] b. Ease of use
[0149] This index mainly reflects the user's subjective usability of the system interaction design and parameter adjustment function. In terms of user usability index, this method received an average score of 4.7 points, which is higher than the 3.5 points of the polyLabel algorithm and the 4.1 points of the polyLabel+ algorithm. Users generally believe that the interface design of this method is intuitive and concise, the operation logic is clear, and it performs well in parameter adjustment function.
[0150] Specifically, this method provides a variety of adjustable parameters, such as the number of nodes, path optimization strategy, simplification tolerance value, measurement steps and text offset, etc. These parameters can be adjusted in real time in an interactive manner to help users flexibly optimize label layout effects according to different application scenarios. This method supports instant preview when adjusting parameters, so that the adjusted visual effects can be presented quickly, which greatly improves the interaction efficiency and makes the label placement process more controllable and efficient, and the overall operation experience is significantly improved. This interactive capability not only meets the sophisticated needs of professional users, but also adapts well to the operating habits of ordinary users.
[0151] c. Adaptability
[0152] The adaptability evaluation mainly examines the system's generalization ability in different scenarios, especially its performance on complex polygons. This method scored 4.6 points in the scene adaptability test, significantly better than the 3.5 points of the polylable algorithm and the 4.0 points of the polylable+ algorithm. Users generally believe that this method shows a high degree of flexibility in dealing with complex geometric structures, and the label layout can adapt to the shape characteristics of polygons while maintaining a high generation efficiency, thus meeting the requirements for efficiency and accuracy in practical applications.
[0153] In summary, user evaluation further verified that this method showed excellent performance in visual aesthetics, user experience and scene adaptability, reflecting its application value and practicality in complex polygonal label layout.
[0154] In some other preferred embodiments of the present invention, a computer-readable storage medium is provided, storing a computer program. When the computer program is executed by a processor, the processor executes the steps of the method described in the above embodiment.
[0155] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program codes.
[0156] The above description is a detailed description of the preferred feasible embodiments of the present invention, but the embodiments are not intended to limit the scope of the patent application of the present invention. All equivalent changes or modified changes completed under the technical spirit suggested by the present invention should fall within the patent scope covered by the present invention.
Claims
1. A method for placing labels inside a polygonal area, characterized in that: include: Process the border of the polygonal area to generate several distribution points, and generate Voronoi picture; Based on the Voronoi Graph planning and optimization to obtain a simplified path of the polygonal area; Calculate the minimum vertical distance from the simplified path to the boundary, calculate the maximum allowable height of the polygonal area where the label can be placed based on the minimum vertical distance, and calculate the maximum font size of the polygonal area where the label can be placed based on the maximum allowable height; Adjust the label to the maximum font size, make its geometric center coincide with the geometric center of the simplified path, and place the label in the polygonal area based on the simplified path; The generation Voronoi The specific steps include: Calculate the boundary lines of adjacent distribution points; Calculation Voronoi vertex; in accordance with Voronoi The vertex corresponding to Voronoi The cells are connected into closed polygons; According to the boundary line, the infinitely extended boundary line is intercepted to form a closed area and generate Voronoi picture; The specific steps of optimizing and obtaining the simplified path of the polygonal area include: Associating the nodes in the polygonal area with the weights of the adjacent nodes and the connecting edges between the two nodes; According to the weight of the connecting edge, the optimal path between nodes is selected according to the fitness formula; The optimal path is simplified in combination with the radial distance, thereby obtaining a simplified path of the polygonal area.
2. The method for placing labels inside a polygonal area according to claim 1, characterized in that: The total length of the border of the polygon is calculated, and a number of distribution points are generated by equidistant sampling.
3. The method for placing labels inside a polygonal area according to claim 1, characterized in that: Constructed using a link table Voronoi A graph of all nodes and edges in the graph, thereby associating the nodes in the polygonal area with their adjacent nodes and the weights of the connecting edges between two nodes.
4. The method for placing labels inside a polygonal area according to claim 1, characterized in that: The specific steps of selecting the optimal path between nodes include: Use Dijkstra's algorithm to find the shortest path between each pair of surrounding nodes; Through the fitness formula: , select the path corresponding to the maximum fitness of each node as the optimal path, where length is the total path length, sinuosity is the tortuosity, , Value according to strategy The value of strategy for medium hour, is 2, when strategy for shortest hour, k is 4.
5. The method for placing labels inside a polygonal area according to claim 1, characterized in that: The specific steps to simplify the optimal path include: Determine the starting point of the optimal path, traverse all other points, calculate the Euclidean distance between the node and the previous node, and when the Euclidean distance is greater than the tolerance value tolerance , then add the node to the simplified point set simplified_ points According to the simplified point set simplified_points The points in further divide the optimal path; Divide the optimal path into several segments, calculate the vertical distances from all points in each segment to the corresponding starting and ending points of the segment, and record the point with the largest vertical distance. max_point ; When the vertical distance is greater than the tolerance value tolerance When , the corresponding point max_point Split the original segment into two new segments; When the vertical distance is less than the tolerance value tolerance , the original segmentation is retained and a simplified path for the polygonal area is generated.
6. The method for placing labels inside a polygonal area according to claim 1, characterized in that: Calculate the points on the simplified path ( x 2, y 2) To several points on the boundary ( x 1, y 1), take the minimum value of these distances as the point ( x 2, y 2) Minimum distance to the boundary d boundary , ; Calculate the maximum allowed height W step , , W step is the maximum allowed width of the step, The minimum aspect ratio of the text; Update the maximum value between widths , ,in, is the increment of each step; Will Convert to pixels: , get the maximum font size, where For every 100 pixels of width.
7. A system for placing labels inside a polygonal area, used to implement the method for placing labels inside a polygonal area according to any one of claims 1 to 6, characterized in that: The invention comprises a segmentation unit, a simplified path extraction unit, a font size calculation unit and a label placement unit connected in sequence, wherein the segmentation unit is used to segment the polygonal area to generate Voronoi picture, Voronoi The simplified path extraction unit is input into the figure, and the simplified path of the polygonal area is obtained through calculation. The font size calculation unit calculates the maximum font size for placing the label based on the simplified path and the polygonal area. The label placement unit adjusts the current label with reference to the maximum font size obtained by the font size calculation unit, and places the label in the polygonal area after adjustment.
Citation Information
Patent Citations
Wireless sensor network node coverage optimization method based on Voronoi diagram for blind area
CN104159236A
Unmanned aerial vehicle path planning method for reconstructing Voronoi diagram in real time
CN111750869A