CN103559213B - A kind of network of highways efficient spatial K-NN search method - Google Patents
A kind of network of highways efficient spatial K-NN search method Download PDFInfo
- Publication number
- CN103559213B CN103559213B CN201310473051.1A CN201310473051A CN103559213B CN 103559213 B CN103559213 B CN 103559213B CN 201310473051 A CN201310473051 A CN 201310473051A CN 103559213 B CN103559213 B CN 103559213B
- Authority
- CN
- China
- Prior art keywords
- data object
- grid cell
- sub
- section
- network
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/29—Geographical information databases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/95—Retrieval from the web
- G06F16/953—Querying, e.g. by the use of web search engines
- G06F16/9537—Spatial or temporal dependent retrieval, e.g. spatiotemporal queries
Abstract
The invention discloses a kind of network of highways efficient spatial K-NN search method, comprise the following steps: A: the corresponding relation of all data objects Yu its coordinate figure is stored in Hash table 1;B: calculate the space arest neighbors on each summit of road and link vertex, arest neighbors and minimum distance are stored in Hash table 2;C: use virtual grid two-dimensional space is divided into several grid cells and is numbered;D: calculate the corresponding relation also between save mesh unit and data object or link vertex, and be stored in Hash table 3;E: calculate query point place grid cell and determine the numbering of grid cell;F: search data object corresponding to this grid cell and calculate nearest data object and return to user.The present invention can reduce the time complexity of highway cyberspace K-NN search, is greatly enhanced search efficiency, reduces adjacent query time.
Description
Technical field
The present invention relates to a kind of space K-NN search method, particularly relate to a kind of network of highways efficient spatial K-NN search
Method.
Background technology
In recent years, universal along with smart mobile phone, people be increasingly using mobile phone carry out positioning, search, browse and
Sharing information;The geographical position of increasing facility such as restaurant, shop, cinema etc. can utilize the electronic chart in mobile phone
Obtain.This service based on geographical location information towards smart phone user is accepted extensively by people.And, with
The development of information technology, this kind of application and service based on geographical location information also gets more and more.
In these application and service, relatively conventional service based on geographical location information is search user current location
Neighbouring, to meet user-defined key word facility.In this type of application, user's current geographic position is the most efficiently processed
Space querying, namely the inquiry of spatial key word, be an important research topic.Due to a large number of users by mobile terminal same
One time initiated inquiry, and obtained answer in being expected to the shortest time, and therefore, concurrent queries is big, inquiry real-time is wanted
Seeking height is the significant challenge being served by facing being currently based on geographical location information.
How to improve the search efficiency of space arest neighbors, be that spatial key word is inquired about and a lot of based on geographical location information
Basic and the highly important key issue faced in being served by.In daily life, vehicle, pedestrian be typically only capable to along
Move on limited spatial network, namely move on network of highways and existing road that movably scope is only limitted in network of highways
Road.During the object that the space of lookup user current location is nearest in network of highways, existing algorithm is generally all by means of shortest
The index structure of path trees type.And use the time complexity of this kind of indexed search query point neighborhood in network of highways
Being O (log N), wherein N is the sum in sub-section, and this will take for substantial amounts of query time;Further, find query point at network of highways
On neighborhood after, existing method must look at this neighborhood in candidate data object on all sub-sections, and need scanning
Index on network of highways also calculates from query point to the shortest path of each candidate target and length thereof, and this further adds
The expense calculated.
Summary of the invention
It is an object of the invention to provide a kind of network of highways efficient spatial K-NN search method, it is adaptable to data volume is big, real
The particular/special requirement that Shi Bingfa queries is big and response requirement of real-time is high, it is possible to by the time of highway cyberspace K-NN search
Complexity is reduced to O (1) from O (log N), and the efficiency of space K-NN search is greatly improved.
The present invention uses following technical proposals:
A kind of network of highways efficient spatial K-NN search method, it is characterised in that comprise the following steps:
A: provided the input data including data object information on network of highways information and network of highways by user, according to input number
According to creating Hash table hashmap_1, and the corresponding relation of all data objects Yu its coordinate figure is stored in Hash table
In hashmap_1;
B: calculate the space arest neighbors on every each summit of road respectively, creates Hash table hashmap_2, and by road top
Arest neighbors on spatial network of point, this summit and minimum distance are stored in Hash table hashmap_2;
C: use virtual grid that two-dimensional space is divided into the square net unit that several grades are big, determine grid cell
The length of side, and virtual grid is numbered;
D: calculate sub-section save mesh unit and the data object controlling this sub-section that each grid cell comprises
Or the corresponding relation between link vertex, and store the result in Hash table hashmap_3;
E: calculate the grid cell at place, query point position, and determine the volume of grid cell corresponding to query point position
Number;
F: according to the grid cell numbering calculated in step E, search the data object that this grid cell is corresponding, and calculate
Wherein return to user from the data object that query point is nearest.
The unique identifier oid that major key is data object of described Hash table hashmap_1, is worth the seat for this data object
Scale value.
The unique identifier vid that major key is link vertex of described Hash table hashmap_2, is worth for this summit in space networks
Minimum distance s between oid and vid and this oid of the arest neighbors on network.
Described step C comprises the following steps:
C1: use virtual grid that two-dimensional space is divided into the square net unit that several grades are big, pass through formula(1) determining the length of side of grid cell, wherein, l is the grid cell length of side, if d1For the most short-track in all roads
The length on road, if d2For having on the road of data object, the minima of the distance between all two adjacent data objects, d
For d1And d2In minima, ξ=10-9;
C2: make the minimum boundary rectangle that R is constituted by all data objects in data set, with the summit in the lower left corner of R
(x0,y0) it is starting point, set up virtual grid, and from coordinate (x0,y0) grid cell at place starts, from left to right, from lower and
On incrementally grid cell is numbered;Coordinates computed point (x, y) formula of the grid cell numbering at place is:
Wherein, id is coordinate points (x, y) the grid cell numbering at place, the grid list that every a line that m is grid is comprised
The quantity of unit, ceil is flow in upper plenum.
Described step D comprises the following steps:
D1: for any one road, is divided into some sub-sections;
D2: for any one strip section, calculate the grid cell intersected with this sub-section;
D3: calculate all sub-section that each grid cell is comprised and the set of data objects controlling this little section,
And the corresponding relation of grid cell numbering with set of data objects and the slope in the sub-section at data object place is stored in Kazakhstan
In uncommon table hashmap_3, the key of hashmap_3 is the numbering of grid cell, to should the value of key be a set, in this set
The slope that each element is the sub-section controlling the oid of each data object of this grid cell and this data object place;
If the point controlling this grid cell is link vertex, then using the slope in the sub-section of vid and place on this summit as a unit
Element is stored in the set that this grid cell is corresponding in hashmap_3.
In described step D1, for any one road, from the beginning of it summit, first by this insertion point, summit
In set ps;Take out the data object on this road the most successively and be inserted in a set ps;Before in a set ps
The line segment of two the most adjacent data object compositions, is bisected in two sub-line segments difference intron line segment aggregate rs;
Finally another summit of road is also inserted in a set ps.
In described step D2, for any one sub-section, if its two-end-point is respectively v1And v2, calculate limit v1→v2
With longitudinal network ruling and the intersection point of transverse grid line;According to v1To v2Direction, according on the magnitude relationship ordered arrangement of abscissa value
State intersection point and v1And v2The set of the point that two summits are formed;To the institute's set of computations the most successively in the set after sequence
In the midpoint of all adjacent 2, use the formula (2) in step C2 to calculate the grid cell at this place, midpoint at each midpoint
Numbering, the set that the grid cell at place, midpoint is formed is and limit v1→v2The grid cell intersected.
In described step E, utilize the formula (2) in step C2, calculate the grid cell at place, query point position, and really
Determine the numbering of grid cell corresponding to query point position.
Described step F comprises the following steps:
F1: according to the grid cell numbering calculated in step E, search this grid cell in Hash table hashmap_3
The slope in every corresponding sub-section and control the oid or the vid of link vertex of data object in this sub-section;
F2: calculate the slope of the straight line that query point is formed by connecting with first object on each strip section respectively;If
The slope calculated is equal with the slope in a certain sub-section corresponding to grid cell, then query point is positioned at the sub-road of this correspondence
Duan Shang;If the slope calculated is the most equal with the slope in some sub-sections corresponding to grid cell, calculate inquiry the most respectively
Coordinate position relation between point and the two-end-point of each sub-line section, to determine sub-section, query point place;
F3: judge whether there is data object on the road of query point place, if it is, enter step F4;If it is not, then
Enter step F5;
F4: if two end points in sub-section, query point place are respectively two data objects, calculate the two number the most respectively
According to the distance between object and query point, and return to use as Query Result using the data object closest with query point
Family, if the distance between the two data object and query point is identical, the most simultaneously using the two data object as Query Result
Return to user;
If two end points in sub-section, query point place are respectively a data object and a link vertex, first count
Calculate query point distance r to this data object1Distance r with query point to this link vertex2, then from Hash table hashmap_2
This link vertex of middle inquiry arest neighbors on spatial network and minimum distance s2, finally compare r1With r2+s2Size, if r1Relatively
Little, then data object corresponding for sub-for query point place section end points is returned to user as Query Result;If r2+s2Less, then
The data object corresponding to this link vertex arest neighbors on spatial network will be inquired about as looking into from Hash table hashmap_2
Ask result and return to user;If r1With r2+s2Size identical, the most simultaneously by data corresponding for sub-for query point place section end points
Object, inquire about from Hash table hashmap_2 data object corresponding to this link vertex arest neighbors on spatial network with
Shi Zuowei Query Result returns to user;
F5: if two end points of query point place road are respectively two link vertex, first score and do not calculate inquiry
O'clock to distance r of first link vertex3With distance r4 of query point to second link vertex, the most respectively from Hash table
Hashmap_2 inquires about first link vertex arest neighbors on spatial network and minimum distance s3, second link vertex
Arest neighbors on spatial network and minimum distance s4, calculate r3+s3With r4+s4Size, if r3+s3Less, then will be from Hash
First link vertex inquired in the table hashmap_2 data object corresponding to arest neighbors on spatial network is as looking into
Ask result and return to user;If r4+s4Less, then by second link vertex inquiring from Hash table hashmap_2 at sky
Between the data object corresponding to arest neighbors on network return to user as Query Result;If r3+s3With r4+s4Size phase
With, the most simultaneously by right for arest neighbors institute on spatial network of first link vertex inquiring from Hash table hashmap_2
The data object answered, second link vertex inquired from Hash table hashmap_2 arest neighbors institute on spatial network
Corresponding data object returns to user simultaneously as Query Result.
The present invention applies as starting point with the space querying of service based on geographical location information, is divided by spatial query processing
Set up and real-time spatial query processing two megastage for off-line index.Off-line index establishment stage serves Directory Enquiries, real-time space
The reason stage, the response speed of the space K-NN search processing stage of for improving real-time space.Off-line index establishment stage is born
Duty index is set up, and creates three Hash tables at off-line index establishment stage: hashmap_1, hashmap_2 in the present invention,
hashmap_3.Wherein, hashmap_1 for storing the indications of data object, i.e. the oid of data object and data object
Corresponding relation between coordinate;Hashmap_2 is for storing the indications of link vertex, the i.e. vid of link vertex and this summit
The data object that the oid of data object nearest on spatial network and the vid of link vertex is nearest with on spatial network
The value of the beeline between oid;Hashmap_3 is for save mesh unit and the data controlling this grid cell neutron section
Corresponding relation between object, this sub-section slope.In the real-time spatial query processing stage, each space arest neighbors is looked into
Ask, first calculate the query point corresponding grid cell in two-dimensional space, three then set up by off-line index establishment stage
Individual Hash table finds the data object in the sub-section comprised in this grid cell of control, determines on the road at query point place and looks into
Asking the space arest neighbors on the road of some place, the space arest neighbors as query point returns to user.The present invention can make
The time complexity of highway cyberspace K-NN search is reduced to O (1) from O (log N), drastically increases network of highways real-time
Space K-NN search efficiency, reduces the K-NN search time, and, Real-time and Concurrent queries big for data volume greatly and responds in real time
Property require being extremely important based on location-based service application system on high network of highways.
Accompanying drawing explanation
Fig. 1 is the schematic flow sheet of the present invention;
Fig. 2 is the square net unit that two-dimensional space is divided into that several grades are big by use virtual grid of the present invention
Schematic diagram;
Fig. 3 is time to be sub-section, query point place slope equal with the slope in a certain sub-section corresponding to grid cell
Schematic diagram;
Fig. 4 is time to be sub-section, query point place slope equal with the slope in some sub-sections corresponding to grid cell
Schematic diagram;
Fig. 5 is two end points of the sub-line section at query point place schematic diagrams when being respectively data object and link vertex;
Fig. 6 and Fig. 7 is schematic diagram when two end points of the sub-line section at query point place are link vertex.
Detailed description of the invention
As it is shown in figure 1, network of highways efficient spatial K-NN search method of the present invention comprises the following steps, wherein A,
B, C, D step indexes establishment stage for off-line;E, F step is for the real-time spatial query processing stage:
A: provided the input data including data object information on network of highways information and network of highways by user, according to input number
According to creating Hash table hashmap_1, and the corresponding relation of all data objects Yu its coordinate figure is stored in Hash table
In hashmap_1;The major key of Hash table hashmap_1 is the unique identifier oid of data object, is worth the seat for this data object
Scale value.
B: calculate the space arest neighbors on every each summit of road respectively, creates Hash table hashmap_2, and by road top
Arest neighbors on spatial network of point, this summit and minimum distance are stored in Hash table hashmap_2;Hash table hashmap_
The major key of 2 is the unique identifier vid of link vertex, be worth for this summit arest neighbors on spatial network oid and vid with should
Minimum distance s between oid.
C: use virtual grid that two-dimensional space is divided into the square net unit that several grades are big, determine grid cell
The length of side, and virtual grid is numbered;When performing step C, perform according to step in detail below:
C1: use virtual grid that two-dimensional space is divided into the square net unit that several grades are big, pass through formula(1) determining the length of side of grid cell, wherein, l is the grid cell length of side, if d1For the most short-track in all roads
The length on road, if d2For having on the road of data object, the minima of the distance between all two adjacent data objects, d
For d1And d2In minima, ξ=10-9;
C2: make the minimum boundary rectangle that R is constituted by all data objects in data set, with the summit in the lower left corner of R
(x0,y0) it is starting point, set up virtual grid, and from coordinate (x0,y0) grid cell at place starts, from left to right, from lower and
On incrementally grid cell is numbered;Coordinates computed point (x, y) formula of the grid cell numbering at place is:
Wherein, id is coordinate points (x, y) the grid cell numbering at place, the grid list that every a line that m is grid is comprised
The quantity of unit, ceil is flow in upper plenum.
D: calculate sub-section save mesh unit and the data object controlling this sub-section that each grid cell comprises
Or the corresponding relation between link vertex, and store the result in Hash table hashmap_3;Perform D step time, according to
Lower concrete steps perform:
D1: for any one road, is divided into some sub-sections;For any one road, from its one
Summit starts, first by this insertion point, summit set ps;Take out the data object on this road the most successively and be inserted into
In some set ps;For the line segment of two data objects compositions the most adjacent in a set ps, it is bisected into two sub-line
In section respectively intron line segment aggregate rs;Finally another summit of road is also inserted in a set ps.
D2: for any one strip section, makes to calculate the grid cell intersected with this sub-section with the following method: make this son
The two-end-point in section is respectively v1And v2, calculate limit v1→v2With longitudinal network ruling and the intersection point of transverse grid line;According to v1To v2
Direction, according to the above-mentioned intersection point of magnitude relationship ordered arrangement and the v of abscissa value1And v2The set of the point that two summits are formed;Right
In set after sequence the midpoint of all adjacent 2 in set of computations the most successively, each midpoint is used step C2
In formula (2) calculate the numbering of grid cell at this place, midpoint, the set that the grid cell at place, midpoint is formed is
With limit v1→v2The grid cell intersected.
D3: calculate all sub-section that each grid cell is comprised and the set of data objects controlling this little section,
And the corresponding relation of grid cell numbering with set of data objects and the slope in the sub-section at data object place is stored in Kazakhstan
In uncommon table hashmap_3, the key of hashmap_3 is the numbering of grid cell, to should the value of key be a set, in this set
The slope that each element is the sub-section controlling the oid of each data object of this grid cell and this data object place.
If the point controlling this grid cell is link vertex, then using the slope in the sub-section of vid and place on this summit as a unit
Element is stored in the set that this grid cell is corresponding in hashmap_3.
E: utilize the formula (2) in step C2, calculates the grid cell at place, query point position, and determines query point position
The numbering of corresponding grid cell;
F: according to the grid cell numbering calculated in step E, search the data object that this grid cell is corresponding, and calculate
Wherein return to user from the data object that query point is nearest.When performing F step, perform according to step in detail below:
F1: according to the grid cell numbering calculated in step E, search this grid cell in Hash table hashmap_3
The slope in every corresponding sub-section and control the oid or the vid of link vertex of data object in this sub-section;
F2: calculate the slope of the straight line that query point is formed by connecting with first object on each strip section respectively;If
The slope calculated is equal with the slope in a certain sub-section corresponding to grid cell, then query point is positioned at the sub-road of this correspondence
Duan Shang;If the slope calculated is the most equal with the slope in some sub-sections corresponding to grid cell, calculate inquiry the most respectively
Coordinate position relation between point and the two-end-point of each sub-line section, to determine sub-section, query point place;
F3: judge whether there is data object on the road of query point place, if it is, enter step F4;If it is not, then
Enter step F5;
F4: if two end points in sub-section, query point place are respectively two data objects, calculate the two number the most respectively
According to the distance between object and query point, and return to use as Query Result using the data object closest with query point
Family, if the distance between the two data object and query point is identical, the most simultaneously using the two data object as Query Result
Return to user;
If two end points in sub-section, query point place are respectively a data object and a link vertex, first count
Calculate query point distance r to this data object1Distance r with query point to this link vertex2, then from Hash table hashmap_2
This link vertex of middle inquiry arest neighbors on spatial network and minimum distance s2, finally compare r1With r2+s2Size, if r1Relatively
Little, then data object corresponding for sub-for query point place section end points is returned to user as Query Result;If r2+s2Less, then
The data object corresponding to this link vertex arest neighbors on spatial network will be inquired about as looking into from Hash table hashmap_2
Ask result and return to user;If r1With r2+s2Size identical, the most simultaneously by data corresponding for sub-for query point place section end points
Object, inquire about from Hash table hashmap_2 data object corresponding to this link vertex arest neighbors on spatial network with
Shi Zuowei Query Result returns to user;
F5: if two end points of query point place road are respectively two link vertex, first score and do not calculate inquiry
O'clock to distance r of first link vertex3Distance r with query point to second link vertex4, the most respectively from Hash table
Hashmap_2 inquires about first link vertex arest neighbors on spatial network and minimum distance s3, second link vertex
Arest neighbors on spatial network and minimum distance s4, calculate r3+s3With r4+s4Size, if r3+s3Less, then will be from Hash
First link vertex inquired in the table hashmap_2 data object corresponding to arest neighbors on spatial network is as looking into
Ask result and return to user;If r4+s4Less, then by second link vertex inquiring from Hash table hashmap_2 at sky
Between the data object corresponding to arest neighbors on network return to user as Query Result;If r3+s3With r4+s4Size phase
With, the most simultaneously by right for arest neighbors institute on spatial network of first link vertex inquiring from Hash table hashmap_2
The data object answered, second link vertex inquired from Hash table hashmap_2 arest neighbors institute on spatial network
Corresponding data object returns to user simultaneously as Query Result.
Below in conjunction with specific embodiment, network of highways efficient spatial K-NN search method of the present invention is explained
Illustrate:
A: provided the input data including data object information on network of highways information and network of highways by user, according to input number
According to creating Hash table hashmap_1, and the corresponding relation of all data objects Yu its coordinate figure is stored in Hash table
In hashmap_1;The major key of Hash table hashmap_1 is the unique identifier oid of data object, is worth the seat for this data object
Scale value.So, the oid of data-oriented object, by searching the respective value in Hash table hashmap_1, these data just can be obtained
The coordinate position of object.
B: calculate the space arest neighbors on every each summit of road respectively, creates Hash table hashmap_2, and by road top
Arest neighbors on spatial network of point, this summit and minimum distance are stored in Hash table hashmap_2;Hash table hashmap_
The major key of 2 is the unique identifier vid of link vertex, be worth for this summit arest neighbors on spatial network oid and vid with should
Minimum distance s between oid.
As in figure 2 it is shown, a, b, c, d, e, f, g are the summit of network of highways, o1To o7For the data object on network of highways, grid
0,1,2 ... for hereinafter described virtual grid element number, Q1, Q2For query point, P1,
P2, P3It is the midpoint on road between adjacent two data object, wherein, P1It is data object o on road ab1With
Data object o2Midpoint;P2It is data object o2With data object o3Midpoint, P3It is data object o on road bc4And data
Object o5Midpoint.
Owing to every road all has two summits, and some roads can share a summit, therefore, in fig. 2, has 11
Bar road, and the number on summit is 7.For each summit, dijkstra algorithm is used to calculate this summit on spatial network
Nearest data object.In Fig. 2, data object nearest on spatial network for summit b is o7.Create Hash table hashmap_
2, major key is the unique identifier vid of link vertex, be worth for this summit nearest data object on spatial network oid and
Minimum distance s between vid and oid.Value corresponding in Hash table hashmap_2 for vid is two tuples, and this two tuple is
Beeline between oid and oid and vid of the data object that vid is nearest.
C: use virtual grid that two-dimensional space is divided into the square net unit that several grades are big, determine grid cell
The length of side, and virtual grid is numbered;When performing step C, perform according to step in detail below:
C1: use virtual grid that two-dimensional space is divided into the square net unit that several grades are big, pass through formula(1) determining the length of side of grid cell, wherein, l is the grid cell length of side, if d1For the most short-track in all roads
The length on road, if d2For having on the road of data object, the minima of the distance between all two adjacent data objects, d
For d1And d2In minima, ξ=10-9;
C2: make the minimum boundary rectangle that R is constituted by all data objects in data set, with the summit in the lower left corner of R
(x0,y0) it is starting point, set up virtual grid, and from coordinate (x0,y0) grid cell at place starts, from left to right, from lower and
On incrementally grid cell is numbered;Coordinates computed point (x, y) formula of the grid cell numbering at place is:
Wherein, id is coordinate points (x, y) the grid cell numbering at place, the grid list that every a line that m is grid is comprised
The quantity of unit, ceil is flow in upper plenum.
In Fig. 2, virtual grid is used to divide the two-dimensional space at network of highways place.This virtual grid one has 12 row, often
Row comprises 16 grid cells, namely m=16.Wherein, 0,1,2,3 numbering of front 4 grid cells being respectively the 1st row.And
16,17,18 is the numbering of first three grid cell of the 2nd row.119 and 120 is the volume of the 8th, the 9th grid cell of the 12nd row
Number.
D: calculate sub-section save mesh unit and the data object controlling this sub-section that each grid cell comprises
Or the corresponding relation between link vertex, and store the result in Hash table hashmap_3;Perform D step time, according to
Lower concrete steps perform:
D1: for any one road, is divided into some sub-sections;For any one road, from its one
Summit starts, first by this insertion point, summit set ps;Take out the data object on this road the most successively and be inserted into
In some set ps;For the line segment of two data objects compositions the most adjacent in a set ps, it is bisected into two sub-line
In section respectively intron line segment aggregate rs;Finally another summit of road is also inserted in a set ps.
In Fig. 2, a, b, c, d, e, f, g are the summit of network of highways, o1, o2..., o7For the data object on network of highways.
For the line segment of two data objects compositions the most adjacent in a set ps, it is bisected into two sub-line segments and is inserted respectively
In sub-line segment aggregate rs, such as P1, P2For midpoint between adjacent two data object on road ab.Wherein, P1It is data object o1
With data object o2Midpoint;P2It is data object o2With data object o3Midpoint.And two, group section end points one of them
During for link vertex, do not divide this sub-section, on road ab in Fig. 2, a → o1, o3Two sub-sections of → b are not divided into
Two sub-sections.
D2: for any one strip section, makes to calculate the grid cell intersected with this sub-section with the following method: make this son
The two-end-point in section is respectively v1And v2, calculate limit v1→v2With longitudinal network ruling and the intersection point of transverse grid line;According to v1To v2
Direction, according to the above-mentioned intersection point of magnitude relationship ordered arrangement and the v of abscissa value1And v2The set of the point that two summits are formed;Right
In set after sequence the midpoint of all adjacent 2 in set of computations the most successively, each midpoint is used step C2
In formula (2) calculate the numbering of grid cell at this place, midpoint, the set that the grid cell at place, midpoint is formed is
With limit v1→v2The grid cell intersected.
D3: calculate all sub-section that each grid cell is comprised and the set of data objects controlling this little section,
And the corresponding relation of grid cell numbering with set of data objects and the slope in the sub-section at data object place is stored in Kazakhstan
In uncommon table hashmap_3, the key of hashmap_3 is the numbering of grid cell, to should the value of key be a set, in this set
The slope that each element is the sub-section controlling the oid of each data object of this grid cell and this data object place;
If the point controlling this grid cell is link vertex, then using the slope in the sub-section of vid and place on this summit as a unit
Element is stored in the set that this grid cell is corresponding in hashmap_3.
E: utilize the formula (2) in step C2, calculates the grid cell at place, query point position, and determines corresponding to query point position
The numbering of grid cell;As in fig. 2, utilize formula
Calculate query point Q1The grid cell numbered 135 at place.
F: according to the grid cell numbering calculated in step E, search the data object that this grid cell is corresponding, and calculate
Wherein return to user from the data object that query point is nearest.When performing F step, perform according to step in detail below:
F1: according to the grid cell numbering calculated in step E, search this grid cell in Hash table hashmap_3
The slope slope in every corresponding sub-section and control the oid or the vid of link vertex of data object in this sub-section;
F2: calculate the oblique of the straight line that is formed by connecting with first data object on each strip section of query point respectively
Rate;If the slope calculated is equal with the slope in a certain sub-section corresponding to grid cell, then query point is positioned at this correspondence
Sub-section on;If the slope calculated is the most equal with the slope in some sub-sections corresponding to grid cell, count the most respectively
Calculate the coordinate position relation between query point and the two-end-point of each sub-line section, to determine sub-section, query point place;
The most in figure 3, Q is query point, O1And O2For controlling the data object of the grid at query point place, a is Liang Tiao road
The common vertex on road.Calculate straight line Q → O respectively1With Q → O2Slope, it is known that Q → O1Slope with only with road a → O1Oblique
Rate is identical, and therefore, query point Q is at road a → O1On.
In the diagram, Q is query point, O1And O2For controlling the data object of the grid at query point place, a is two road
Common vertex.Calculate straight line Q → O respectively1With Q → O2Slope, it is known that Q → O1With Q → O2Slope identical, and with road a →
O1With a → O2Slope the most identical, in the case, by calculating the seat between query point and the two-end-point of each sub-line section
Cursor position relation, i.e. can determine that query point Q is at road a → O2On, and it is not positioned at road a → O1On.
F3: judge whether there is data object on the road of query point place, if it is, enter step F4;If it is not, then
Enter step F5;
F4: if two end points in sub-section, query point place are respectively two data objects, calculate the two number the most respectively
According to the distance between object and query point, and return to use as Query Result using the data object closest with query point
Family, if the distance between the two data object and query point is identical, the most simultaneously using the two data object as Query Result
Return to user;
Such as query point Q in Fig. 22Position, Q2It is positioned at sub-route O4→O5Between, and O4With O5It is respectively two data pair
As rather than summit, crossing.So have only to from O4With O5In find out from query point Q2Nearest data object is as Query Result
Return to user.In fig. 2, data object O4For O4With O5In from query point Q2Nearest data object, so at Fig. 2
In the case of Suo Shi, O4It is the space arest neighbors inquired.
If two end points in sub-section, query point place are respectively a data object and a link vertex, first count
Calculate query point to distance r1 of this data object and query point to distance r of this link vertex2, then from Hash table hashmap_
This link vertex arest neighbors on spatial network and minimum distance s is inquired about in 22, finally compare r1With r2+s2Size, if r1
Less, then data object corresponding for sub-for query point place section end points is returned to user as Query Result;If r2+s2It is less,
Then using inquire about from Hash table hashmap_2 data object corresponding to this link vertex arest neighbors on spatial network as
Query Result returns to user;If r1With r2+s2Size identical, the most simultaneously by number corresponding for sub-for query point place section end points
According to object, from Hash table hashmap_2, inquire about the data object corresponding to this link vertex arest neighbors on spatial network
User is returned to simultaneously as Query Result;
Query point Q as shown in Figure 21Position, query point Q1The grid cell numbered 135 at place, query point Q1Place
Sub-line section is o3→ b, two corresponding end points are respectively data object o3With link vertex b.For this situation, first calculate and look into
Ask some Q1To data object o3Distance r1Distance r with query point to link vertex b2, then from Hash table hashmap_2
Inquire link vertex b arest neighbors o on spatial network7And link vertex b is to its arest neighbors o7Minimum distance s2, finally
Relatively r1With r2+s2Size, if r1Less, then by query point Q1The data object o that sub-section, place end points is corresponding3As inquiry
Result returns to user;If r2+s2Less, then will inquire about this link vertex b from Hash table hashmap_2 on spatial network
The data object o corresponding to arest neighbors7User is returned to as Query Result.From figure 2 it can be seen that r1< r2+s2, because of
This, by query point Q1The data object o that sub-section, place end points is corresponding3User is returned to as the arest neighbors inquired.
Query point Q the most as shown in Figure 51Position, query point Q1The sub-line section at place is o2→ d, two corresponding end points divide
Wei data object o2With link vertex d.For this situation, first calculate query point Q1To data object o2Distance r1With look into
Ask some distance r to link vertex d2, then from Hash table hashmap_2, inquire link vertex d on spatial network
Arest neighbors o1And link vertex d is to its arest neighbors o1Minimum distance s2, finally compare r1With r2+s2Size, if r1Less, then
By query point Q1The data object o that sub-section, place end points is corresponding2User is returned to as Query Result;If r2+s2Less, then
The data object o corresponding to this link vertex d arest neighbors on spatial network will be inquired about from Hash table hashmap_21Make
User is returned to for Query Result.From figure 5 it can be seen that r1> r2+s2, therefore, will inquire about from Hash table hashmap_2
Data object o corresponding to this link vertex d arest neighbors on spatial network1User is returned to as Query Result.
F5: if two end points of query point place road are respectively two link vertex, first score and do not calculate inquiry
O'clock to distance r of first link vertex3Distance r with query point to second link vertex4, the most respectively from Hash table
Hashmap_2 inquires about first link vertex arest neighbors on spatial network and minimum distance s3, second link vertex
Arest neighbors on spatial network and minimum distance s4, calculate r3+s3With r4+s4Size, if r3+s3Less, then will be from Hash
First link vertex inquired in the table hashmap_2 data object corresponding to arest neighbors on spatial network is as looking into
Ask result and return to user;If r4+s4Less, then by second link vertex inquiring from Hash table hashmap_2 at sky
Between the data object corresponding to arest neighbors on network return to user as Query Result;If r3+s3With r4+s4Size phase
With, the most simultaneously by right for arest neighbors institute on spatial network of first link vertex inquiring from Hash table hashmap_2
The data object answered, second link vertex inquired from Hash table hashmap_2 arest neighbors institute on spatial network
Corresponding data object returns to user simultaneously as Query Result.
Query point Q as shown in Figure 61Position, query point Q1The sub-line section at place is d → e, and two corresponding end points are respectively
For link vertex d and link vertex e.For this situation, first calculate query point Q1Distance r to link vertex d3And query point
Distance r to link vertex e4, from Hash table hashmap_2, then inquire nearest on spatial network of link vertex d
Adjacent o1And link vertex d is to its arest neighbors o1Minimum distance s3, link vertex e arest neighbors o on spatial network2And road
Summit e to its arest neighbors o2Minimum distance s4, finally compare r3+s3With r4+s4Size, if r3+s3Less, then will be from Hash
First link vertex d inquired in the table hashmap_2 data object o corresponding to arest neighbors on spatial network1Make
User is returned to for Query Result;If r4+s4Less, then will inquire about this link vertex e from Hash table hashmap_2 in space
Data object o corresponding to arest neighbors on network2User is returned to as Query Result.From fig. 6 it can be seen that r3+s3>
r4+s4, therefore, the number corresponding to this link vertex e arest neighbors on spatial network will be inquired about from Hash table hashmap_2
According to object o2User is returned to as Query Result.
Query point Q the most as shown in Figure 71Position, query point Q1The sub-line section at place is d → e, and two corresponding end points divide
Wei link vertex d and link vertex e.For this situation, first calculate query point Q1Distance r to link vertex d3And inquiry
Point is to distance r of link vertex e4, from Hash table hashmap_2, then inquire link vertex d on spatial network
Neighbour o1And link vertex d is to its arest neighbors o1Minimum distance s3, link vertex e arest neighbors o on spatial network2And road
Summit, road e to its arest neighbors o2Minimum distance s4, finally compare r3+s3With r4+s4Size, if r3+s3Less, then will be from Kazakhstan
First link vertex d inquired in the uncommon table hashmap_2 data object o corresponding to arest neighbors on spatial network1
User is returned to as Query Result;If r4+s4Less, then will inquire about this link vertex e from Hash table hashmap_2 at sky
Between the data object o corresponding to arest neighbors on network2User is returned to as Query Result.From fig. 6 it can be seen that r3+s3
> r4+s4, therefore, will inquire about from Hash table hashmap_2 corresponding to this link vertex e arest neighbors on spatial network
Data object o2User is returned to as Query Result.
The present invention applies as starting point with the space querying of service based on geographical location information, is divided by spatial query processing
Set up and real-time spatial query processing two megastage for off-line index.
Off-line index establishment stage serves the real-time spatial query processing stage, the processing stage of for improving real-time space
The response speed of space K-NN search.Off-line index establishment stage is responsible for index and is set up, and sets up at off-line index in the present invention
Stage creates three Hash tables: hashmap_1, hashmap_2, hashmap_3.Wherein, hashmap_1 is used for storing data
Corresponding relation between oid and the coordinate of data object of the indications of object, i.e. data object;Hashmap_2 is used for storing
The oid of the data object that the vid of the indications of link vertex, i.e. link vertex is nearest on spatial network with this summit and road
The value of the beeline between the oid of data object nearest on the vid on summit, road and spatial network;Hashmap_3 is used for depositing
Corresponding relation between storage grid cell and the data object controlling this grid cell neutron section, this sub-section slope.
In the real-time spatial query processing stage, each space arest neighbors is inquired about, first calculate query point in two dimension
Corresponding grid cell in space, three Hash tables then set up by off-line index establishment stage find this grid list of control
The data object in the sub-section comprised in unit, determine on the road at query point place and space on the network of highways of query point place
Neighbour, the space arest neighbors as query point returns to user.
Claims (9)
1. a network of highways efficient spatial K-NN search method, it is characterised in that comprise the following steps:
A: provided the input data including data object information on network of highways information and network of highways by user, according to input data wound
Build Hash table hashmap_1, and the corresponding relation of all data objects Yu its coordinate figure is stored in Hash table hashmap_1
In;
B: calculate the space arest neighbors on every each summit of road respectively, creates Hash table hashmap_2, and by link vertex,
This summit arest neighbors on spatial network and minimum distance are stored in Hash table hashmap_2;
C: use virtual grid that two-dimensional space is divided into the square net unit that several grades are big, determine the limit of grid cell
Long, and virtual grid is numbered;
D: calculate all sub-section that each grid cell is comprised and the set of data objects controlling this little section, and by net
Lattice element number is stored in Hash table with the corresponding relation of set of data objects and the slope in the sub-section at data object place
In hashmap_3;
E: calculate the grid cell at place, query point position, and determine the numbering of grid cell corresponding to query point position;
F: according to the grid cell numbering calculated in step E, search the data object that this grid cell is corresponding, and calculate wherein
The data object nearest from query point returns to user.
Network of highways efficient spatial K-NN search method the most according to claim 1, it is characterised in that: described Hash table
The major key of hashmap_1 is the unique identifier oid of data object, is worth the coordinate figure for this data object.
Network of highways efficient spatial K-NN search method the most according to claim 2, it is characterised in that: described Hash table
The major key of hashmap_2 is the unique identifier vid of link vertex, is worth the oid for this summit arest neighbors on spatial network
And the minimum distance s between vid and this oid.
Network of highways efficient spatial K-NN search method the most according to claim 3, it is characterised in that described step C
Comprise the following steps:
C1: use virtual grid that two-dimensional space is divided into the square net unit that several grades are big, pass through formulaDetermining the length of side of grid cell, wherein, ι is the grid cell length of side, if d1For the shortest in all roads
The length of road, if d2For having on the road of data object, the minima of the distance between all two adjacent data objects,
D is d1And d2In minima, ξ=10-9;
C2: make the minimum boundary rectangle that R is constituted by all data objects in data set, with the summit (x in the lower left corner of R0,
y0) it is starting point, set up virtual grid, and from coordinate (x0,y0) grid cell at place starts, from left to right, pass from bottom to top
Increase ground grid cell is numbered;Coordinates computed point (x, y) formula of the grid cell numbering at place is:
Wherein, id is that coordinate points (x, y) number, the grid cell that every a line that m is grid is comprised by the grid cell at place
Quantity, ceil is flow in upper plenum.
Network of highways efficient spatial K-NN search method the most according to claim 4, it is characterised in that described step D
Comprise the following steps:
D1: for any one road, is divided into some sub-sections;
D2: for any one strip section, calculate the grid cell intersected with this sub-section;
D3: calculate all sub-section that each grid cell is comprised and the set of data objects controlling this little section, and will
Grid cell numbering is stored in Hash table with the corresponding relation of set of data objects and the slope in the sub-section at data object place
In hashmap_3, the key of hashmap_3 is the numbering of grid cell, to should the value of key be a set, and every in this set
Individual element is the slope in the sub-section controlling the oid of each data object of this grid cell and this data object place;If
The point controlling this grid cell is link vertex, then deposited as an element by the slope in the sub-section of vid and place on this summit
Store up in the set that this grid cell is corresponding in hashmap_3.
Network of highways efficient spatial K-NN search method the most according to claim 5, it is characterised in that: described step D1
In, for any one road, from the beginning of it summit, first by this insertion point, summit set ps;Take the most successively
Go out the data object on this road and be inserted in a set ps;For two data objects the most adjacent in a set ps
The line segment of composition, is bisected in two sub-line segments difference intron line segment aggregate rs;Finally by another top of road
Point is also inserted in a set ps.
Network of highways efficient spatial K-NN search method the most according to claim 6, it is characterised in that: described step D2
In, for any one sub-section, if its two-end-point is respectively v1And v2, calculate limit v1→v2With longitudinal network ruling and horizontal net
The intersection point of ruling;According to v1To v2Direction, according to the above-mentioned intersection point of magnitude relationship ordered arrangement and the v of abscissa value1And v2Two tops
The set of the point that point is formed;To in the set after sequence the most successively in set of computations in all adjacent 2
Point, calculates the numbering of the grid cell at this place, midpoint, the net at place, midpoint to the formula (2) in each midpoint use step C2
The set that lattice unit is formed is and limit v1→v2The grid cell intersected.
Network of highways efficient spatial K-NN search method the most according to claim 7, it is characterised in that: described step E
In, utilize the formula (2) in step C2, calculate the grid cell at place, query point position, and determine corresponding to query point position
The numbering of grid cell.
Network of highways efficient spatial K-NN search method the most according to claim 8, it is characterised in that described step F
Comprise the following steps:
F1: according to the grid cell numbering calculated in step E, searches this grid cell institute right in Hash table hashmap_3
The slope in every the sub-section answered and control the oid or the vid of link vertex of data object in this sub-section;
F2: calculate the slope of the straight line that query point is formed by connecting with first object on each strip section respectively;If calculating
The slope gone out is equal with the slope in a certain sub-section corresponding to grid cell, then query point is positioned at the sub-section of this correspondence
On;If the slope calculated is the most equal with the slope in some sub-sections corresponding to grid cell, calculate query point the most respectively
And the coordinate position relation between the two-end-point of each sub-line section, to determine sub-section, query point place;
F3: judge whether there is data object on the road of query point place, if it is, enter step F4;If it is not, then enter
Step F5;
F4: if two end points in sub-section, query point place are respectively two data objects, calculate the two data pair the most respectively
As the distance between query point, and the data object closest with query point is returned to user as Query Result, if
Distance between the two data object and query point is identical, is returned to as Query Result by the two data object the most simultaneously
User;
If two end points in sub-section, query point place are respectively a data object and a link vertex, first calculate and look into
Ask some distance r to this data object1Distance r with query point to this link vertex2, then look into from Hash table hashmap_2
Ask this link vertex arest neighbors on spatial network and minimum distance s2, finally compare r1With r2+s2Size, if r1It is less,
Then data object corresponding for sub-for query point place section end points is returned to user as Query Result;If r2+s2Less, then will
The data object corresponding to this link vertex arest neighbors on spatial network is inquired about as inquiry from Hash table hashmap_2
Result returns to user;If r1With r2+s2Size identical, the most simultaneously by data pair corresponding for sub-for query point place section end points
As, from Hash table hashmap_2, inquire about data object corresponding to this link vertex arest neighbors on spatial network simultaneously
User is returned to as Query Result;F5: if two end points of query point place road are respectively two link vertex, first
Score does not calculate query point distance r to first link vertex3Distance r with query point to second link vertex4, then
First link vertex arest neighbors on spatial network and minimum distance s is inquired about respectively from Hash table hashmap_23,
Arest neighbors on spatial network of two link vertex and minimum distance s4, calculate r3+s3With r4+s4Size, if r3+s3Relatively
Little, then by corresponding to arest neighbors on spatial network of first link vertex inquiring from Hash table hashmap_2
Data object returns to user as Query Result;If r4+s4Less, then that will inquire from Hash table hashmap_2 by second
Data object corresponding to individual link vertex arest neighbors on spatial network returns to user as Query Result;If r3+s3With
r4+s4Size identical, the most simultaneously by first link vertex inquiring from Hash table hashmap_2 on spatial network
The data object corresponding to arest neighbors, second link vertex inquiring from Hash table hashmap_2 be at spatial network
On the data object corresponding to arest neighbors return to user simultaneously as Query Result.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310473051.1A CN103559213B (en) | 2013-10-10 | 2013-10-10 | A kind of network of highways efficient spatial K-NN search method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310473051.1A CN103559213B (en) | 2013-10-10 | 2013-10-10 | A kind of network of highways efficient spatial K-NN search method |
Publications (2)
Publication Number | Publication Date |
---|---|
CN103559213A CN103559213A (en) | 2014-02-05 |
CN103559213B true CN103559213B (en) | 2016-08-17 |
Family
ID=50013460
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201310473051.1A Active CN103559213B (en) | 2013-10-10 | 2013-10-10 | A kind of network of highways efficient spatial K-NN search method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103559213B (en) |
Families Citing this family (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106033440A (en) * | 2015-03-16 | 2016-10-19 | 中国石油化工股份有限公司 | Management method for spatial data |
CN105868336B (en) * | 2016-03-28 | 2019-11-29 | 哈尔滨工程大学 | Spatial key word querying method in road network towards set |
CN107301254B (en) * | 2017-08-24 | 2020-07-10 | 电子科技大学 | Road network hot spot area mining method |
CN110657805A (en) * | 2018-09-30 | 2020-01-07 | 北京奇虎科技有限公司 | Method and device for searching moving target based on road scene |
CN109902711B (en) * | 2019-01-14 | 2023-03-31 | 南京航空航天大学 | K-nearest neighbor query algorithm for moving object on time-dependent road network |
CN113449208B (en) * | 2020-03-26 | 2022-09-02 | 阿里巴巴集团控股有限公司 | Space query method, device, system and storage medium |
CN115392955B (en) * | 2022-08-10 | 2024-03-01 | 中国银联股份有限公司 | Store duplicate removal processing method, store duplicate removal processing device, store duplicate removal processing equipment and storage medium |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP5333815B2 (en) * | 2008-02-19 | 2013-11-06 | 株式会社日立製作所 | k nearest neighbor search method, k nearest neighbor search program, and k nearest neighbor search device |
CN102810118B (en) * | 2012-07-05 | 2015-08-05 | 上海电力学院 | A kind of change weighs net K nearest neighbor search method |
CN103020130B (en) * | 2012-11-20 | 2016-11-09 | 北京航空航天大学 | A kind of k nearest neighbor query method towards support area in the location-based service of city road network |
CN103020319A (en) * | 2013-01-11 | 2013-04-03 | 江苏大学 | Real-time mobile space keyword approximate Top-k query method |
-
2013
- 2013-10-10 CN CN201310473051.1A patent/CN103559213B/en active Active
Also Published As
Publication number | Publication date |
---|---|
CN103559213A (en) | 2014-02-05 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN103559213B (en) | A kind of network of highways efficient spatial K-NN search method | |
CN103884345B (en) | Interest point information collecting method, interest point information displaying method, interest point information collecting device, interest point information displaying device, and interest point retrieval system | |
RU2571573C1 (en) | Method and server for searching for nearby user in social networking services | |
CN100523735C (en) | Fast map matching method based on small lattice road network organization and structure | |
CN103927933B (en) | A kind of magnanimity moves method and the device that target renders | |
CN109902711B (en) | K-nearest neighbor query algorithm for moving object on time-dependent road network | |
CN103559209B (en) | A kind of efficient spatial K-NN search method that Voronoi Diagram is combined with virtual grid | |
CN101488158A (en) | Road network modeling method based on road element | |
Huang et al. | Continuous distance-based skyline queries in road networks | |
CN107167136A (en) | Recommend method and system in a kind of position towards electronic map | |
CN108241712A (en) | A kind of map data processing method and device | |
CN106708837B (en) | Interest point searching method and device | |
CN101944095A (en) | Path planning method and system | |
CN102609530A (en) | Space database indexing method of regional double-tree structure | |
CN101587650A (en) | GPS bus transfering navigation method and system thereof | |
CN106570062A (en) | System and method for querying uncertain moving object range of road network trajectory | |
CN102175252A (en) | Method for planning dynamic merging and united path of distributed multi-stage road network | |
US20220027427A1 (en) | Business searching methods and apparatuses, electronic devices and storage media | |
CN101789028B (en) | Search engine for geographical position and constructing method thereof | |
Sun et al. | Demonstrating spindra: A geographic knowledge graph management system | |
CN103631839B (en) | A kind of page region weight model implementation method | |
CN105466418A (en) | A map positioning method and a device | |
CN104809530A (en) | System and method for automatically optimizing travel routes | |
CN103177650B (en) | Simple digital map manufacturing method based on aerial photo | |
CN105096589A (en) | Method of selecting representative node in traffic road, system and client |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
CP02 | Change in the address of a patent holder |
Address after: 475001 Henan province city Minglun Street No. 85 Patentee after: Henan University Address before: 475004 Jinming Avenue, Kaifeng City, Henan Province Patentee before: Henan University |
|
CP02 | Change in the address of a patent holder |