Summary of the invention
The present invention is intended to solve above-mentioned the problems of the prior art, proposes a kind of method of searching interest point fast.
Second purpose of the present invention provides a kind of interest point search device.
In order to address the above problem and to achieve the above object, interest point search method of the present invention may further comprise the steps: the data that 1) read the point of interest in the map sheet; 2) calculate peripheral extent point of interest and peripheral distance; 3) the peripheral binary sort tree with the fixed-node number n screens interest points meeting requirements; After said peripheral binary tree sort tree is meant that binary tree is by inorder traversal; Resulting node is pressed the peripheral binary tree of the ascending orderly arrangement of peripheral distance, and should preserve left subtree, right subtree, father's node and peripheral distance by the periphery binary tree; 4) take out interest points meeting requirements.
In interest point search method of the present invention, the storage of putting together of the longitude of all points of interest and latitude, the remainder data of point of interest is placed on its back and stores together.
So just can when calculating peripheral distance and peripheral extent point of interest at every turn, only need read the longitude in the detailed data of point of interest and latitude and remainder data separate processes in longitude and latitude, and need not read other data, thus the time of shortening read data.
In interest point search method of the present invention, before calculating peripheral distance, judge that the peripheral extent point of interest is in a rectangular extent.The scope of rectangular extent on longitude and latitude is respectively A*B and A*C, and wherein A is the maximum length that allows, and B is a longitude factor, and C is a latitude.As not just to judge that this point of interest is not in the scope that will search.If the longitude and the longitude of current location point of interest and other points of interest subtract each other, latitude and latitude subtract each other respectively less than A*B, A*C, then this point of interest is in rectangular extent, otherwise this point of interest is not in said rectangular extent.
Like this,, do not need to calculate peripheral distance again, thereby reduced the time of calculating peripheral distance for not being the point of interest in the rectangular extent.
In interest point search method of the present invention, introduce the peripheral binary sort tree of fixed-node number n, and always minimum front n of the peripheral distance of all nodes in the binary sort tree.And be rightmost that the maximum node of peripheral distance is preserved.Reduce the time of ordering like this with regard to available following steps.
Step 1: if in the peripheral binary sort tree of fixed-node number the node number less than n; (n is that the fixed-node number of the peripheral binary sort tree of fixed-node number is the maximal value of binary sort tree node number) then inserted this node by the method that binary sort tree inserts new node.But if this peripheral distance that inserts node equals the peripheral distance of certain node A in the peripheral binary sort tree of fixed-node number, then this inserts node and inserts as the left child node of node A.And the original left child node of node A is placed on the left child node that inserts node.
Step 2: if the node number equals n in the peripheral binary sort tree of fixed-node number, (n is that the fixed-node number of the peripheral binary sort tree of fixed-node number is the maximal value of binary sort tree node number).Compare the rightmost node that the maximum node of this new node and peripheral distance is promptly preserved, see that which peripheral distance is big; If this new node is big, then skip, continue more next point of interest.If this new node is little; Then delete rightmost node M in the peripheral binary sort tree of fixed-node number; Compose the value of new node to deleting rightmost node M in the binary tree then, rightmost node M inserts by the method that binary sort tree inserts new node in the binary tree deleting again; The back is new binary tree rightmost that the maximum node of peripheral distance is preserved; Compose and give node M.Continue more next point of interest.If the peripheral distance of this new node equals the peripheral distance of certain node B in the peripheral binary sort tree of fixed-node number; Then delete rightmost node M in the peripheral binary sort tree of fixed-node number; Compose the value of new node to deleting rightmost node M in the binary tree then; Deleted rightmost node M in the binary tree to this and inserted, and the original left child node of node B is placed on this left child node of having deleted rightmost node M in the binary tree as the left child node of node B; The back is new binary tree rightmost that the maximum node of peripheral distance is preserved; Compose and give node M.Continue more next point of interest.
Because n node of the fixing use of the peripheral binary sort tree of fixed-node number is promptly only with array [n]; Each array member's size is the node size of the peripheral binary sort tree of fixed-node number.The left subtree of node, right subtree, father's node are all represented to one of n with subscript 1; Realize the management voluntarily of internal memory; Avoid because of internal memory is too little frequent dynamic assignment and the slow-footed problem that causes.Thereby improve speed generally.
Inorder traversal through binary sort tree at last can obtain the result.
Because the screen of mobile phone is less, its processor speed is slow and internal memory is little, and preferably, the n value is 50 to 200.
In the said method, read data: effect is to read out point of interest longitude and latitude in the map sheet, is used to calculate peripheral extent point of interest and peripheral distance.Calculate peripheral extent point of interest and peripheral distance: effect is to judge whether given arbitrary point of interest is the peripheral point of interest of wanting.Peripheral binary sort tree screening interest points meeting requirements with the fixed-node number: effect is to be whether peripheral distance should be stayed in the peripheral binary sort tree less than the point of interest of certain numerical value to what meet the peripheral distance requirement.After all interest point datas are all handled, finally stay point of interest in the peripheral binary sort tree and be exactly the point of interest that will obtain.Take out interest points meeting requirements: effect is to take out the point of interest in the peripheral binary sort tree, converts the detailed data of point of interest to.
The present invention further proposes a kind of interest point search device, and it comprises: storage unit, center calculation unit, output unit as a result; Storage unit is being deposited the interest point data in the map sheet; Interest point data in the center calculation unit reading cells; Calculate peripheral extent point of interest and peripheral distance,, take out interest points meeting requirements at last with the peripheral binary sort tree screening interest points meeting requirements of fixed-node number n; Output to output unit as a result; After said peripheral binary tree sort tree was meant that binary tree is by inorder traversal, resulting node was pressed the peripheral binary tree of the ascending orderly arrangement of peripheral distance, and should preserve left subtree, right subtree, father's node and peripheral distance by the periphery binary tree.
Through said method and device, the point of interest point that can reduce the computing time of peripheral distance between the computing time of each point of interest, two points of interest and meet the result is searched the time, thereby has reduced retrieval time greatly.In addition, this method has realized the management voluntarily of internal memory, avoids too little because of the terminal internal memory, frequently distributes the slow-footed problem that causes.
Embodiment
From to the preferred embodiment that purport of the present invention and use thereof are described and the following description of accompanying drawing,
Above and other purpose, characteristics and advantage of the present invention will be conspicuous.
Term definition
Distance: be meant that two points with different longitudes and latitude couple together formed length of straigh line in plane right-angle coordinate.
Peripheral distance: be meant the distance between the point of interest at the current place of automobile in auto navigation and the arbitrary definite point of interest on every side.
Periphery binary tree: be meant that the node in the binary tree preserves left subtree, right subtree, the binary tree of father's node and peripheral distance.
The periphery binary sort tree: after being meant that binary tree is by inorder traversal, resulting node is pressed the peripheral binary tree of the ascending orderly arrangement of peripheral distance.
The peripheral binary sort tree of fixed-node number: the nodal point number that is meant peripheral binary sort tree is no more than fixed-node number (being assumed to n); When the nodal point number of peripheral binary sort tree surpasses n,, must delete rightmost node earlier as inserting new node; Delete node as new node with this, compose and give initial value, insert this new node of method insertion of new node then by binary sort tree.If the nodal point number of peripheral binary sort tree during less than n, inserts the method for new node and inserts this new node by binary sort tree.
The peripheral extent point of interest: be meant in plane right-angle coordinate, with the point of interest length in the horizontal and vertical directions at the current place of automobile in auto navigation all less than the point of interest of certain numerical value.
The detailed data of point of interest: be meant all data that point of interest is relevant.Like longitude, latitude, point of interest title, address, letter assembly, cities and towns name, telephone number etc.
Fig. 1 is the key step of the embodiment of the invention:
(1) reads the data of the point of interest in the map sheet, read out the longitude of point of interest and latitude.
(2) calculate peripheral extent point of interest and peripheral distance.
(3) the peripheral binary sort tree with the fixed-node number screens the point of interest that meets the requirements.
(4) also have data to handle, forward (1) to.All data all read out and handle and forward (5) to.
(5) all take out all interest points meeting requirements with inorder traversal.
The data structure of using among this embodiment is following:
The data structure of node in the peripheral binary sort tree of fixed-node number
In this embodiment, use a plurality of variablees, implication is following:
The maximum node number of the peripheral binary sort tree of #define n 50//fixed-node number, preferably n is 50-100, n gets 50 in this embodiment;
BinTreeStruct BTN [n+1] //BTN [n+1] is a n+1 node array.BTN [0] need not;
XB is array BTN [n+1] subscript value, is 1 to n;
MAX_AROUND is the peripheral distance maximal value, is 5000m;
RR is a rightmost point in the peripheral binary sort tree of fixed-node number, i.e. the maximum node of peripheral distance in the peripheral binary sort tree of fixed-node number;
DisTemp is the peripheral distance between the POI point at peripheral extent POI point and the current place of automobile;
SearchPos is a temporary variable.
Fig. 2 a is the concrete realization of screening interest points meeting requirements to Fig. 2 d.
(1) initialization of various data; Array BTN initialization, size is (n+1), subscript zero need not, only with 1 to the n subscript simulated as binary tree, establishing peripheral distance maximal value MAX_AROUND is 5 kilometers, makes subscript XB that initial value is 1, establishing n is 50.
(2) A1: the longitude of point of interest, latitude data run through, and take out interest points meeting requirements and withdraw from; Otherwise read the longitude and the latitude of point of interest.
(3) do you be respectively A*B with longitude and latitude scope and the A*C rectangular extent judges it is the peripheral extent point of interest? If the longitude and the longitude of current location point of interest and other points of interest subtract each other, latitude and latitude subtract each other respectively less than A*B, A*C; Then this point of interest is in rectangular extent; It is the peripheral extent point of interest; Otherwise this point of interest is not the peripheral extent point of interest not in said rectangular extent.Wherein A is 5 kilometers for maximum permission length, and B is a longitude factor, and C is a latitude.
(4) be not the peripheral extent point of interest, the read next point of interest forwards A1 to.Be the peripheral extent point of interest, forward (5) to.
(5) the peripheral distance disTemp between the point of interest at calculating peripheral extent point of interest and the current place of automobile.
(6) whether judge peripheral distance disTemp less than peripheral distance maximal value MAX_AROUND, such as, preset five kilometers.
(7) not, the read next point of interest forwards A1 to.Be to forward (8) to.
Whether the peripheral binary sort tree of (8) judging the fixed-node number is empty, judges promptly whether root node is zero.
(9) be to forward (10) to., do not forward (11) to.
(10) root node equals subscript XB, and the value of XB value BTN of array [XB] is zero for father's node; Left subtree is zero; Right subtree is zero, the value of preserving current peripheral distance; Preserve the address value of point of interest.Rightmost point is that the maximum node RR of peripheral distance is a root node.Subscript XB increases one.(annotate: RR does not belong to the codomain scope of BTN [XB]).The read next point of interest forwards A1 to.
(11) whether subscript XB is more than or equal to (n+1).
(12) not, forward A4 to.Be to forward (13) to.
(13) whether the value of current peripheral distance is greater than the value of the peripheral distance of BTN [RR].RR is a rightmost point in the peripheral binary sort tree of fixed-node number, i.e. the maximum node of peripheral distance in the peripheral binary sort tree of fixed-node number.
(14) be that the read next point of interest forwards A1 to., do not forward (15) to.
(15) compose root node to searchPos, searchPos is a temporary variable.
(16) whether A2:searchPos is leaf node.
(17) be that the read next point of interest forwards A1 to., do not forward (18) to.
(18) whether current peripheral distance disTemp equals the peripheral distance of BTN [searchPos].
(19) equal, forward (20) to.Be not equal to, forward (24) to.
(20) rightmost point is whether the maximum node RR of peripheral distance is root node.
(21) be to forward (22) to., do not forward (23) to.
(22) preserving the point of interest address is the point of interest address among the maximum node RR of peripheral distance to rightmost point; Forward next point of interest to; Turn to A1.
(23) the node relation of change RR node is left out it from binary tree.The value of RR value BTN of array [RR] is searchPos for father's node; Left subtree is the left subtree of searchPos; Right subtree is zero, the value of preserving current peripheral distance; Preserve the address value of point of interest.Be inserted into RR in the left subtree of searchPos; Seeking rightmost point is that the maximum node of peripheral distance is composed the node to RR.Forward next point of interest to; Turn to A1.
(24) whether current peripheral distance is less than the peripheral distance of BTN [searchPos].
(25) not, forward A3 to.Be to forward (26) to.
(26) whether the left subtree of BTN [searchPos] is zero.
(27) not to forward (28) to.Be to forward (29) to.
(28) left subtree of BTN [searchPos] is composed to searchPos and is turned to A2.
(29) the node relation of change RR node is left out it from binary tree.The value of RR value BTN of array [RR] is searchPos for father's node; Left subtree is zero; Right subtree is zero, the value of preserving current peripheral distance; Preserve the address value of point of interest.Be inserted into RR in the left subtree of searchPos; Seeking rightmost point is that the maximum node of peripheral distance is composed the node to RR.Forward next point of interest to; Turn to A1.
(30) whether the right subtree of A3:BTN [searchPos] is zero.
(31) non-vanishing, forward (32) to.Be zero, forward (33) to.
(32) right subtree of BTN [searchPos] is composed to searchPos and is turned to A2.
(33) the node relation of change RR node is left out it from binary tree.The value of RR value BTN of array [RR] is searchPos for father's node; Left subtree is zero; Right subtree is zero, the value of preserving current peripheral distance; Preserve the address value of point of interest.Be inserted into RR in the right subtree of searchPos; Seeking rightmost point is that the maximum node of peripheral distance is composed the node to RR.Forward next point of interest to; Turn to A1.
(34) A4: compose root node to searchPos, searchPos is a temporary variable.
(35) whether A5:searchPos is leaf node.
(36) be that the read next point of interest forwards A1 to., do not forward (37) to.
(37) whether current peripheral distance equals the peripheral distance of BTN [searchPos].
(38) equal, forward (39) to.Be not equal to, forward (40) to.
(39) value of XB value BTN of array [XB] is searchPos for father's node; Left subtree is the left subtree of searchPos; Right subtree is zero, the value of preserving current peripheral distance; Preserve the address value of point of interest.Be inserted into XB in the left subtree of searchPos; Seeking rightmost point is that the maximum node of peripheral distance is composed the node to RR.Subscript XB increases one.Forward next point of interest to; Turn to A1.
(40) whether current peripheral distance is less than the peripheral distance of BTN [searchPos].
(41) be to forward (42) to., do not forward (43) to.
(42) whether the left subtree of BTN [searchPos] is zero.
(43) not, forward (44) to.Be to forward (45) to.
(44) left subtree of BTN [searchPos] is composed to searchPos and is turned to A5.
(45) value of XB value BTN of array [XB] is searchPos for father's node; Left subtree is zero; Right subtree is zero, the value of preserving current peripheral distance; Preserve the address value of point of interest.Be inserted into XB in the left subtree of searchPos; Seeking rightmost point is that the maximum node of peripheral distance is composed the node to RR.Subscript XB increases one.Forward next point of interest to; Turn to A1.
(46) whether the right subtree of BTN [searchPos] is zero.
(47) not, forward (48) to.Be to forward (49) to.
(48) right subtree of BTN [searchPos] is composed to searchPos and is turned to A5.
(49) value of XB value BTN of array [XB] is searchPos for father's node; Left subtree is zero; Right subtree is zero, the value of preserving current peripheral distance; Preserve the address value of point of interest.Be inserted into XB in the right subtree of searchPos; Seeking rightmost point is that the maximum node of peripheral distance is composed the node to RR.Subscript XB increases one.Forward next point of interest to; Turn to A1.
Through these steps, periphery is searched searched on speed, to reach same class with key word index.And the speed that key word index is searched on mobile phone is fast.
Interest point search method of the present invention can be used on the portable terminals such as mobile phone, makes this portable terminal become a kind of interest point search device.Portable terminal comprises storage unit, center calculation unit, output unit as a result; Storage unit is being deposited the interest point data in the map sheet; Interest point data in the center calculation unit reading cells; Calculate peripheral extent point of interest and peripheral distance; With the peripheral binary sort tree screening interest points meeting requirements of fixed-node number n, take out interest points meeting requirements at last, output to output unit as a result.
Although illustrated and described the preferred embodiments of the present invention, it is contemplated that those skilled in the art can be in the spirit of accompanying claims and scope carries out various modifications to of the present invention.