Disclosure of Invention
Aiming at the problems in the prior art, the invention provides a method for generating a recursive molecular annotation structure of an electronic map, which can support a multi-molecular annotation structure with a complex structure, support rich annotation content and promote the visual attraction and information quantity of the map.
The invention discloses a method for generating a recursive molecular labeling structure of an electronic map, which comprises the following steps:
s1, obtaining marking structure units corresponding to all parts of a molecular marking structure to be generated, wherein the marking structure units comprise character units corresponding to character parts and separator units corresponding to separators for separating the character parts;
s2, determining the grade value of each labeling structure unit based on the score line level of the corresponding part of the labeling structure unit in the molecular labeling structure;
S3, combining and grouping all marking structural units according to a set rule in a recursion mode according to the order of the level values from high to low to obtain grouping structural units so as to replace the marking structural units corresponding to the grouping structural units, calculating the pixel size of the grouping structural units at the corresponding parts of the molecular marking structure, and repeating until the marking structural units are completely replaced to obtain the complete pixel size of the molecular marking structure;
s4, acquiring a marking point of the map and firstly determining a drawing position coordinate of a molecular marking structure on the map based on the size of the complete pixel; then, the grouping structural units are restored to replaced marking structural units according to the reverse sequence of merging and grouping, the drawing range is determined, and the steps are repeated until the grouping structural units are fully restored, and the drawing range of each marking structural unit is determined;
And S5, drawing and generating a molecular labeling structure on the map based on the determined labeling structure unit.
Further, in the step S1, the separator units comprise horizontal separator units corresponding to horizontal separator parts for separating left and right characters and fractional line separator units corresponding to fractional line parts for dividing upper and lower characters, wherein the corresponding parts of the horizontal separator units are not displayed in the molecular labeling structure.
In the step S1, each labeling structural unit is stored through a labeling structural unit list.
Further, the step S1 specifically includes:
Splitting the selected text units according to the selected splitting mode;
If the character units are split up and down, a newly added score line separator unit and a character unit are obtained, so that a corresponding score formula is formed on the molecular marking structure, wherein the molecules of the score formula correspond to the selected character units, the score lines correspond to the newly added score line separator units, and the denominators correspond to the newly added character units;
If the character units are split left and right, a newly added horizontal separator unit and a character unit are obtained, so that two corresponding adjacent character parts are formed on the molecular marking structure, wherein the character parts corresponding to the selected character units and the newly added character units are respectively positioned at the left side and the right side, and the horizontal separator part corresponding to the newly added horizontal separator unit is positioned between the left character unit and the right character unit.
Further, the step S2 includes:
The rank values of the text units and horizontal separator units are determined based on the following expressions, respectively:
level Text with a character pattern=2n
level horizontal separator=2n
the class value of the score line separator unit of the score line where the corresponding part of the text unit/horizontal separator unit is located in the molecular labeling structure is determined based on the following expression:
level Score line=(level Text with a character pattern or level horizontal separator) -1
Wherein level Text with a character pattern is the rank value of the word unit, level horizontal separator is the rank value of the horizontal separator unit, and level Score line is the rank value of the score line separator unit;
n is a natural number greater than or equal to 0, and is determined based on the number of fractional line levels at which the corresponding part of the labeling structural unit is located in the molecular labeling structure. When n=0, it means that the labeling structural unit has no associated score line in the molecular labeling structure, and is naturally not in any score line level, so the number of layers is 0.
Further, the step S2 comprises the step of determining the grade value of the selected text unit based on the following expression:
level Selecting=2n
Wherein level Selecting is a level value of the selected word unit, n is a natural number greater than or equal to 0, and is determined based on the number of fractional line levels of the corresponding part of the labeling structure unit in the molecular labeling structure;
Under the condition of splitting the selected word units up and down, changing the grade value of the selected word units into a grade Selecting +2, determining the grade value of the newly added fractional line separator unit as a grade Selecting +1, and determining the grade value of the newly added word units as the same grade value as the grade value of the selected word units after being changed;
When the character unit is split left and right, the level value of the added horizontal separator unit and the character unit is determined to be the same as the level value of the selected character unit.
Further, the step S2 further includes:
determining a binding relation of the labeling content corresponding to each labeling structure unit, wherein the binding relation of the labeling content is used for dynamically acquiring the labeled text content;
determining sequence indexes corresponding to labeling structural units according to the sequence from high to low, from left to right and from top to bottom of the level values corresponding to the parts of the molecular labeling structure;
And determining symbol pattern definition corresponding to each labeling structure unit, wherein the symbol pattern definition corresponding to the word unit is a font symbol, and the symbol pattern definition corresponding to the score line separator unit is a line symbol.
Further, the step S3 includes:
s301, determining the pixel size of a Chinese unit in a molecular labeling structure based on the labeling content binding relation and symbol pattern definition of the Chinese unit;
S302, searching a separator unit with the maximum level value in a labeling structure unit list, merging and grouping the separator unit with a text unit corresponding to a text part adjacent to a corresponding separator in a molecular labeling structure to obtain a grouping structure unit;
s303, calculating the pixel size of the grouping structural unit;
s304, replacing the corresponding marking structural units in the marking structural unit list with the obtained grouping structural units to obtain a new marking structural unit list as a new searching object;
and S305, repeating the steps S302 to S304 until the grouping structural units replace all the labeling structural units, wherein the calculated pixel size of the grouping structural units is the complete pixel size of the molecular labeling structure.
Further, the step S302 includes:
Searching a separator unit with the largest level value in the labeling structure unit list;
if the separator unit is a horizontal separator unit, the horizontal separator units with the same grade value and continuous are searched, and the adjacent marking structure units are combined and grouped to obtain grouping structure units;
if the separator unit is a fractional line separator unit, merging and grouping the found fractional line separator unit and the adjacent marking structure units to obtain a grouping structure unit;
for the grouping structure units obtained by grouping the horizontal separator units, the height of the grouping structure units is the maximum value of the heights of the marking structure units in the grouping structure units, and the width of the grouping structure units is the sum of the widths of the marking structure units in the grouping structure units;
for the grouping structure units obtained by combining and grouping the score line separator units, the height is the sum of the thickness of each marking structure unit and the score line, and the width is the maximum width of the marking structure unit.
Further, the step S303 further includes:
The relative position of the tag structural unit in relation to the upper left corner of the group structural unit on the map is determined.
Further, the step S4 includes:
s401, calculating pixel coordinates of the marked points on the map by giving geographical coordinates of the marked points, the display range of the current map and a scale;
S402, calculating pixel coordinates of the upper left corner of the molecular labeling structure on the map according to pixel coordinates of the labeling points, the relative relation between the labeling points and the molecular formula labeling, and the complete pixel size of the molecular labeling structure;
S403, restoring the replaced marking structural units according to the reverse sequence of the merging and grouping of the grouping structural units, and determining the drawing range of the restored marking structural units by combining the pixel coordinates of the upper left corner of the grouping structural units and the relative positions of the marking structural units in the grouping structural units relative to the upper left corner of the grouping structural units;
S404, repeating the step S403 until all the grouping structural units are restored to obtain the drawing range of each labeling structural unit.
The invention has at least the following beneficial effects:
1. And constructing and updating the complex annotation structure. Based on the technical idea of infinite hierarchical splitting of the molecular formula concept, a complex and changeable map labeling structure can be decomposed into smaller and easier to manage parts (labeling structural units) in a recursive manner.
2. Flexible expansion of molecular annotation structures. The step-by-step decomposition interaction design based on infinite resolution can be used for carrying out transverse resolution expansion or longitudinal resolution expansion on any part based on the existing molecular labeling structure, and even deleting the existing resolution expansion strategy.
3. And calculating the dynamic size of the molecular labeling structure. The adoption of dynamic association of the labeling content and the molecular labeling structure only needs to define a set of molecular structure, and the labeling of different text contents can be expressed by combining the binding relation of the labeling content. Meanwhile, the drawing range of each molecular structure unit can be dynamically calculated in the drawing process, a user does not need to define the range of each component part in the molecular labeling structure in advance, and the use is more convenient and flexible.
Other advantageous effects of the present invention will be described in detail in the detailed description section.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the technical solutions of the present invention will be described in detail below. It will be apparent that the described embodiments are only some, but not all, embodiments of the invention. All other embodiments, based on the examples herein, which are within the scope of the invention as defined by the claims, will be within the scope of the invention as defined by the claims.
As shown in fig. 1, the invention discloses a method for generating a recursive molecular annotation structure of an electronic map, which comprises the following steps:
s1, obtaining marking structure units corresponding to all parts of a molecular marking structure to be generated, wherein the marking structure units comprise character units corresponding to character parts and separator units corresponding to separators for separating the character parts;
s2, determining the grade value of each labeling structure unit based on the score line level of the corresponding part of the labeling structure unit in the molecular labeling structure;
S3, combining and grouping all marking structural units according to a set rule in a recursion mode according to the order of the level values from high to low to obtain grouping structural units so as to replace the marking structural units corresponding to the grouping structural units, calculating the pixel size of the grouping structural units at the corresponding parts of the molecular marking structure, and repeating until the marking structural units are completely replaced to obtain the complete pixel size of the molecular marking structure;
s4, acquiring a marking point of the map and firstly determining a drawing position coordinate of a molecular marking structure on the map based on the size of the complete pixel; then, the grouping structural units are restored to replaced marking structural units according to the reverse sequence of merging and grouping, the drawing range is determined, and the steps are repeated until the grouping structural units are fully restored, and the drawing range of each marking structural unit is determined;
And S5, drawing and generating a molecular labeling structure on the map based on the determined labeling structure unit.
As shown in fig. 2, the molecular labeling structure is drawn by a plurality of labeling structural units, the labeling structural units exist in a list form (also called a labeling structural unit list), and the labeling structural units mainly comprise three types, namely characters, horizontal separators (content cannot be displayed on a map) and score line separators (score lines are drawn on the map). Each labeling structure unit is provided with five parts of sequence index, grade value, symbol style definition (character corresponds to font symbol, score line corresponds to linear symbol), drawing range (needing subsequent calculation) and labeling content binding relation.
The deeper the level of the numerator or denominator level n (starting from 1) at which the horizontal separator is located, the greater its level, the level value of the level being 2n, the level value of the score line separator level at which it is located being 2n-1, the level of the labeled building block 2 being 2, and the level of the labeled building block 4 being 1 in fig. 2. The order index is arranged in order of the labeling structural elements from high level to low level, left to right, and top to bottom. The label content binding relation is used for dynamically acquiring labeled text content, for example, when certain field content of a table needs to be displayed based on a certain molecular label structure on a map, the label content binding relation can be bound into a certain field of the table, so that different records of the table can be displayed based on the molecular label structure on the map. The display text supports chinese-english characters, punctuation marks, or user-defined TrueType characters, as shown in table 1 below.
TABLE 1
TrueType is a novel mathematical glyph description technique jointly proposed by Apple corporation and Microsoft corporation. TrueType is a technique for describing the outline of a font by a mathematical function. It includes the instructions of font construction, colour filling, digital describing function, flow condition control, grid processing control and additional prompt control. The content of the annotation not only supports characters and special characters, but also supports extension symbols such as tree species symbols, forest species symbols and the like, thereby improving the visual richness and information quantity of map annotation.
Referring to fig. 4, the present embodiment discloses a flow based on the existing molecular formula labeling structure extension—the structural unit, and the user can perform infinite hierarchical splitting based on the flow, and generate a functional interface design in combination with the recursive molecular labeling structure in fig. 3, so that the operation is flexible and simple. Specifically, the process of adding the labeling structural unit in a splitting mode comprises the following steps:
Selecting a labeling structural unit to be cut (setting the grade 2n thereof);
Selecting a split type:
If the horizontal splitting is adopted, a horizontal separator and a labeling structural unit are sequentially inserted after the labeling structural unit is selected, and the grade is 2n;
if vertical splitting is adopted, the level of the marking structure unit selected at present is adjusted to 2n+2, and a fraction line separator unit (the level value is 2n+1) and a marking structure unit (the level is 2n+2) are sequentially inserted after the structure unit is selected;
rearranging the sequence of each labeling structural unit from inside to outside, left to right and top to bottom in the molecular formula;
And (5) ending.
In some preferred embodiments of the present invention, the step S1 specifically includes:
Splitting the selected text units according to the selected splitting mode;
If the character units are split up and down, a newly added score line separator unit and a character unit are obtained, so that a corresponding score formula is formed on the molecular marking structure, wherein the molecules of the score formula correspond to the selected character units, the score lines correspond to the newly added score line separator units, and the denominators correspond to the newly added character units;
If the character units are split left and right, a newly added horizontal separator unit and a character unit are obtained, so that two corresponding adjacent character parts are formed on the molecular marking structure, wherein the character parts corresponding to the selected character units and the newly added character units are respectively positioned at the left side and the right side, and the horizontal separator part corresponding to the newly added horizontal separator unit is positioned between the left character unit and the right character unit.
In some preferred embodiments of the present invention, it is specifically disclosed how to determine a hierarchical value of an annotated structural unit, comprising:
The rank values of the text units and horizontal separator units are determined based on the following expressions, respectively:
level Text with a character pattern=2n
level horizontal separator=2n
the class value of the score line separator unit of the score line where the corresponding part of the text unit/horizontal separator unit is located in the molecular labeling structure is determined based on the following expression:
level Score line=(level Text with a character pattern or level horizontal separator) -1
Wherein level Text with a character pattern is the rank value of the word unit, level horizontal separator is the rank value of the horizontal separator unit, and level Score line is the rank value of the score line separator unit;
n is a natural number greater than or equal to 0, and is determined based on the number of fractional line levels at which the corresponding part of the labeling structural unit is located in the molecular labeling structure. When n=0, it means that the labeling structural unit has no associated score line in the molecular labeling structure, and is naturally not in any score line level, so the number of layers is 0.
For example, in the molecular labeling structure shown in fig. 2, A, B is a numerator of a score line, C, D is a denominator of a score line, and since A, B, C, D is related to only one score line, the corresponding hierarchical number of A, B, C, D is 1, i.e., n=1, the hierarchical value is 2n=2, the hierarchical value of the score line is 2n—1=1, and the hierarchical level of the score line is 0, i.e., n=0, and the hierarchical value of the score line is 2n=0 because the score line is not a numerator or a denominator of any score line.
In some preferred embodiments of the present invention, for the splitting of text units disclosed in the above embodiments, it is specifically disclosed how the rank value is subsequently determined, specifically including that the rank value of the selected text unit is determined based on the following expression:
level Selecting=2n
Wherein level Selecting is a level value of the selected word unit, n is a natural number greater than or equal to 0, and is determined based on the number of fractional line levels of the corresponding part of the labeling structure unit in the molecular labeling structure;
Under the condition of splitting the selected word units up and down, changing the grade value of the selected word units into a grade Selecting +2, determining the grade value of the newly added fractional line separator unit as a grade Selecting +1, and determining the grade value of the newly added word units as the same grade value as the grade value of the selected word units after being changed;
When the character unit is split left and right, the level value of the added horizontal separator unit and the character unit is determined to be the same as the level value of the selected character unit.
In some preferred embodiments of the present invention, the step S2 further includes:
determining a binding relation of the labeling content corresponding to each labeling structure unit, wherein the binding relation of the labeling content is used for dynamically acquiring the labeled text content;
determining sequence indexes corresponding to labeling structural units according to the sequence from high to low, from left to right and from top to bottom of the level values corresponding to the parts of the molecular labeling structure;
And determining symbol pattern definition corresponding to each labeling structure unit, wherein the symbol pattern definition corresponding to the word unit is a font symbol, and the symbol pattern definition corresponding to the score line separator unit is a line symbol.
Referring to the flow of calculating the overall size (the pixel size on the map) by the recursive molecular labeling structure shown in fig. 5, specifically includes:
starting (labeling building blocks for already constructed molecules);
Combining ① font style settings, a screen DPI, a score line style, an alignment mode and the like, and marking the characters with ② to calculate the sizes of the characters, namely the sizes of pixels drawn on a map (the original point is unknown);
Searching separators of all levels of the labeling structure unit list (level=m (max refers to maximum value) to judge whether the separators exist or not, and if the separators do not exist, directly entering the following m=m-1 stage;
If so, judging whether the horizontal separator exists;
If so, searching the horizontal separators with the same grade and continuous and the adjacent marking structural units (namely left and right parts of the separators);
The grouping structure unit is set and recorded as follows:
(1) Recording the height of the packet = the height maximum value of each annotation structure unit;
(2) Recording packet width = sum of widths of individual structural units;
(3) The relative position of each annotation structure unit with respect to the upper left corner of this group is recorded.
If not, finding adjacent structural units (namely upper and lower parts of the score line);
The grouping structure unit is set and recorded as follows:
(1) Recording the height of the packet = sum of the heights of the labeling structural units + score line thickness;
(2) Record packet width = label structure unit width maximum;
(3) Recording the length of the score line as the width of the packet;
(4) The relative positions of the text and score lines relative to the top left corner of the group are recorded.
After the recording is completed, the grouping structural units are used for replacing the structural units in the grouping in the marking structural unit list, and a new marking structural unit list is created and used as a new searching object;
Obtaining a new m value, namely a new search target value, by m=m-1;
And judging whether m is greater than or equal to 0, if so, returning to search the separator again, and if not, acquiring the pixel size of the whole molecular labeling structure, and ending the calculation.
In some preferred embodiments of the present invention, the step S3 includes:
s301, determining the pixel size of a Chinese unit in a molecular labeling structure based on the labeling content binding relation and symbol pattern definition of the Chinese unit;
S302, searching a separator unit with the maximum level value in a labeling structure unit list, merging and grouping the separator unit with a text unit corresponding to a text part adjacent to a corresponding separator in a molecular labeling structure to obtain a grouping structure unit;
s303, calculating the pixel size of the grouping structural unit;
s304, replacing the corresponding marking structural units in the marking structural unit list with the obtained grouping structural units to obtain a new marking structural unit list as a new searching object;
and S305, repeating the steps S302 to S304 until the grouping structural units replace all the labeling structural units, wherein the calculated pixel size of the grouping structural units is the complete pixel size of the molecular labeling structure.
Further, the step S302 includes:
Searching a separator unit with the largest level value in the labeling structure unit list;
if the separator unit is a horizontal separator unit, the horizontal separator units with the same grade value and continuous are searched, and the adjacent marking structure units are combined and grouped to obtain grouping structure units;
if the separator unit is a fractional line separator unit, merging and grouping the found fractional line separator unit and the adjacent marking structure units to obtain a grouping structure unit;
for the grouping structure units obtained by grouping the horizontal separator units, the height of the grouping structure units is the maximum value of the heights of the marking structure units in the grouping structure units, and the width of the grouping structure units is the sum of the widths of the marking structure units in the grouping structure units;
for the grouping structure units obtained by combining and grouping the score line separator units, the height is the sum of the thickness of each marking structure unit and the score line, and the width is the maximum width of the marking structure unit.
Further, the step S303 further includes:
The relative position of the tag structural unit in relation to the upper left corner of the group structural unit on the map is determined.
Referring to the flow for calculating the drawing range of each labeling structural unit shown in fig. 6, the method comprises the following steps:
the pixel position of the upper left corner on the map is marked entirely;
searching the rest newly constructed structure unit list in reverse order according to the time sequence of generation;
Judging whether the group exists or not, if so, finding out each group of structural units, and calculating the drawing pixel range of each structural unit in the group according to the relative position of each structural unit in the group relative to the group;
If not, acquiring each text structure unit and the drawing pixel range of the score line;
Drawing each text structure unit and score lines on the map;
And (5) ending.
In some preferred embodiments of the present invention, the step S4 includes:
s401, calculating pixel coordinates of the marked points on the map by giving geographical coordinates of the marked points, the display range of the current map and a scale;
S402, calculating pixel coordinates of the upper left corner of the molecular labeling structure on a map according to pixel coordinates of the labeling points, the relative relation between the labeling points and the molecular formula labeling (such as the consistency between the center of the molecular formula labeling and the labeling points) and the complete pixel size of the molecular labeling structure;
S403, restoring the replaced marking structural units according to the reverse sequence of the merging and grouping of the grouping structural units, and determining the drawing range of the restored marking structural units by combining the pixel coordinates of the upper left corner of the grouping structural units and the relative positions of the marking structural units in the grouping structural units relative to the upper left corner of the grouping structural units;
S404, repeating the step S403 until all the grouping structural units are restored to obtain the drawing range of each labeling structural unit.
The step S5 specifically comprises the step of drawing and presenting on a map based on the definition of the drawing style of each text and the score line and the drawing range thereof.
The foregoing is merely illustrative of the present invention, and the present invention is not limited thereto, and any person skilled in the art will readily recognize that variations or substitutions are within the scope of the present invention.