WO2016095749A1 - Method and device for querying spatial object and establishing spatial index of electronic map - Google Patents

Method and device for querying spatial object and establishing spatial index of electronic map Download PDF

Info

Publication number
WO2016095749A1
WO2016095749A1 PCT/CN2015/097021 CN2015097021W WO2016095749A1 WO 2016095749 A1 WO2016095749 A1 WO 2016095749A1 CN 2015097021 W CN2015097021 W CN 2015097021W WO 2016095749 A1 WO2016095749 A1 WO 2016095749A1
Authority
WO
WIPO (PCT)
Prior art keywords
bit
spatial object
bits
binary
spatial
Prior art date
Application number
PCT/CN2015/097021
Other languages
French (fr)
Chinese (zh)
Inventor
贾双成
叶旻
Original Assignee
高德软件有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 高德软件有限公司 filed Critical 高德软件有限公司
Publication of WO2016095749A1 publication Critical patent/WO2016095749A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor

Definitions

  • the present invention relates to the field of geographic information systems, and in particular, to a method and apparatus for querying spatial objects and establishing spatial indexes in an electronic map.
  • the wide application of satellite positioning technology and Internet technology has driven the development of navigation and location service related industries.
  • the need for location services provided by geographic information systems is becoming more and more urgent.
  • the so-called spatial object refers to the spatial entity represented in the electronic map.
  • a building can be a spatial object
  • a road can be a spatial object.
  • a spatial object can also represent a collection of spatial entities, such as several storefronts within a certain area or multiple buildings within a certain area.
  • Spatial objects can be distinguished from other spatial objects by configuring a unique spatial object identifier such as number 1, 2, 3, etc. in the electronic map.
  • a spatial index refers to a data structure arranged in a certain order according to the position and shape of a spatial object or a certain spatial relationship between spatial objects.
  • quadtree spatial indexing is a widely used spatial indexing mechanism.
  • the basic idea of quadtree spatial indexing is to recursively divide geospatial into tree structures of different levels. It divides the geographical space of the known range into four equal subspaces. If necessary, divide at least one subspace into four equal subspaces. So recursively, until the level of the tree reaches a certain depth or after some requirements are met, the segmentation is stopped (for example, if the number of spatial objects associated with each node of the current subspace does not exceed the preset number, the segmentation is stopped, otherwise the pair continues This subspace is split).
  • the root node queries the leaf node layer by layer. For example, it is determined whether the spatial object identifier of the spatial object is included in the spatial object range corresponding to the root node, and if so, the query is continued to the lower node of the root node until the leaf node is queried. It can be seen that each query space object needs to query layer by layer in the prior art. When the tree structure level of the quadtree spatial index is large, the existing query method based on the quadtree spatial index query space object is inefficient.
  • An object of the present invention is to provide a method and apparatus for querying a spatial object and establishing a spatial index in an electronic map to overcome the problem of low query efficiency of spatial objects in the prior art.
  • the present invention provides a method for querying a spatial object in an electronic map, including:
  • the binary combination ID includes a hierarchical indication bit indicating a hierarchy of the spatial object to be queried in the spatial index, and a grid indicating that the spatial object belongs to the hierarchy
  • the space object to be queried is queried in the determined grid.
  • the present invention provides a method for establishing a spatial index in an electronic map, the method comprising:
  • the latitude and longitude range included in the electronic map is respectively mapped to an integer range represented by m-bit binary numbers, wherein each layer of the electronic map has been previously divided into 2 2i grids having the same geographical space range, and i represents each layer.
  • the level of the electronic map the value of i is 1 to N, and m is a positive integer greater than or equal to N, and N is a positive integer;
  • the i-bit longitude and i-bit latitude of the extracted spatial object are staggered to obtain a binary sequence of 2i bits, and the binary sequence of 2i bits represents the mesh to which the spatial object belongs in the i-th layer.
  • the hierarchical indication bit and the initial ID of the spatial object are combined according to a preset combination rule to generate a binary combination ID of the spatial object in the i-th layer.
  • the present invention further provides an apparatus for querying a spatial object in an electronic map, the apparatus comprising:
  • An obtaining module configured to obtain a binary combination ID of the spatial object to be queried, where the binary combination ID includes a hierarchical indication bit indicating a hierarchy of the spatial object to be queried in the spatial index, and a grid indicating that the spatial object belongs to the hierarchy
  • a hierarchy determining module configured to determine, according to a hierarchical indication bit in the binary combination ID, a hierarchy of the spatial object to be queried in the spatial index
  • a grid determining module configured to determine, according to an initial ID in the binary combination ID, a grid to which the to-be-queried spatial object belongs in a hierarchy indicated by the hierarchical indicator bit;
  • a query module configured to query the to-be-queried spatial object in the determined grid.
  • the present invention further provides an apparatus for establishing a spatial index in an electronic map, the apparatus comprising:
  • a latitude and longitude representation module for mapping the latitude and longitude ranges included in the electronic map to integer ranges each represented by an m-bit binary number, wherein each layer of the electronic map has been previously divided into 2 2i grids having the same geographical space range , i denotes the level of each layer of the electronic map, i takes a value from 1 to N, and m is a positive integer greater than or equal to N, and N is a positive integer;
  • a latitude and longitude determining module configured to determine, for each spatial object in each layer, an m-bit binary number of the longitude corresponding mapping of the spatial object, and an m-bit corresponding to the latitude of the spatial object Binary number
  • the bit module is used for the order from the high bit to the low bit, and the i bit is taken from the m binary number of the longitude corresponding mapping of the spatial object and the i bit is taken from the binary number of the latitude corresponding mapping;
  • the initial ID generation module is configured to interleave the i-bit longitude and the i-bit latitude of the extracted spatial object in order from high to low, to obtain a binary sequence of 2i bits, and the binary sequence of the 2i bits indicates that the spatial object is in the first The initial ID of the grid to which the i layer belongs;
  • the combined ID generation module is configured to combine the hierarchical indication bit and the initial ID of the spatial object according to a preset combination rule to generate a binary combination ID of the spatial object in the i-th layer.
  • the spatial index is established by dividing the electronic map, so that the spatial object of each layer in the spatial index has a binary combination ID, so that the binary combination ID can represent the spatial object to be queried in the spatial index.
  • the method of querying the mesh to which the spatial object belongs by means of one node and one node can improve the query efficiency.
  • FIG. 1 is an exemplary flowchart of a method for querying a spatial object in an electronic map according to an embodiment of the present invention
  • FIG. 2 is an exemplary flowchart of a method for establishing a spatial index in an electronic map according to an embodiment of the present invention
  • FIG. 3a is a schematic diagram of a global electronic map, which is divided into four grids in a first layer in a latitude and longitude direction according to an embodiment of the present invention
  • FIG. 3b is a schematic diagram showing 16 grids of the second layer of the global electronic map on the basis of FIG. 3a according to an embodiment of the present invention
  • FIG. 4 is an exemplary flowchart of constructing a spatial index for a global electronic map according to an embodiment of the present invention
  • FIG. 5 is an exemplary flowchart of a process for querying a query space object by using a constructed spatial index according to an embodiment of the present invention
  • FIG. 6 is a schematic diagram of an apparatus for querying a spatial object in an electronic map according to an embodiment of the present invention.
  • FIG. 7 is another schematic diagram of an apparatus for querying a spatial object in an electronic map according to an embodiment of the present invention.
  • FIG. 8 is a schematic diagram of an apparatus for establishing a spatial index in an electronic map according to an embodiment of the present invention.
  • FIG. 9 is another schematic diagram of an apparatus for establishing a spatial index in an electronic map according to an embodiment of the present invention.
  • the embodiment of the invention provides a method for querying a spatial object in an electronic map.
  • a novel spatial indexing mechanism of the electronic map is provided.
  • the electronic map is divided into multiple levels in advance, each level represents a complete electronic map, and each level divides the electronic map into multiple copies, each of which represents a grid (can be understood as a Tile).
  • each spatial object has a binary combination ID at each layer, and the binary combination ID includes a hierarchical indication bit indicating a hierarchy of the spatial object to be queried in the spatial index, and Indicates the initial ID of the grid to which the spatial object belongs in the hierarchy, so that when querying the spatial object, there is no need to query from node to node in the prior art.
  • the present invention can quickly locate the hierarchy to which the spatial object to be queried belongs, and the mesh to which the affiliation belongs, so that the mesh to which the spatial object belongs can be accurately and quickly located, thereby
  • the prior art can speed up the query efficiency of the query space object.
  • the present invention includes two aspects of querying a spatial object and establishing a spatial index. These two aspects are described in detail below.
  • FIG. 1 it is an example of a method for querying a spatial object in an electronic map according to an embodiment of the present invention.
  • Sexual flow chart the method includes the following steps:
  • Step 101 Obtain a binary combination ID of a spatial object to be queried, where the binary combination ID includes a hierarchical indication bit indicating a hierarchy of the spatial object to be queried in the spatial index, and an initial representation of the mesh to which the spatial object belongs. ID.
  • the space object to be queried may be a spatial entity or a set of multiple spatial entities, such as a Poi (Point of Interest).
  • Step 102 Determine, according to the hierarchical indicator bit in the binary combination ID, the belonging level of the spatial object to be queried in the spatial index.
  • step 102 may include the following steps:
  • Step A1 determining, according to the binary combination ID, the first bit assigned to 1 from the binary combination ID, the first bit assigned a value of 1 is represented in the binary combination ID
  • Step A2 Determine the total number of bits after the first bit in the binary combination ID assigned to 1, the total number of bits being the total number of bits of the initial ID.
  • Step A3 Divide the total number of bits by 2 to obtain the belonging level of the spatial object.
  • Step 103 Determine, according to the initial ID in the binary combination ID, the mesh to which the to-be-queried spatial object belongs in the hierarchy indicated by the hierarchical indicator bit.
  • Step 104 Query the to-be-queried spatial object in the determined grid.
  • the embodiment of the present invention implements the hierarchical level of the query according to the hierarchical indication bit in the binary combination ID, and locates the mesh to which the spatial object to be queried belongs by using the initial ID, so that the query method can quickly locate the spatial object to be queried relative to the prior art node-by-node query method.
  • Grid to help speed up query space The speed of the image, which can improve the query efficiency of the spatial object.
  • This embodiment is used to describe a method for establishing a spatial index.
  • FIG. 2 it is an exemplary flowchart of a method for establishing a spatial index in an electronic map according to an embodiment of the present invention. The method includes the following steps:
  • Step 201 Map the latitude and longitude ranges included in the electronic map to integer ranges each represented by an m-bit binary number, wherein each layer of the electronic map has been previously divided into 2 2i grids having the same geographical space range, and i represents For each level of the electronic map, i takes a value from 1 to N, and m is a positive integer greater than or equal to N, and N is a positive integer.
  • Step 202 Determine, for each spatial object in each layer, an m-bit binary number of the longitude corresponding mapping of the spatial object, and an m-bit binary number of the latitude corresponding mapping of the spatial object.
  • Step 203 Taking the order of the high order to the low order, taking the i bit from the m bit binary number of the longitude corresponding mapping of the spatial object and the i bit of the m bit binary number corresponding to the latitude mapping.
  • Step 204 The high-order to low-order order is used to interleave the extracted i-bit longitude and i-bit latitude of the spatial object to obtain a binary sequence of 2i bits, and the binary sequence of 2i bits indicates that the spatial object belongs to the i-th layer.
  • the initial ID of the grid The initial ID of the grid.
  • Step 205 Combine the hierarchical indication bit and the initial ID of the spatial object according to a preset combination rule to generate a binary combination ID of the spatial object in the i-th layer.
  • step 201 1) In step 201:
  • the global electronic map when the electronic map is a global electronic map, the global electronic map can be divided into 1 to 15 layers, and each layer is a level.
  • each layer of the electronic map described in step 201 is divided into 2 2i grids having the same geographical space range: for example, in the 15th layer, the global electronic map is divided into 2 30 with the same latitude and longitude range. Equals.
  • the global electronic map is segmented in the latitude direction and segmented in the longitude direction to obtain four meshes.
  • the number in the figure is a binary number, indicating the initial ID of the layer in the layer (the meanings of the numbers in the following figure are the same in Figure 3b, and will not be described later); the formation process of the second layer is as follows: as shown in Figure 3b, in the figure On the basis of 3a, each grid in Fig.
  • the grid in the i-th layer is obtained by cutting each grid in the i-th layer into four parts. It should be noted that, in the first few layers, the mesh is first cut from the latitude direction and then the mesh is cut from the longitude direction, or the mesh is first cut from the longitude direction to divide the mesh from the latitude direction, or simultaneously
  • the singularity of the mesh from the latitude and longitude directions is applicable to the embodiments of the present invention, which is not limited by the present invention.
  • m has a value of 31 and N has a value of 15.
  • N has a value of 15.
  • the geographic range represented by each grid in the 15th layer is about 1.8cm, and the minimum spatial object that can be represented has a geographical range of 1.8 2 cm 2 . In turn, it is possible to accurately represent the position of the spatial object.
  • the largest integer that can be represented by an m-bit binary number is 2 2 -1, which represents a total of 2 m integers.
  • the longitude of the electronic map is represented by m-bit binary numbers, and the latitude is also m-bit binary number.
  • each layer of the electronic map in order to make the grid of the layer and the initial ID have a one-to-one correspondence, that is, each grid corresponds to an initial ID, and each initial ID corresponds to a grid, then the latitude and longitude can be combined.
  • the number of integers must be greater than or equal to the number of grids (ie, 2 2m ⁇ 2 2i ), so for the ith layer, m ⁇ i .
  • the electronic map has a total of N layers, that is, the maximum value of i is N, so m ⁇ N.
  • the longitude of the electronic map For mapping the longitude of the electronic map to the integer range represented by the m-bit binary number, for example, when N is 15 and m is 31, if the longitude range of the electronic map is [0, 90], 31 bits are used.
  • the smallest integer represented by a binary number, that is, 31 zeros represents the minimum longitude (ie, the longitude is 0), and the largest integer represented by a 31-bit binary number, that is, 31, represents the maximum longitude (ie, the longitude is 90); for the same reason, for the electronic map
  • the latitude is mapped to the integer range represented by the m-bit binary number. For example, when N is 15 and m is 31, if the latitude of the electronic map is [0, 90], the 31-bit binary is used.
  • the smallest integer represented, that is, 31 zeros represents the minimum latitude (ie, the latitude is 0), and the largest integer represented by the 31-bit binary number, that is, 31, represents the maximum latitude (ie, the
  • step 203 In step 203:
  • the value of m is 31, that is, the latitude and longitude of the global electronic map are each a 31-bit binary number. If the longitude coordinate of a spatial object B in the fifth layer is "1111111 11111111 11111111 11111110" (where the direction from the high to the low is from left to right), the latitude coordinate of the spatial object B is "0111111 11111111 11111111 11111110" Then, the upper 5 bits of the longitude of the spatial object are "11111", and the latitude of the spatial object is 5 bits higher than "01111".
  • the m-bit binary number can fully represent the actual latitude and longitude value. At this time, the m-bit binary number represents the actual integer part. Latitude and longitude.
  • the m-bit binary number of the longitude-corresponding mapping is required for each spatial object.
  • one of the simplest solving methods is, for example, determining the ratio of the actual longitude of the spatial object to the maximum longitude, which is the m-bit binary number of the corresponding mapping of the longitude. The ratio between the maximum m-bit binary and the largest m-bit binary is determined, and the ratio is determined, and the long-term corresponding mapped m-bit binary number is solvable.
  • the m-bit binary number of the corresponding mapping is determined by other mathematical methods, and is also applicable to the embodiment of the present invention, which is not limited by the present invention.
  • step 204
  • the high 3-bit binary number of the latitude of the spatial object is “C 1 C 2 C 3 "
  • the high 3-bit binary number of the longitude is “D 1 D 2 D 3 ", which is obtained from the longitude and then staggered.
  • the 6-bit binary sequence should be "D 1 C 1 D 2 C 2 D 3 C 3 ".
  • the 10-bit binary sequence of the space object B in the fifth layer should be "1011111111”
  • the decimal number is 767 (that is, in the embodiment of the present invention, the decimal object can be used to represent the network object B in the layer 5
  • the initial ID of the grid is 767).
  • the staggered arrangement may be started from the latitude direction, which is not limited by the present invention.
  • the initial ID is 101101 (a total of 6 binary digits).
  • the grid is segmented based on the grid of the previous layer (ie, the second layer) with an initial ID of 1011.
  • the principle is first explained by a simple example, for example, the same spatial object is in each layer. Where the m-bit binary numbers of its longitude are the same, then in the second layer, the 4-bit binary number taken from the high-order to the low-order order, and the third-level binary-number in the third layer is also taken from the high-order to the low-order.
  • bit binary numbers which are also a spatial object, require only a different number of bits in different levels.
  • the initial ID of the spatial object in the layer is staggered by the high i-bit of longitude and latitude, so the initial ID of the lowest layer (the Nth layer) has a maximum of 2N bits.
  • the initial ID of the total number of bits of a spatial object represents the mesh to which the spatial object belongs in each layer, and the spatial object is in the mesh with the initial ID of 101101 in the third layer.
  • the spatial object is in the grid of the second layer with an initial ID of 1011.
  • the position of the spatial object in the electronic map is fixed.
  • the range represented by the upper layer of the grid is larger than the range represented by the grid of the next layer, so the grid with the initial ID of 101101 is initialized.
  • the mesh with the ID of 1011 is derived from the mechanism of dividing the electronic map and establishing the initial ID for the mesh.
  • the mesh with the initial ID of 1011 in the second layer is again divided into meshes with an initial ID of 10 in the first layer. It can be seen that the parent-child relationship between the grids in the initial ID is very easy to identify and judge.
  • the binary combination ID of the newly added spatial object may be directly generated and stored according to the latitude and longitude of the spatial object. It is not necessary to generate the spatial object identifier cumbersomely for each corresponding node as in the prior art, so that the embodiment of the present invention facilitates simple and fast spatial indexing.
  • step 205 In step 205:
  • an initial ID of the mesh in which the spatial object is located is generated according to the latitude and longitude coordinates of the spatial object, and the initial ID can clearly indicate the relationship between the upper and lower levels of the mesh, and
  • the latitude and longitude coordinates are associated with the grid by the initial ID, so that when the spatial object is queried, the grid of the spatial object can be quickly located by the initial ID.
  • the binary combination ID is generated by adding the hierarchical information to the initial ID, so that the binary combination ID can represent the hierarchy to which the spatial object belongs, and the hierarchical level of the mesh in which the spatial object is located can also be represented, so as to quickly determine in which hierarchy the space is determined.
  • the grid to which the object belongs is generated according to the latitude and longitude coordinates of the spatial object, and the initial ID can clearly indicate the relationship between the upper and lower levels of the mesh, and
  • the latitude and longitude coordinates are associated with the grid by the initial ID, so that when the spatial object is queried, the grid of the spatial object can be quickly located by the
  • step 205 can be implemented as the following steps:
  • Step B1 Add a bit bit indicating the level indication bit before the highest bit of the secondary sequence corresponding to the initial ID, and set the value of the bit to 1.
  • Step B2 If the number of bits of the secondary sequence formed by the hierarchical indicator bit and the initial ID is less than the preset number of bits of the binary combination ID, then L bits are added before the level indication bit, and the L bits are The bit bit value is set to 0, and the L is equal to the preset number of bits minus the number of bits remaining after the level indicator bit and the number of bits occupied by the initial ID.
  • the preset number of bits in each layer may be different, and the preset number of bits in each layer is an integer multiple of 8 which can include the initial ID of the layer, for example, the initial ID of a layer is 6 bits.
  • the total number of bits of the initial ID plus the level indicator bit is 7 bits in total, then the preset number of bits in the layer is 8 bits; if the initial ID of a layer is 8 bits, the total number of bits of the initial ID plus the level indicator bit A total of 9 bits, the default number of bits in the layer is 16 bits; if the initial ID of a layer is 10 bits, the total number of bits of the initial ID plus the level indicator is a total of 11 bits, then the preset of the layer The number of digits is 16 bits.
  • the preset number of bits can be set to a fixed value according to actual needs, for example, the electronic map to be divided is divided into 15 layers, and the longitude and latitude are represented by 31-bit binary numbers, and the initial ID of the 15th layer is The number of digits is up to 30 bits (15+15), so in order to be able to contain 30-bit binary numbers, the preset number of bits can be set to 32 bits; for example, the electronic map to be divided is divided into 31 layers, and the longitude and Latitude is 31 bits each When the binary number is expressed, the initial ID of the 31st layer has a maximum of 62 bits (31+31), so in order to be able to include a 62-bit binary number, the preset number of bits can be set to 64 bits.
  • a one-bit sign bit is added before the most significant bit of the binary combination ID. For example, when the binary combination ID indicates a positive number, and the symbol position is 0, when the binary combination ID indicates a negative number, the symbol position is set to 1.
  • the binary combination ID can include the hierarchical information corresponding to the spatial object and the information of the mesh to which the spatial object belongs, so that the mesh to which the spatial object belongs can be quickly queried in the established spatial index. For subsequent operations, such as rendering the grid in which the spatial object is located, or accurately rendering the location of the spatial object in the electronic map according to the latitude and longitude coordinates of the spatial object.
  • the embodiment of the present invention establishes a spatial index on the electronic map, so that the spatial object of each layer in the spatial index has a binary combination ID, so that the binary combination ID can represent the hierarchy of the spatial object to be queried in the spatial index.
  • the hierarchical indicator bit, and the initial ID of the mesh to which the spatial object belongs in the hierarchy so that when the spatial object is queried, the hierarchy to which the spatial object belongs and the associated mesh can be quickly determined according to the binary combination ID, and thus the relative
  • a method of querying a mesh to which a spatial object belongs by means of a node and a node can improve query efficiency.
  • the building A is used as the object to be queried, and the space object is queried in the space index, and the mesh to which the space object belongs is located, and the mesh after the positioning is rendered as an example.
  • the method for querying a spatial object in an electronic map is described in detail. The method includes a process of pre-constructing a spatial index in advance, and a process of locating a mobile terminal by using the spatial index of the construct in the later stage:
  • Step 401 The global electronic map is divided into 15 layers, and the global electronic map is divided into 2 2i equal parts in the same geographical space in each layer, wherein each layer is a level, and i represents a level.
  • Step 402 Map the latitude and longitude ranges included in the global electronic map to integer ranges each represented by a 31-bit binary number.
  • the step 402 can be understood as that the global latitude and longitude are respectively quantized, so that the range between the minimum longitude and the maximum longitude of the electronic map to be divided after quantization and the range between the minimum latitude and the maximum latitude are both [0, 2 31 -1], and the longitude and latitude of the electronic map to be divided are respectively represented by a 31-digit binary number.
  • Step 403 For each spatial object in the i-th layer, determine a 31-bit binary number of the longitude-corresponding mapping of the spatial object, and a 31-bit binary number of the latitude-corresponding mapping of the spatial object.
  • Step 404 From the order of the high order to the low order, the i bit is taken from the 31-bit binary number of the longitude corresponding map of the spatial object and the 31 bit binary number of the latitude corresponding map is taken.
  • Step 405 The order of the i-bit longitude and the i-bit latitude of the extracted spatial object are staggered from the high order to the low order to obtain a binary sequence of 2i bits, and the binary sequence of the 2i bits indicates that the spatial object belongs to the i-th layer.
  • the initial ID of the grid The initial ID of the grid.
  • Step 406 Add a bit indicating the level indication bit before the highest bit of the secondary sequence corresponding to the initial ID, and set the value of the bit to 1.
  • Step 407 If the number of bits of the secondary sequence formed by the hierarchical indicator bit and the initial ID is less than the preset number of bits of the binary combination ID, that is, 31 bits, then L bits are added before the level indication bit, and The L bit bits take the value set to 0, and the L is equal to the preset number of bits 31 minus the number of bits remaining after the level indicator bit and the number of bits occupied by the initial ID.
  • Step 408 Add a bit in front of the highest bit of the binary combination ID as a sign bit to generate a binary combination ID with a sign bit.
  • Step 501 Acquire the latitude and longitude of the building A.
  • Step 502 According to the latitude and longitude of the building A, and according to step 403-step 408, the binary combination ID of the signed bit of the building A in the 15th layer of the global electronic map is generated.
  • step 502 a binary combination ID of the 15th layer with a sign bit is generated, and the binary combination ID with the sign bit has a hierarchical relationship of all layers, so that the building A can be located in other levels later.
  • the binary combination ID with the sign bit generated at the 15th layer is only illustrated in step 502, and is not intended to limit the present invention.
  • the building A can be queried in the first layer according to actual needs in order to generate a binary combination ID of the signed bit of the layer. For example, it is determined that the building A is displayed in the first floor according to the map scale set by the user. For example, if the scale set by the user is large enough, it can be determined that in the 15th floor, the building A is displayed, and the binary combination ID of the symbol A of the building A of the 15th floor is generated; if the scale set by the user is small enough, When it is determined that the building A is displayed in the first floor, the binary combination ID with the sign bit of the building A of the first floor is generated.
  • Step 503 Determine the grid to which the building A belongs in the 15th floor of the global electronic map according to the binary combination ID of the sign A of the building A, and determine the position of the building A in the grid.
  • Step 504 Render the grid to which the building A belongs in the 15th layer of the global electronic map, and render the location of the mobile terminal in the grid.
  • Step 505 According to the selection operation of the 10th layer selected by the user, it is determined that the user requests to render the grid to which the mobile terminal belongs in the 10th layer.
  • Step 506 Determine the binary combination ID of the mobile terminal in the 10th layer according to the initial ID of the mobile terminal in the binary combination ID with the sign bit in the 15th layer of the global electronic map.
  • the binary combination ID with the sign bit is represented by 32 bits, and if the binary combination ID of the signed bit in the 15th layer of the building A is "01000101 11111111 11111111 11111111, the highest Bit 0 is a sign bit indicating a positive number, then the third bit to the 22nd bit from the high bit is the initial ID of building A in the 10th floor, ie "000101 11111111 111111" (ie, the last 30 bits of the order from the high to the low in the binary combination ID with the sign bit are the initial ID at the 15th layer, and the first 20 bits of the initial ID of the 15th layer are the initial at the 10th layer. ID).
  • the building A is added by a bit indicating the level indicating bit before the high bit of the initial ID in the 10th layer, and the position is set to 1, and then the binary combined ID is generated, and then in the binary Adding a sign bit before the high bit of the combined ID finally obtains the binary combination ID of the 32-bit signed bit of the building A in the 10th floor: 000000000 0001 000101 11111111 111111.
  • Step 507 Determine the grid to which the building A belongs in the tenth floor according to the binary combination ID of the sign A in the tenth floor of the building A, and determine the position of the building A in the grid.
  • Step 508 Render the grid to which the building A belongs in the 10th floor of the global electronic map, and render the position of the building A in the grid.
  • An embodiment of the present invention further provides an apparatus for querying a spatial object in an electronic map, as shown in FIG. 6 is a schematic diagram of the apparatus, the apparatus includes:
  • the obtaining module 601 is configured to obtain a binary combination ID of the spatial object to be queried, where the binary combination ID includes a hierarchical indication bit indicating a hierarchy of the spatial object to be queried in the spatial index, and a network indicating that the spatial object belongs to the hierarchy Initial ID of the grid;
  • a hierarchy determining module 602 configured to determine, according to a hierarchical indicator bit in the binary combination ID, a hierarchy of the spatial object to be queried in the spatial index;
  • a grid determining module 603, configured to determine, according to an initial ID in the binary combination ID, a grid to which the to-be-queried spatial object belongs in a hierarchy indicated by the hierarchical indicator bit;
  • the query module 604 is configured to query the to-be-queried spatial object in the determined grid.
  • the level determining module 602 includes:
  • the hierarchical indication information determining unit 605 is configured to determine, from the binary combination ID, a first bit assigned a value of 1 according to a binary combination ID from an upper order to a lower order, wherein the first bit assigned a value of 1 is a hierarchical indication bit indicating a hierarchy level of the spatial object to be queried in the spatial index in the binary combination ID;
  • the initial ID total number of bits determining unit 606 is configured to determine a total number of bits after the first bit of the binary combination ID that is assigned a value of 1, the total number of bits is the total number of bits of the initial ID;
  • the level determining unit 607 is configured to divide the total number of bits by 2 to obtain the belonging level of the spatial object.
  • the embodiment of the present invention further provides an apparatus for establishing a spatial index in an electronic map.
  • the apparatus includes:
  • the latitude and longitude indicating module 801 is configured to map the latitude and longitude ranges included in the electronic map to integer ranges each represented by an m-bit binary number, wherein each layer of the electronic map has been previously divided into 2 2i networks having the same geographical space range.
  • L, i represents the level of each layer of electronic map, i takes a value from 1 to N, and m is a positive integer greater than or equal to N, N is a positive integer;
  • the latitude and longitude determination module 802 is configured to determine, for each spatial object in each layer, an m-bit binary number of the longitude corresponding mapping of the spatial object, and an m-bit binary number corresponding to the latitude of the spatial object;
  • the bit-taking module 803 is configured to take the i-bit from the m-bit binary number of the longitude-corresponding mapping of the spatial object and the m-bit binary number of the latitude-corresponding mapping in the order from the upper bit to the lower bit;
  • the initial ID generation module 804 is configured to interleave the extracted i-bit longitude and i-bit latitude of the spatial object from the high order to the low order to obtain a binary sequence of 2i bits, wherein the binary sequence of 2i bits indicates that the spatial object is The initial ID of the grid to which the i-th layer belongs;
  • the combined ID generation module 805 is configured to combine the hierarchical indication bit and the initial ID of the spatial object according to a preset combination rule to generate a binary combination ID of the spatial object in the i-th layer.
  • the combined ID generating module 805 includes:
  • a level bit adding unit 806, configured to add a bit bit indicating a level indicator bit before the highest bit of the second-level sequence corresponding to the initial ID, and set the value of the bit bit to 1;
  • the combined ID generating unit 807 is configured to add L bit positions before the level indicating bit if the number of bits of the two-level sequence formed by the level indicating bit and the initial ID is less than the preset number of bits of the binary combination ID, and The value of the L bit bits is set to 0, and the L is equal to the preset number of bits minus the number of bits remaining after the level indicator bit and the number of bits occupied by the initial ID.
  • embodiments of the present invention can be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or a combination of software and hardware. Moreover, the invention can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.
  • computer-usable storage media including but not limited to disk storage, CD-ROM, optical storage, etc.
  • the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
  • the apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
  • the instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Navigation (AREA)
  • Instructional Devices (AREA)

Abstract

A method and device for querying spatial objects and establishing a spatial index of electronic map, the method comprising: obtaining a binary combination ID of a to-be-queried spatial object; the binary combination ID comprises a level indication bit representing a belonging level of the to-be-queried spatial object in the spatial index, and comprises an initial ID representing a belonging grid of the spatial object in said level (101); according to the level indication bit in the binary combination ID, determining the belonging level of the to-be-queried spatial object in the spatial index (102); according to the initial ID in the binary combination ID, determining the belonging grid of the to-be-queried spatial object in the level represented by the level indication bit (103); querying the to-be-queried spatial object in the determined gird (104). The method can improve query efficiency for the spatial object.

Description

电子地图中查询空间对象和建立空间索引的方法及装置Method and device for querying spatial object and establishing spatial index in electronic map
本申请要求在2014年12月18日提交中国专利局、申请号为201410799760.3、发明名称为“电子地图中查询空间对象和建立空间索引的方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese Patent Application filed on Dec. 18, 2014, the Chinese Patent Office, Application No. 201410799760.3, entitled "Method and Apparatus for Querying Space Objects and Establishing Spatial Index in Electronic Maps", the entire contents of which is hereby incorporated by reference. This is incorporated herein by reference.
技术领域Technical field
本发明涉及地理信息系统领域,尤其涉及一种电子地图中查询空间对象和建立空间索引的方法及装置。The present invention relates to the field of geographic information systems, and in particular, to a method and apparatus for querying spatial objects and establishing spatial indexes in an electronic map.
背景技术Background technique
卫星定位技术及互联网技术的广泛应用,带动了导航及位置服务相关产业的发展。用户对于地理信息系统提供的位置服务的需求越来越迫切。例如通过电子地图进行定位,检索空间对象的位置等。而对于电子地图数据进行检索必然要建立空间对象的空间索引。所谓空间对象是指电子地图中表示的空间实体,例如,一栋建筑可以为一个空间对象,一条道路可以为一个空间对象。空间对象也可以表示空间实体的集合,例如一定区域内的几家店面或一定区域内的多个建筑。空间对象在电子地图中可以通过配置一个唯一的空间对象标识例如编号1、2、3等,将该空间对象与其他空间对象区分开来。空间索引则是指依据空间对象的位置和形状或空间对象之间的某种空间关系按一定的顺序排列的一种数据结构。The wide application of satellite positioning technology and Internet technology has driven the development of navigation and location service related industries. The need for location services provided by geographic information systems is becoming more and more urgent. For example, positioning by an electronic map, retrieving the position of a spatial object, and the like. For the retrieval of electronic map data, it is necessary to establish a spatial index of the spatial object. The so-called spatial object refers to the spatial entity represented in the electronic map. For example, a building can be a spatial object, and a road can be a spatial object. A spatial object can also represent a collection of spatial entities, such as several storefronts within a certain area or multiple buildings within a certain area. Spatial objects can be distinguished from other spatial objects by configuring a unique spatial object identifier such as number 1, 2, 3, etc. in the electronic map. A spatial index refers to a data structure arranged in a certain order according to the position and shape of a spatial object or a certain spatial relationship between spatial objects.
在电子地图中,四叉树空间索引是一种应用广泛的空间索引机制。四叉树空间索引的基本思想是将地理空间递归划分为不同层级的树结构。它将已知范围的地理空间等分成四个相等的子空间。需要时再将至少一个子空间再等分成四个相等的子空间。如此递归下去,直至树的层次达到一定深度或者满足某种要求后停止分割(例如,当前子空间的每个节点关联的空间对象的个数不超过预设数目,则停止分割,否则就继续对该子空间进行分割)。在四 叉树空间索引的数据结构中,建立每个节点与该节点的子节点的对应关系,并存储每个节点表示的空间对象范围(如空间对象标识的范围)。当通过四叉树空间索引去查询一个空间对象时,自根节点向叶子节点逐层查询。例如,判断该空间对象的空间对象标识是否包含在根节点对应的空间对象范围中,若是,则向该根节点的下层节点继续查询,直至查询到叶子节点。可见,现有技术每一次查询空间对象都需要逐层进行查询,当四叉树空间索引的树结构层次较多时,现有的基于四叉树空间索引查询空间对象的方法的查询效率低下。In electronic maps, quadtree spatial indexing is a widely used spatial indexing mechanism. The basic idea of quadtree spatial indexing is to recursively divide geospatial into tree structures of different levels. It divides the geographical space of the known range into four equal subspaces. If necessary, divide at least one subspace into four equal subspaces. So recursively, until the level of the tree reaches a certain depth or after some requirements are met, the segmentation is stopped (for example, if the number of spatial objects associated with each node of the current subspace does not exceed the preset number, the segmentation is stopped, otherwise the pair continues This subspace is split). In four In the data structure of the fork tree space index, the correspondence between each node and the child nodes of the node is established, and the range of the spatial object represented by each node (such as the range of the space object identifier) is stored. When a spatial object is queried through the quadtree spatial index, the root node queries the leaf node layer by layer. For example, it is determined whether the spatial object identifier of the spatial object is included in the spatial object range corresponding to the root node, and if so, the query is continued to the lower node of the root node until the leaf node is queried. It can be seen that each query space object needs to query layer by layer in the prior art. When the tree structure level of the quadtree spatial index is large, the existing query method based on the quadtree spatial index query space object is inefficient.
发明内容Summary of the invention
本发明的目的是提供一种电子地图中查询空间对象和建立空间索引的方法及装置,以克服现有技术中空间对象的查询效率低下的问题。An object of the present invention is to provide a method and apparatus for querying a spatial object and establishing a spatial index in an electronic map to overcome the problem of low query efficiency of spatial objects in the prior art.
第一方面,本发明提供一种电子地图中查询空间对象的方法,包括:In a first aspect, the present invention provides a method for querying a spatial object in an electronic map, including:
获取待查询空间对象的二进制组合ID(Identity,标识),所述二进制组合ID中包括表示该待查询空间对象在空间索引中所属层级的层级指示位,以及表示该空间对象在该层级所属网格的初始ID;Obtaining a binary combination ID (Identity) of the to-be-queried spatial object, where the binary combination ID includes a hierarchical indication bit indicating a hierarchy of the spatial object to be queried in the spatial index, and a grid indicating that the spatial object belongs to the hierarchy Initial ID
根据二进制组合ID中的层级指示位,确定该待查询空间对象在空间索引中的所属层级;Determining, according to the hierarchical indicator bit in the binary combination ID, the belonging level of the spatial object to be queried in the spatial index;
根据二进制组合ID中的初始ID,确定该待查询空间对象在层级指示位表示的层级中所属的网格;Determining, according to an initial ID in the binary combination ID, a mesh to which the to-be-queried spatial object belongs in a hierarchy indicated by the hierarchical indicator bit;
在确定的网格中查询所述待查询空间对象。The space object to be queried is queried in the determined grid.
第二方面,本发明提供一种电子地图中建立空间索引的方法,所述方法包括:In a second aspect, the present invention provides a method for establishing a spatial index in an electronic map, the method comprising:
将电子地图所包含的经纬度范围分别映射到均用m位二进制数表示的整数范围,其中,已预先将每一层电子地图分割为地理空间范围相同的22i个网格,i表示每一层电子地图的层级,i的取值为1到N,且m为大于或等于N的正整数,N为正整数; The latitude and longitude range included in the electronic map is respectively mapped to an integer range represented by m-bit binary numbers, wherein each layer of the electronic map has been previously divided into 2 2i grids having the same geographical space range, and i represents each layer. The level of the electronic map, the value of i is 1 to N, and m is a positive integer greater than or equal to N, and N is a positive integer;
针对每一层中的每一个空间对象,确定该空间对象的经度对应映射的m位二进制数,以及该空间对象的纬度对应映射的m位二进制数;Determining, by each spatial object in each layer, an m-bit binary number of the longitude corresponding mapping of the spatial object, and an m-bit binary number corresponding to the latitude of the spatial object;
由高位到低位的顺序,从该空间对象的经度对应映射的m位二进制数中取i位以及纬度对应映射的m位二进制数中取i位;From the order of the high order to the low order, taking the i bit from the m-bit binary number of the longitude corresponding mapping of the spatial object and the i bit of the m-bit binary number corresponding to the latitude mapping;
由高位到低位的顺序,将取出的该空间对象的i位经度和i位纬度交错排列,得到2i位的二进制序列,该2i位的二进制序列表示该空间对象在第i层中所属的网格的初始ID;From the high order to the low order, the i-bit longitude and i-bit latitude of the extracted spatial object are staggered to obtain a binary sequence of 2i bits, and the binary sequence of 2i bits represents the mesh to which the spatial object belongs in the i-th layer. Initial ID
将该空间对象的层级指示位和初始ID按照预设的组合规则进行组合,生成该空间对象在第i层中的二进制组合ID。The hierarchical indication bit and the initial ID of the spatial object are combined according to a preset combination rule to generate a binary combination ID of the spatial object in the i-th layer.
第三方面,与第一方面对应地,本发明还提供一种电子地图中查询空间对象的装置,所述装置包括:In a third aspect, corresponding to the first aspect, the present invention further provides an apparatus for querying a spatial object in an electronic map, the apparatus comprising:
获取模块,用于获取待查询空间对象的二进制组合ID,所述二进制组合ID中包括表示该待查询空间对象在空间索引中所属层级的层级指示位,以及表示该空间对象在该层级所属网格的初始ID;An obtaining module, configured to obtain a binary combination ID of the spatial object to be queried, where the binary combination ID includes a hierarchical indication bit indicating a hierarchy of the spatial object to be queried in the spatial index, and a grid indicating that the spatial object belongs to the hierarchy Initial ID
层级确定模块,用于根据二进制组合ID中的层级指示位,确定该待查询空间对象在空间索引中的所属层级;a hierarchy determining module, configured to determine, according to a hierarchical indication bit in the binary combination ID, a hierarchy of the spatial object to be queried in the spatial index;
网格确定模块,用于根据二进制组合ID中的初始ID,确定该待查询空间对象在层级指示位表示的层级中所属的网格;a grid determining module, configured to determine, according to an initial ID in the binary combination ID, a grid to which the to-be-queried spatial object belongs in a hierarchy indicated by the hierarchical indicator bit;
查询模块,用于在确定的网格中查询所述待查询空间对象。a query module, configured to query the to-be-queried spatial object in the determined grid.
第四方面,与第二方面对应地,本发明还提供一种电子地图中建立空间索引的装置,所述装置包括:In a fourth aspect, corresponding to the second aspect, the present invention further provides an apparatus for establishing a spatial index in an electronic map, the apparatus comprising:
经纬度表示模块,用于将电子地图所包含的经纬度范围分别映射到均用m位二进制数表示的整数范围,其中,已预先将每一层电子地图分割为地理空间范围相同的22i个网格,i表示每一层电子地图的层级,i的取值为1到N,且m为大于或等于N的正整数,,N为正整数;A latitude and longitude representation module for mapping the latitude and longitude ranges included in the electronic map to integer ranges each represented by an m-bit binary number, wherein each layer of the electronic map has been previously divided into 2 2i grids having the same geographical space range , i denotes the level of each layer of the electronic map, i takes a value from 1 to N, and m is a positive integer greater than or equal to N, and N is a positive integer;
经纬度确定模块,用于针对每一层中的每一个空间对象,确定该空间对象的经度对应映射的m位二进制数,以及该空间对象的纬度对应映射的m位 二进制数;a latitude and longitude determining module, configured to determine, for each spatial object in each layer, an m-bit binary number of the longitude corresponding mapping of the spatial object, and an m-bit corresponding to the latitude of the spatial object Binary number
取位模块,用于由高位到低位的顺序,从该空间对象的经度对应映射的m二进制数中取i位以及纬度对应映射的二进制数中取i位;The bit module is used for the order from the high bit to the low bit, and the i bit is taken from the m binary number of the longitude corresponding mapping of the spatial object and the i bit is taken from the binary number of the latitude corresponding mapping;
初始ID生成模块,用于由高位到低位的顺序,将取出的该空间对象的i位经度和i位纬度交错排列,得到2i位的二进制序列,该2i位的二进制序列表示该空间对象在第i层中所属的网格的初始ID;The initial ID generation module is configured to interleave the i-bit longitude and the i-bit latitude of the extracted spatial object in order from high to low, to obtain a binary sequence of 2i bits, and the binary sequence of the 2i bits indicates that the spatial object is in the first The initial ID of the grid to which the i layer belongs;
组合ID生成模块,用于将该空间对象的层级指示位和初始ID按照预设的组合规则进行组合,生成该空间对象在第i层中的二进制组合ID。The combined ID generation module is configured to combine the hierarchical indication bit and the initial ID of the spatial object according to a preset combination rule to generate a binary combination ID of the spatial object in the i-th layer.
本发明至少具有以下有益效果:通过对待分割电子地图建立空间索引,使得该空间索引中每层的空间对象都有一个二进制组合ID,使该二进制组合ID能够表示该待查询空间对象在空间索引中所属层级的层级指示信息,以及表示该空间对象在该层级中所属网格的初始ID,从而便于在查询空间对象时,能够根据二进制组合ID快速的确定空间对象所属的层级以及所属的网格,相对现有技术通过一个节点一个节点的方式去查询空间对象所属的网格的方法,能够提高查询效率。The present invention has at least the following beneficial effects: the spatial index is established by dividing the electronic map, so that the spatial object of each layer in the spatial index has a binary combination ID, so that the binary combination ID can represent the spatial object to be queried in the spatial index. The hierarchical level indication information of the hierarchical level, and the initial ID of the mesh to which the spatial object belongs in the hierarchy, so that when the spatial object is queried, the hierarchy to which the spatial object belongs and the associated mesh can be quickly determined according to the binary combination ID. Compared with the prior art, the method of querying the mesh to which the spatial object belongs by means of one node and one node can improve the query efficiency.
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本发明。The above general description and the following detailed description are intended to be illustrative and not restrictive.
附图说明DRAWINGS
图1为本发明实施例中的电子地图中查询空间对象的方法的示例性流程图;1 is an exemplary flowchart of a method for querying a spatial object in an electronic map according to an embodiment of the present invention;
图2为本发明实施例中电子地图中建立空间索引的方法的示例性流程图;2 is an exemplary flowchart of a method for establishing a spatial index in an electronic map according to an embodiment of the present invention;
图3a为本发明实施例中对全球电子地图,在经纬度方向各切分一次得到第一层中的4个网格的示意图;FIG. 3a is a schematic diagram of a global electronic map, which is divided into four grids in a first layer in a latitude and longitude direction according to an embodiment of the present invention; FIG.
图3b为本发明实施例中在图3a的基础上,得到对全球电子地图的第二层的16个网格的示意图;FIG. 3b is a schematic diagram showing 16 grids of the second layer of the global electronic map on the basis of FIG. 3a according to an embodiment of the present invention; FIG.
图4为本发明实施例中的对全球电子地图构建空间索引的示例性流程图; 4 is an exemplary flowchart of constructing a spatial index for a global electronic map according to an embodiment of the present invention;
图5为本发明实施例中利用构建的空间索引对待查询空间对象进行查询的过程的示例性流程图;FIG. 5 is an exemplary flowchart of a process for querying a query space object by using a constructed spatial index according to an embodiment of the present invention; FIG.
图6为本发明实施例中电子地图中查询空间对象的装置的示意图;6 is a schematic diagram of an apparatus for querying a spatial object in an electronic map according to an embodiment of the present invention;
图7为本发明实施例中电子地图中查询空间对象的装置的另一示意图;FIG. 7 is another schematic diagram of an apparatus for querying a spatial object in an electronic map according to an embodiment of the present invention; FIG.
图8为本发明实施例中电子地图中建立空间索引的装置的示意图;FIG. 8 is a schematic diagram of an apparatus for establishing a spatial index in an electronic map according to an embodiment of the present invention; FIG.
图9为本发明实施例中电子地图中建立空间索引的装置的另一示意图。FIG. 9 is another schematic diagram of an apparatus for establishing a spatial index in an electronic map according to an embodiment of the present invention.
具体实施方式detailed description
以下结合说明书附图对本发明的优选实施例进行说明,应当理解,此处所描述的优选实施例仅用于说明和解释本发明,并不用于限定本发明,并且在不冲突的情况下,本发明中的实施例及实施例中的特征可以相互组合。The preferred embodiments of the present invention are described in conjunction with the accompanying drawings, and the preferred embodiments described herein are intended to illustrate and explain the invention, and not to limit the invention, and The embodiments and the features in the embodiments can be combined with each other.
本发明实施例提供一种电子地图中查询空间对象的方法,在该方法提供的方案中,提供一种新型的电子地图的空间索引机制。具体的,预先将电子地图进行分割划分为多个层级,每一层级都表示一个完整的电子地图,每一层级都将电子地图划分为多份,每一份表示一个网格(可以理解为一个瓦片)。任一层级中的空间对象,在该层级中会隶属于该层中的一个网格。在本发明提供的空间索引机制中,每一个空间对象在每一层都有一个二进制组合ID,该二进制组合ID中包括了表示该待查询空间对象在空间索引中所属层级的层级指示位,以及表示该空间对象在该层级中所属网格的初始ID,从而在查询该空间对象时,无需像现有技术中逐节点的去查询。本发明可以根据待查询空间对象的二进制组合ID能够快速的定位到该待查询空间对象所属层级,以及所属层级中的所属网格,从而可以准确快速的定位该空间对象所属的网格,从而相对于现有技术能够加速查询空间对象的查询效率。The embodiment of the invention provides a method for querying a spatial object in an electronic map. In the solution provided by the method, a novel spatial indexing mechanism of the electronic map is provided. Specifically, the electronic map is divided into multiple levels in advance, each level represents a complete electronic map, and each level divides the electronic map into multiple copies, each of which represents a grid (can be understood as a Tile). A spatial object in any level in which it belongs to a mesh in that layer. In the spatial indexing mechanism provided by the present invention, each spatial object has a binary combination ID at each layer, and the binary combination ID includes a hierarchical indication bit indicating a hierarchy of the spatial object to be queried in the spatial index, and Indicates the initial ID of the grid to which the spatial object belongs in the hierarchy, so that when querying the spatial object, there is no need to query from node to node in the prior art. According to the binary combination ID of the spatial object to be queried, the present invention can quickly locate the hierarchy to which the spatial object to be queried belongs, and the mesh to which the affiliation belongs, so that the mesh to which the spatial object belongs can be accurately and quickly located, thereby The prior art can speed up the query efficiency of the query space object.
本发明中包括查询空间对象和建立空间索引两个方面,下面对这两个方面进行详细说明。The present invention includes two aspects of querying a spatial object and establishing a spatial index. These two aspects are described in detail below.
实施例一Embodiment 1
如图1所示,为本发明实施例中电子地图中查询空间对象的方法的示例 性流程图,该方法包括以下步骤:As shown in FIG. 1 , it is an example of a method for querying a spatial object in an electronic map according to an embodiment of the present invention. Sexual flow chart, the method includes the following steps:
步骤101:获取待查询空间对象的二进制组合ID,所述二进制组合ID中包括表示该待查询空间对象在空间索引中所属层级的层级指示位,以及表示该空间对象在该层级所属网格的初始ID。Step 101: Obtain a binary combination ID of a spatial object to be queried, where the binary combination ID includes a hierarchical indication bit indicating a hierarchy of the spatial object to be queried in the spatial index, and an initial representation of the mesh to which the spatial object belongs. ID.
其中,在一个实施例中,该待查询空间对象可以是一个空间实体,也可以是多个空间实体的集合,例如Poi(Point of Interest,兴趣点)。The space object to be queried may be a spatial entity or a set of multiple spatial entities, such as a Poi (Point of Interest).
步骤102:根据二进制组合ID中的层级指示位,确定该待查询空间对象在空间索引中的所属层级。Step 102: Determine, according to the hierarchical indicator bit in the binary combination ID, the belonging level of the spatial object to be queried in the spatial index.
其中,在一个实施例中,为便于操作和快速查询,步骤102可包括以下步骤:In one embodiment, for ease of operation and quick query, step 102 may include the following steps:
步骤A1:按照二进制组合ID从高位至低位的顺序,从所述二进制组合ID中确定出第一个赋值为1的位,所述第一个赋值为1的位为所述二进制组合ID中表示待查询空间对象在空间索引中的所属层级的层级指示位。Step A1: determining, according to the binary combination ID, the first bit assigned to 1 from the binary combination ID, the first bit assigned a value of 1 is represented in the binary combination ID The hierarchical indication bit of the hierarchy to which the spatial object to be queried belongs in the spatial index.
步骤A2:确定所述二进制组合ID中第一个赋值为1的位之后的总位数,该总位数为所述初始ID的总位数。Step A2: Determine the total number of bits after the first bit in the binary combination ID assigned to 1, the total number of bits being the total number of bits of the initial ID.
步骤A3:用该总位数除以2得到该空间对象的所属层级。Step A3: Divide the total number of bits by 2 to obtain the belonging level of the spatial object.
由此实现了根据二进制组合ID快速的确定空间对象的所属层级。而不必像现有技术中要通过逐节点去查询,从而提高了查询效率。This makes it possible to quickly determine the hierarchy of the spatial object from the binary combination ID. It is not necessary to query by node-by-node as in the prior art, thereby improving query efficiency.
步骤103:根据二进制组合ID中的初始ID,确定该待查询空间对象在层级指示位表示的层级中所属的网格。Step 103: Determine, according to the initial ID in the binary combination ID, the mesh to which the to-be-queried spatial object belongs in the hierarchy indicated by the hierarchical indicator bit.
步骤104:在确定的网格中查询所述待查询空间对象。Step 104: Query the to-be-queried spatial object in the determined grid.
其中,在一个实施例中,在二进制组合ID的最高位前面还有一位符号位。例如当二进制组合ID表示正数时,该符号位为0,当二进制组合ID表示负数时,该符号位为1。Therein, in one embodiment, there is one more sign bit in front of the most significant bit of the binary combination ID. For example, when the binary combination ID indicates a positive number, the sign bit is 0, and when the binary combination ID indicates a negative number, the sign bit is 1.
本发明实施例实现根据二进制组合ID中层级指示位定位查询的层级,通过初始ID定位待查询空间对象所属的网格,从而相对于现有技术逐节点的查询方法能够快速的定位待查询空间对象所属的网格,以便于加快查询空间对 象的速度,从而能够提高空间对象的查询效率。The embodiment of the present invention implements the hierarchical level of the query according to the hierarchical indication bit in the binary combination ID, and locates the mesh to which the spatial object to be queried belongs by using the initial ID, so that the query method can quickly locate the spatial object to be queried relative to the prior art node-by-node query method. Grid to help speed up query space The speed of the image, which can improve the query efficiency of the spatial object.
实施例二Embodiment 2
该实施例用于对空间索引的建立方法进行详细说明,如图2所示,为本发明实施例中电子地图中建立空间索引的方法的示例性流程图,该方法包括以下步骤:This embodiment is used to describe a method for establishing a spatial index. As shown in FIG. 2, it is an exemplary flowchart of a method for establishing a spatial index in an electronic map according to an embodiment of the present invention. The method includes the following steps:
步骤201:将电子地图所包含的经纬度范围分别映射到均用m位二进制数表示的整数范围,其中,已预先将每一层电子地图分割为地理空间范围相同的22i个网格,i表示每一层电子地图的层级,i的取值为1到N,且m为大于或等于N的正整数,N为正整数。Step 201: Map the latitude and longitude ranges included in the electronic map to integer ranges each represented by an m-bit binary number, wherein each layer of the electronic map has been previously divided into 2 2i grids having the same geographical space range, and i represents For each level of the electronic map, i takes a value from 1 to N, and m is a positive integer greater than or equal to N, and N is a positive integer.
步骤202:针对每一层中的每一个空间对象,确定该空间对象的经度对应映射的m位二进制数,以及该空间对象的纬度对应映射的m位二进制数。Step 202: Determine, for each spatial object in each layer, an m-bit binary number of the longitude corresponding mapping of the spatial object, and an m-bit binary number of the latitude corresponding mapping of the spatial object.
步骤203:由高位到低位的顺序,从该空间对象的经度对应映射的m位二进制数中取i位以及纬度对应映射的m位二进制数中取i位。Step 203: Taking the order of the high order to the low order, taking the i bit from the m bit binary number of the longitude corresponding mapping of the spatial object and the i bit of the m bit binary number corresponding to the latitude mapping.
步骤204:由高位到低位的顺序,将取出的该空间对象的i位经度和i位纬度交错排列,得到2i位的二进制序列,该2i位的二进制序列表示该空间对象在第i层中所属的网格的初始ID。Step 204: The high-order to low-order order is used to interleave the extracted i-bit longitude and i-bit latitude of the spatial object to obtain a binary sequence of 2i bits, and the binary sequence of 2i bits indicates that the spatial object belongs to the i-th layer. The initial ID of the grid.
步骤205:将该空间对象的层级指示位和初始ID按照预设的组合规则进行组合,生成该空间对象在第i层中的二进制组合ID。Step 205: Combine the hierarchical indication bit and the initial ID of the spatial object according to a preset combination rule to generate a binary combination ID of the spatial object in the i-th layer.
下面通过以下1)-4)中的内容对上述各步骤进行详细说明:The above steps are described in detail below by the contents of 1)-4):
1)、在步骤201中:1) In step 201:
其中,在一个实施例中,当电子地图为全球电子地图时,可以将全球电子地图划分为1至15层,每一层为一个层级。Wherein, in one embodiment, when the electronic map is a global electronic map, the global electronic map can be divided into 1 to 15 layers, and each layer is a level.
其中,对步骤201中所述的每一层电子地图分割为地理空间范围相同的22i个网格进行举例说明:例如在第15层中,将全球电子地图划分为经纬度范围均相同的230等份。例如如图3a所示,在第一层中,将全球电子地图,在纬度方向上进行切分,并在经度方向上进行切分,得到四个网格。图中的编号为二进制数,表示网格的在该层的初始ID(以下图3b中编号的含义相同, 以后不再赘述);第二层的形成过程如下:如图3b所示,在图3a的基础上,将图3a中的每个网格在纬度方向和经度方向各进行一次切分,使得图3a中的每个网格被分割成4个。因此,在第二层中,共有16个网格。以此类推,第i层中的网格,是将第i-1层中的每个网格切分成4份之后得到的。需要说明的是,无论在第几层中,先从纬度方向切分网格再从经度方向切分网格,或者先从经度方向切分网格在从纬度方向切分网格,亦或者同时从纬度和经度方向切分网格,在本发明实施例中均适用,本发明对此不做限定。Wherein, each layer of the electronic map described in step 201 is divided into 2 2i grids having the same geographical space range: for example, in the 15th layer, the global electronic map is divided into 2 30 with the same latitude and longitude range. Equals. For example, as shown in FIG. 3a, in the first layer, the global electronic map is segmented in the latitude direction and segmented in the longitude direction to obtain four meshes. The number in the figure is a binary number, indicating the initial ID of the layer in the layer (the meanings of the numbers in the following figure are the same in Figure 3b, and will not be described later); the formation process of the second layer is as follows: as shown in Figure 3b, in the figure On the basis of 3a, each grid in Fig. 3a is divided once in the latitude direction and the longitude direction, so that each grid in Fig. 3a is divided into four. Therefore, in the second layer, there are 16 grids in total. By analogy, the grid in the i-th layer is obtained by cutting each grid in the i-th layer into four parts. It should be noted that, in the first few layers, the mesh is first cut from the latitude direction and then the mesh is cut from the longitude direction, or the mesh is first cut from the longitude direction to divide the mesh from the latitude direction, or simultaneously The singularity of the mesh from the latitude and longitude directions is applicable to the embodiments of the present invention, which is not limited by the present invention.
其中,在一个实施例中,m取值为31,N的取值为15。对于全球电子地图,由于地球的周长约为4万千米,则在第15层中每个网格所表示的地理范围约为1.8cm,可以表示的最小空间对象的地理范围为1.82cm2,进而能够足够精确表示空间对象的位置。Wherein, in one embodiment, m has a value of 31 and N has a value of 15. For global electronic maps, since the circumference of the Earth is about 40,000 kilometers, the geographic range represented by each grid in the 15th layer is about 1.8cm, and the minimum spatial object that can be represented has a geographical range of 1.8 2 cm 2 . In turn, it is possible to accurately represent the position of the spatial object.
其中,m位二进制数表示的整数范围,用自然数的范围表示是[0,2m-1],如1位二进制数能够表示的最大整数为21-1=1,共表示0、1共2(即21)个整数;2位二进制数能够表示的最大整数为22-1=3,共表示0、1、2、3共4(即22)个整数。依此类推,m位二进制数能够表示的最大整数为22-1,共表示2m个整数。而电子地图经度用m位二进制数表示,纬度也用m位二进制数,则经纬度结合起来共能够表示2m*2m=22m个整数。针对电子地图的每一层,为了使该层的网格和初始ID是一一对应关系,即每个网格对应一个初始ID,每个初始ID对应一个网格,则经纬度结合起来能够表示的整数的个数必须大于等于网格的个数(即22m≥22i),故此针对第i层,m≥i。电子地图共有N层,即i的最大取值为N,故此,m≥N。Wherein, the integer range represented by the m-bit binary number is represented by the range of the natural number [0, 2 m -1], for example, the largest integer that can be represented by the 1-bit binary number is 2 1 -1=1, which represents a total of 0, 1 2 (ie, 2 1 ) integers; the largest integer that a 2-bit binary number can represent is 2 2 -1=3, which represents a total of 4 (ie, 2 2 ) integers of 0, 1, 2 , and 3. By analogy, the largest integer that can be represented by an m-bit binary number is 2 2 -1, which represents a total of 2 m integers. The longitude of the electronic map is represented by m-bit binary numbers, and the latitude is also m-bit binary number. The combination of latitude and longitude can represent 2 m *2 m = 2 2m integers. For each layer of the electronic map, in order to make the grid of the layer and the initial ID have a one-to-one correspondence, that is, each grid corresponds to an initial ID, and each initial ID corresponds to a grid, then the latitude and longitude can be combined. The number of integers must be greater than or equal to the number of grids (ie, 2 2m ≥ 2 2i ), so for the ith layer, mi . The electronic map has a total of N layers, that is, the maximum value of i is N, so m ≥ N.
对于将电子地图的经度映射到m位二进制数表示的整数范围,例如是,当N取值为15,m取值为31时,若电子地图的经度范围为[0,90]则用31位二进制数表示的最小整数即31个0表示最小经度(即经度为0),用31位二进制数表示的最大整数即31个1表示最大经度(即经度为90);同理,对于将电子地图的纬度映射到m位二进制数表示的整数范围,例如是,当N取值为15,m取值为31时,若电子地图的纬度范围为[0,90],则用31位二进制数 表示的最小整数即31个0表示最小纬度(即纬度为0),用31位二进制数表示的最大整数即31个1表示最大纬度(即纬度为90)。For mapping the longitude of the electronic map to the integer range represented by the m-bit binary number, for example, when N is 15 and m is 31, if the longitude range of the electronic map is [0, 90], 31 bits are used. The smallest integer represented by a binary number, that is, 31 zeros represents the minimum longitude (ie, the longitude is 0), and the largest integer represented by a 31-bit binary number, that is, 31, represents the maximum longitude (ie, the longitude is 90); for the same reason, for the electronic map The latitude is mapped to the integer range represented by the m-bit binary number. For example, when N is 15 and m is 31, if the latitude of the electronic map is [0, 90], the 31-bit binary is used. The smallest integer represented, that is, 31 zeros represents the minimum latitude (ie, the latitude is 0), and the largest integer represented by the 31-bit binary number, that is, 31, represents the maximum latitude (ie, the latitude is 90).
2)、在步骤203中:2) In step 203:
其中,在一个实施例中,当对全球电子地图划分为15层时,m取值为31时,即全球电子地图的经纬度各为31位的二进制数。若第5层中的一个空间对象B的经度坐标为“1111111 11111111 11111111 11111110”(其中高位到低位的方向为从左到右的方向),该空间对象B的纬度坐标为“0111111 11111111 11111111 11111110”,则取该空间对象的经度的高5位为“11111”,取该空间对象的纬度高5位为“01111”。Wherein, in one embodiment, when the global electronic map is divided into 15 layers, the value of m is 31, that is, the latitude and longitude of the global electronic map are each a 31-bit binary number. If the longitude coordinate of a spatial object B in the fifth layer is "1111111 11111111 11111111 11111110" (where the direction from the high to the low is from left to right), the latitude coordinate of the spatial object B is "0111111 11111111 11111111 11111110" Then, the upper 5 bits of the longitude of the spatial object are "11111", and the latitude of the spatial object is 5 bits higher than "01111".
其中,假设最大的经度或纬度取整后转换为二进制数后为m位,则m位的二进制数能够完全表示实际的经纬度的数值,这时候m位二进制数表示的就是实际的取整数部分的经纬度。Among them, assuming that the maximum longitude or latitude is rounded to a binary number and then m bits, the m-bit binary number can fully represent the actual latitude and longitude value. At this time, the m-bit binary number represents the actual integer part. Latitude and longitude.
假若m位二进制数不能够表示实际的经纬度,则对每一个空间对象需要求得对应映射的m位二进制数。以求得经度对应映射的m位二进制数为例,一种最简单的求解方法例如是,确定空间对象的实际经度与最大经度的比例,该比例即是该经度的对应映射的m位二进制数与最大的m位二进制之间的比例,而最大的m位二进制数是确定的,比例是确定的,则该经度对应映射的m位二进制数是可求解的。当然,通过其他的数学方法确定对应映射的m位二进制数也适用于本发明实施例,本发明对此不做限定。If the m-bit binary number cannot represent the actual latitude and longitude, then the corresponding mapped m-bit binary number is required for each spatial object. Taking the m-bit binary number of the longitude-corresponding mapping as an example, one of the simplest solving methods is, for example, determining the ratio of the actual longitude of the spatial object to the maximum longitude, which is the m-bit binary number of the corresponding mapping of the longitude. The ratio between the maximum m-bit binary and the largest m-bit binary is determined, and the ratio is determined, and the long-term corresponding mapped m-bit binary number is solvable. Certainly, the m-bit binary number of the corresponding mapping is determined by other mathematical methods, and is also applicable to the embodiment of the present invention, which is not limited by the present invention.
3)、在步骤204中:3) In step 204:
例如,空间对象的纬度的高3位二进制数为“C1C2C3”,经度的高3位二进制数为“D1D2D3”,则先从经度开始,交错排列后得到的6位二进制序列应该为“D1C1D2C2D3C3”。则前述空间对象B在第5层中的10位二进制序列应为“1011111111”,换算为十进制数则为767(即本发明实施例中可以用十进制数表示空间对象B在第5层中所属网格的初始ID为767)。当然,也可以先从纬度方向开始交错排列,本发明对此不做限定。For example, the high 3-bit binary number of the latitude of the spatial object is "C 1 C 2 C 3 ", and the high 3-bit binary number of the longitude is "D 1 D 2 D 3 ", which is obtained from the longitude and then staggered. The 6-bit binary sequence should be "D 1 C 1 D 2 C 2 D 3 C 3 ". Then, the 10-bit binary sequence of the space object B in the fifth layer should be "1011111111", and the decimal number is 767 (that is, in the embodiment of the present invention, the decimal object can be used to represent the network object B in the layer 5 The initial ID of the grid is 767). Of course, the staggered arrangement may be started from the latitude direction, which is not limited by the present invention.
通过交错排列该空间对象的经度的高i位和纬度的高i位,可以根据初始 ID,快速、明确地确定层级之间的父子关系。例如初始ID为101101(共6位二进制数)。该网格是由上一层(即第二层)的初始ID为1011的网格的基础上分割来的,其中的原理先通过一个简单的例子进行说明,例如对于同一空间对象在每一层中它的经度的m位二进制数均相同,则在第二层,由高位到低位的顺序取的4位二进制数,在第三层同样是由高位到低位的顺序取的6位二进制数,则这6位二进制数的后2位的顺序正好在第二层的4位二进制数之后的两位二进制数,因此第三层中6位二进制数的前4位正好为第二层中的4位二进制数,即同样都是一个空间对象不同层级中仅需要不同的位数表示而已。同理,在第i层中,空间对象在该层的初始ID是经度和纬度的高i位交错排列得来的,因此在最低层(第N层)的初始ID的位数最多为2N位,对于同一空间对象其在最低层的初始ID仅有一个,只不过每一层选取2N位的初始ID的高2i位来使用。基于上述简单的例子,可知,一个空间对象的总位数的初始ID表征了该空间对象在每一层中所属的网格,空间对象在第三层的初始ID为101101的网格中,同时该空间对象在第二层的初始ID为1011的网格中。而空间对象在电子地图中的位置是固定的,根据电子地图的划分机制,上一层网格表示的范围大于下一层网格所表示的范围,因此初始ID为101101的网格是由初始ID为1011的网格划分而来,这一点是由划分电子地图和为网格建立初始ID的机制中可以直接推断出来。同理,在第二层中初始ID为1011的网格又是在第一层中初始ID为10的网格分割而来的。可见,在初始ID中网格之间的父子关系非常容易辨识和判断。By staggering the high i-bit of the longitude of the spatial object and the high i-bit of the latitude, according to the initial ID, quickly and unambiguously determine the parent-child relationship between levels. For example, the initial ID is 101101 (a total of 6 binary digits). The grid is segmented based on the grid of the previous layer (ie, the second layer) with an initial ID of 1011. The principle is first explained by a simple example, for example, the same spatial object is in each layer. Where the m-bit binary numbers of its longitude are the same, then in the second layer, the 4-bit binary number taken from the high-order to the low-order order, and the third-level binary-number in the third layer is also taken from the high-order to the low-order. Then the order of the last 2 bits of the 6-bit binary number is exactly the two-digit binary number after the 4-bit binary number of the second layer, so the first 4 bits of the 6-bit binary number in the third layer are exactly 4 in the second layer. Bit binary numbers, which are also a spatial object, require only a different number of bits in different levels. Similarly, in the i-th layer, the initial ID of the spatial object in the layer is staggered by the high i-bit of longitude and latitude, so the initial ID of the lowest layer (the Nth layer) has a maximum of 2N bits. For the same spatial object, there is only one initial ID at the lowest layer, except that each layer selects the high 2i bit of the initial ID of 2N bits for use. Based on the above simple example, it can be seen that the initial ID of the total number of bits of a spatial object represents the mesh to which the spatial object belongs in each layer, and the spatial object is in the mesh with the initial ID of 101101 in the third layer. The spatial object is in the grid of the second layer with an initial ID of 1011. The position of the spatial object in the electronic map is fixed. According to the division mechanism of the electronic map, the range represented by the upper layer of the grid is larger than the range represented by the grid of the next layer, so the grid with the initial ID of 101101 is initialized. The mesh with the ID of 1011 is derived from the mechanism of dividing the electronic map and establishing the initial ID for the mesh. Similarly, the mesh with the initial ID of 1011 in the second layer is again divided into meshes with an initial ID of 10 in the first layer. It can be seen that the parent-child relationship between the grids in the initial ID is very easy to identify and judge.
此外,当在电子地图表示的地理范围内,有新的空间对象需要加入索引时,可以根据该空间对象的经纬度直接生成并存储该新增空间对象的二进制组合ID。而不必像现有技术中,要为对应的每个节点繁琐地生成该空间对象标识,从而本发明实施例有利于简单快速的进行空间索引。In addition, when a new spatial object needs to be added to the index within the geographical range represented by the electronic map, the binary combination ID of the newly added spatial object may be directly generated and stored according to the latitude and longitude of the spatial object. It is not necessary to generate the spatial object identifier cumbersomely for each corresponding node as in the prior art, so that the embodiment of the present invention facilitates simple and fast spatial indexing.
4)、在步骤205中:4) In step 205:
通过对电子地图进行分割,根据空间对象的经纬度坐标生成该空间对象所在网格的初始ID,该初始ID能够明确的表示网格之间的上下级关系,此外, 通过初始ID将经纬度坐标与网格的关联起来,便于在查询空间对象时,通过初始ID便能够快速的定位空间对象所在的网格。通过将层级信息加入初始ID中生成二进制组合ID,以便于二进制组合ID能够表示空间对象所属层级,也能够将空间对象所在网格的所属层级表示出来,以便于快速确定在哪个层级中确定该空间对象所属的网格。例如,一个空间对象在多个层级中时,通过二进制组合ID的层级位可以快速的确定在哪个层级中查询该空间对象所属的网格。比如:二进制组合ID为01101101(共8位二进制数),层级位为第一个不为0的位,则该二进制组合ID的层级位在从低位到高位数的第7个(设此位数为第X位),则空间对象所属的网格位于第3层,即:层级等于(7-1)除以2。可以看出:层级i与X的关系:X=2i+1。By segmenting the electronic map, an initial ID of the mesh in which the spatial object is located is generated according to the latitude and longitude coordinates of the spatial object, and the initial ID can clearly indicate the relationship between the upper and lower levels of the mesh, and The latitude and longitude coordinates are associated with the grid by the initial ID, so that when the spatial object is queried, the grid of the spatial object can be quickly located by the initial ID. The binary combination ID is generated by adding the hierarchical information to the initial ID, so that the binary combination ID can represent the hierarchy to which the spatial object belongs, and the hierarchical level of the mesh in which the spatial object is located can also be represented, so as to quickly determine in which hierarchy the space is determined. The grid to which the object belongs. For example, when a spatial object is in multiple levels, the hierarchical bits of the binary combination ID can quickly determine in which level the grid to which the spatial object belongs is queried. For example, if the binary combination ID is 01101101 (a total of 8 binary numbers) and the level bit is the first bit that is not 0, then the level of the binary combination ID is 7th from the low to the high digit (this bit is set) For the Xth bit), the mesh to which the spatial object belongs is at level 3, ie the level is equal to (7-1) divided by 2. It can be seen that the relationship between level i and X: X = 2i + 1.
其中,在一个实施例中,步骤205可以实施为以下步骤:Wherein, in an embodiment, step 205 can be implemented as the following steps:
步骤B1:在初始ID对应的二级制序列的最高位前增加一个表示层级指示位的比特bit位,将该bit位取值设为1。Step B1: Add a bit bit indicating the level indication bit before the highest bit of the secondary sequence corresponding to the initial ID, and set the value of the bit to 1.
步骤B2:若层级指示位和初始ID构成的二级制序列的位数少于二进制组合ID的预设位数,则在所述层级指示位前增加L个bit位,并将所述L个bit位取值设为0,所述L等于所述预设位数减去所述层级指示位和初始ID所占用的位数之后剩余的位数。Step B2: If the number of bits of the secondary sequence formed by the hierarchical indicator bit and the initial ID is less than the preset number of bits of the binary combination ID, then L bits are added before the level indication bit, and the L bits are The bit bit value is set to 0, and the L is equal to the preset number of bits minus the number of bits remaining after the level indicator bit and the number of bits occupied by the initial ID.
其中,较佳的,每一层的预设位数可以不同,每一层的预设位数为能包含该层的初始ID的8的整数倍,例如某一层的初始ID为6位,初始ID的总位数加层级指示位后一共为7位,则该层的预设位数为8位;若某一层的初始ID为8位,初始ID的总位数加层级指示位后一共为9位,则该层的预设位数为16位;若某一层的初始ID为10位,初始ID的总位数加层级指示位后一共为11位,则该层的预设位数为16位。当然,可以根据实际需要将预设位数设置为一个固定的值,例如将待分割电子地图分割为15层,且表示经度和纬度各用31位二进制数表示时,则第15层的初始ID的位数最多为30位(15+15),因此为了能够包含30位二进制数,可以将预设位数设置为32位;再例如,将待分割电子地图分割为31层,且表示经度和纬度各用31位 二进制数表示时,则第31层的初始ID的位数最多为62位(31+31),因此为了能够包含62位二进制数,可以将预设位数设置为64位。Preferably, the preset number of bits in each layer may be different, and the preset number of bits in each layer is an integer multiple of 8 which can include the initial ID of the layer, for example, the initial ID of a layer is 6 bits. The total number of bits of the initial ID plus the level indicator bit is 7 bits in total, then the preset number of bits in the layer is 8 bits; if the initial ID of a layer is 8 bits, the total number of bits of the initial ID plus the level indicator bit A total of 9 bits, the default number of bits in the layer is 16 bits; if the initial ID of a layer is 10 bits, the total number of bits of the initial ID plus the level indicator is a total of 11 bits, then the preset of the layer The number of digits is 16 bits. Of course, the preset number of bits can be set to a fixed value according to actual needs, for example, the electronic map to be divided is divided into 15 layers, and the longitude and latitude are represented by 31-bit binary numbers, and the initial ID of the 15th layer is The number of digits is up to 30 bits (15+15), so in order to be able to contain 30-bit binary numbers, the preset number of bits can be set to 32 bits; for example, the electronic map to be divided is divided into 31 layers, and the longitude and Latitude is 31 bits each When the binary number is expressed, the initial ID of the 31st layer has a maximum of 62 bits (31+31), so in order to be able to include a 62-bit binary number, the preset number of bits can be set to 64 bits.
例如对空间对象B的初始ID的10位序列“0111100111”前面增加一个表示层级指示位的bit位,并将该bit位取值设为1后,得到11位二进制序列“10111100111”,预设位数为16位时,则在所述层级指示位前增加16-11既5个bit位,将这5个bit位置0后,得到最后的二进制组合ID为“0000010111100111”,至此生成了二进制组合ID。For example, by adding a bit indicating the level indicating bit to the 10-bit sequence "0111100111" of the initial ID of the spatial object B, and setting the bit value to 1, an 11-bit binary sequence "10111100111" is obtained, and the preset bit is obtained. When the number is 16 bits, then 16-11 and 5 bit bits are added before the level indication bit. After the 5 bit positions are 0, the final binary combination ID is "0000010111100111", and the binary combination ID is generated. .
此外,在一个实施例中,为了满足编程的需要,在二进制组合ID的最高位前面增加一位符号位。例如当二进制组合ID表示正数时,并将符号位置0,当二进制组合ID表示负数时,将符号位置1。Moreover, in one embodiment, to accommodate programming needs, a one-bit sign bit is added before the most significant bit of the binary combination ID. For example, when the binary combination ID indicates a positive number, and the symbol position is 0, when the binary combination ID indicates a negative number, the symbol position is set to 1.
通过上述生成二进制组合ID的过程,使得二进制组合ID能够包含空间对象对应的层级信息以及空间对象所属网格的信息,以便于能够快速在建立的空间索引中查询到该空间对象所属的网格。以便于进行后续操作,例如渲染该空间对象所在的网格,或者根据该空间对象的经纬度坐标,在电子地图中精确的渲染该空间对象所在的位置。Through the process of generating the binary combination ID, the binary combination ID can include the hierarchical information corresponding to the spatial object and the information of the mesh to which the spatial object belongs, so that the mesh to which the spatial object belongs can be quickly queried in the established spatial index. For subsequent operations, such as rendering the grid in which the spatial object is located, or accurately rendering the location of the spatial object in the electronic map according to the latitude and longitude coordinates of the spatial object.
综上,本发明实施例通过对电子地图建立空间索引,使得该空间索引中每层的空间对象都有一个二进制组合ID,使该二进制组合ID能够表示该待查询空间对象在空间索引中所属层级的层级指示位,以及表示该空间对象在该层级中所属网格的初始ID,从而便于在查询空间对象时,能够根据二进制组合ID快速的确定空间对象所属的层级以及所属的网格,进而相对现有技术通过一个节点一个节点的方式去查询空间对象所属的网格的方法,能够提高查询效率。In summary, the embodiment of the present invention establishes a spatial index on the electronic map, so that the spatial object of each layer in the spatial index has a binary combination ID, so that the binary combination ID can represent the hierarchy of the spatial object to be queried in the spatial index. The hierarchical indicator bit, and the initial ID of the mesh to which the spatial object belongs in the hierarchy, so that when the spatial object is queried, the hierarchy to which the spatial object belongs and the associated mesh can be quickly determined according to the binary combination ID, and thus the relative In the prior art, a method of querying a mesh to which a spatial object belongs by means of a node and a node can improve query efficiency.
下面通过一个简单的实施例,对本发明实施例中在电子地图中查询空间对象的方法进行详细说明。The method for querying a spatial object in an electronic map in the embodiment of the present invention is described in detail below through a simple embodiment.
实施例三Embodiment 3
以大厦A为待查询空间对象,在上述建立的空间索引中查询该空间对象,定位该空间对象所属的网格,并渲染定位后的网格为例,对本发明实施例中 在电子地图中查询空间对象的方法进行详细说明,该方法包括前期预先构建空间索引的过程,和后期利用该构建的空间索引对移动终端进行定位的过程:The building A is used as the object to be queried, and the space object is queried in the space index, and the mesh to which the space object belongs is located, and the mesh after the positioning is rendered as an example. The method for querying a spatial object in an electronic map is described in detail. The method includes a process of pre-constructing a spatial index in advance, and a process of locating a mobile terminal by using the spatial index of the construct in the later stage:
其中,首先对预先构建空间索引的过程进行说明,以对全球电子地图构建空间索引为例进行说明,如图4所示,包括以下步骤:First, the process of pre-constructing the spatial index is described to illustrate the construction of the spatial index of the global electronic map, as shown in FIG. 4, including the following steps:
步骤401:将全球电子地图分割为15层,在每一层中将全球电子地图分割为地理空间范围均相同的22i等份,其中,每一层为一个层级,i表示层级。Step 401: The global electronic map is divided into 15 layers, and the global electronic map is divided into 2 2i equal parts in the same geographical space in each layer, wherein each layer is a level, and i represents a level.
步骤402:将全球电子地图所包含的经纬度范围分别映射到均用31位二进制数表示的整数范围。Step 402: Map the latitude and longitude ranges included in the global electronic map to integer ranges each represented by a 31-bit binary number.
其中,步骤402可以理解为将全球的经纬度分别进行量化,使量化后该待分割电子地图的最小经度至最大经度之间的取值范围、以及最小纬度至最大纬度之间的取值范围均为[0,231-1],并用31位数的二进制数分别表示该待分割电子地图的经度和纬度。The step 402 can be understood as that the global latitude and longitude are respectively quantized, so that the range between the minimum longitude and the maximum longitude of the electronic map to be divided after quantization and the range between the minimum latitude and the maximum latitude are both [0, 2 31 -1], and the longitude and latitude of the electronic map to be divided are respectively represented by a 31-digit binary number.
步骤403:针对第i层中的每一个空间对象,确定该空间对象的经度对应映射的31位二进制数,以及该空间对象的纬度对应映射的31位二进制数。Step 403: For each spatial object in the i-th layer, determine a 31-bit binary number of the longitude-corresponding mapping of the spatial object, and a 31-bit binary number of the latitude-corresponding mapping of the spatial object.
步骤404:由高位到低位的顺序,从该空间对象的经度对应映射的31位二进制数中取i位以及纬度对应映射的31位二进制数中取i位。Step 404: From the order of the high order to the low order, the i bit is taken from the 31-bit binary number of the longitude corresponding map of the spatial object and the 31 bit binary number of the latitude corresponding map is taken.
步骤405:由高位到低位的顺序,将取出的该空间对象的i位经度和i位纬度交错排列,得到2i位的二进制序列,该2i位的二进制序列表示该空间对象在第i层中所属的网格的初始ID。Step 405: The order of the i-bit longitude and the i-bit latitude of the extracted spatial object are staggered from the high order to the low order to obtain a binary sequence of 2i bits, and the binary sequence of the 2i bits indicates that the spatial object belongs to the i-th layer. The initial ID of the grid.
步骤406:在初始ID对应的二级制序列的最高位前增加一个表示层级指示位的bit位,将该bit位取值设为1。Step 406: Add a bit indicating the level indication bit before the highest bit of the secondary sequence corresponding to the initial ID, and set the value of the bit to 1.
步骤407:若层级指示位和初始ID构成的二级制序列的位数少于二进制组合ID的预设位数即31位,则在所述层级指示位前增加L个bit位,并将所述L个bit位取值设为0,所述L等于所述预设位数31减去所述层级指示位和初始ID所占用的位数之后剩余的位数。Step 407: If the number of bits of the secondary sequence formed by the hierarchical indicator bit and the initial ID is less than the preset number of bits of the binary combination ID, that is, 31 bits, then L bits are added before the level indication bit, and The L bit bits take the value set to 0, and the L is equal to the preset number of bits 31 minus the number of bits remaining after the level indicator bit and the number of bits occupied by the initial ID.
步骤408:在二进制组合ID最高位前面增加一位用作符号位,生成带有符号位的二进制组合ID。 Step 408: Add a bit in front of the highest bit of the binary combination ID as a sign bit to generate a binary combination ID with a sign bit.
下面介绍利用构建的空间索引查询大厦A所属的网格的过程,如图5所示,包括以下步骤:The following describes the process of querying the grid to which Building A belongs by using the constructed spatial index, as shown in Figure 5, including the following steps:
步骤501:获取大厦A的经纬度。Step 501: Acquire the latitude and longitude of the building A.
步骤502:根据大厦A的经纬度,并根据步骤403-步骤408生成大厦A在全球电子地图的第15层中的带有符号位的二进制组合ID。Step 502: According to the latitude and longitude of the building A, and according to step 403-step 408, the binary combination ID of the signed bit of the building A in the 15th layer of the global electronic map is generated.
其中,步骤502中生成第15层的带有符号位的二进制组合ID,该带有符号位的二进制组合ID具有所有层的层级关系,便于以后在其他层级中定位该大厦A使用。Wherein, in step 502, a binary combination ID of the 15th layer with a sign bit is generated, and the binary combination ID with the sign bit has a hierarchical relationship of all layers, so that the building A can be located in other levels later.
当然,步骤502中仅为举例说明生成在第15层的带有符号位的二进制组合ID,并不用于限定本发明。可以根据实际需要设定在第几层中查询该大厦A以便于生成该层的带有符号位的二进制组合ID。例如可以根据用户设置的地图比例尺,确定在第几层中显示大厦A。例如用户设置的比例尺足够大,则可以确定在第15层中,显示大厦A,则生成第15层的大厦A的带有符号位的二进制组合ID;若用户设置的比例尺为足够小,则可以确定在第1层中显示大厦A,则生成第1层的大厦A的带有符号位的二进制组合ID。Of course, the binary combination ID with the sign bit generated at the 15th layer is only illustrated in step 502, and is not intended to limit the present invention. The building A can be queried in the first layer according to actual needs in order to generate a binary combination ID of the signed bit of the layer. For example, it is determined that the building A is displayed in the first floor according to the map scale set by the user. For example, if the scale set by the user is large enough, it can be determined that in the 15th floor, the building A is displayed, and the binary combination ID of the symbol A of the building A of the 15th floor is generated; if the scale set by the user is small enough, When it is determined that the building A is displayed in the first floor, the binary combination ID with the sign bit of the building A of the first floor is generated.
步骤503:根据大厦A的带有符号位的二进制组合ID,确定大厦A在全球电子地图的第15层中所属的网格,并在该网格中确定大厦A的位置。Step 503: Determine the grid to which the building A belongs in the 15th floor of the global electronic map according to the binary combination ID of the sign A of the building A, and determine the position of the building A in the grid.
步骤504:渲染大厦A在全球电子地图的第15层中所属的网格,并渲染该移动终端在该网格中的位置。Step 504: Render the grid to which the building A belongs in the 15th layer of the global electronic map, and render the location of the mobile terminal in the grid.
步骤505:根据用户执行的选择第10层的选择操作,确定用户要求渲染该移动终端在第10层中所属的网格。Step 505: According to the selection operation of the 10th layer selected by the user, it is determined that the user requests to render the grid to which the mobile terminal belongs in the 10th layer.
步骤506:根据该移动终端在全球电子地图的第15层中的带有符号位的二进制组合ID中的初始ID,确定该移动终端在第10层中的二进制组合ID。Step 506: Determine the binary combination ID of the mobile terminal in the 10th layer according to the initial ID of the mobile terminal in the binary combination ID with the sign bit in the 15th layer of the global electronic map.
其中,在前述构建的空间索引中,带有符号位的二进制组合ID都用32位表示,若大厦A在第15层中的带有符号位的二进制组合ID为“01000101 11111111 11111111 11111111,其中最高位0为符号位表示为正数,则从高位开始数第3位到第22位为大厦A在第10层中的初始ID即“000101 11111111  111111”(即带有符号位的二进制组合ID中由高位到低位的顺序后30位表示的是在第15层的初始ID,第15层的初始ID的前20位为在第10层的初始ID)。按照前述步骤B1-B2的方法,将大厦A在第10层中的初始ID的高位前增加一位表示层级指示位,并将该位置1,然后生成二进制组合ID,再在该二进制组合ID的高位前增加一位符号位后最终获得大厦A在第10层中的32位的带有符号位的二进制组合ID为:000000000 0001 000101 11111111 111111。Wherein, in the spatial index constructed above, the binary combination ID with the sign bit is represented by 32 bits, and if the binary combination ID of the signed bit in the 15th layer of the building A is "01000101 11111111 11111111 11111111, the highest Bit 0 is a sign bit indicating a positive number, then the third bit to the 22nd bit from the high bit is the initial ID of building A in the 10th floor, ie "000101 11111111 111111" (ie, the last 30 bits of the order from the high to the low in the binary combination ID with the sign bit are the initial ID at the 15th layer, and the first 20 bits of the initial ID of the 15th layer are the initial at the 10th layer. ID). According to the method of the foregoing steps B1-B2, the building A is added by a bit indicating the level indicating bit before the high bit of the initial ID in the 10th layer, and the position is set to 1, and then the binary combined ID is generated, and then in the binary Adding a sign bit before the high bit of the combined ID finally obtains the binary combination ID of the 32-bit signed bit of the building A in the 10th floor: 000000000 0001 000101 11111111 111111.
步骤507:根据大厦A在第10层中的带有符号位的二进制组合ID,确定该大厦A在第10层中所属的网格,在该网格中确定大厦A的位置。Step 507: Determine the grid to which the building A belongs in the tenth floor according to the binary combination ID of the sign A in the tenth floor of the building A, and determine the position of the building A in the grid.
步骤508:渲染大厦A在全球电子地图的第10层中所属的网格,并渲染大厦A在该网格中的位置。Step 508: Render the grid to which the building A belongs in the 10th floor of the global electronic map, and render the position of the building A in the grid.
实施例四Embodiment 4
本发明实施例还提供一种电子地图中查询空间对象的装置,如图6所示为该装置的示意图,该装置包括:An embodiment of the present invention further provides an apparatus for querying a spatial object in an electronic map, as shown in FIG. 6 is a schematic diagram of the apparatus, the apparatus includes:
获取模块601,用于获取待查询空间对象的二进制组合ID,所述二进制组合ID中包括表示该待查询空间对象在空间索引中所属层级的层级指示位,以及表示该空间对象在该层级所属网格的初始ID;The obtaining module 601 is configured to obtain a binary combination ID of the spatial object to be queried, where the binary combination ID includes a hierarchical indication bit indicating a hierarchy of the spatial object to be queried in the spatial index, and a network indicating that the spatial object belongs to the hierarchy Initial ID of the grid;
层级确定模块602,用于根据二进制组合ID中的层级指示位,确定该待查询空间对象在空间索引中的所属层级;a hierarchy determining module 602, configured to determine, according to a hierarchical indicator bit in the binary combination ID, a hierarchy of the spatial object to be queried in the spatial index;
网格确定模块603,用于根据二进制组合ID中的初始ID,确定该待查询空间对象在层级指示位表示的层级中所属的网格;a grid determining module 603, configured to determine, according to an initial ID in the binary combination ID, a grid to which the to-be-queried spatial object belongs in a hierarchy indicated by the hierarchical indicator bit;
查询模块604,用于在确定的网格中查询所述待查询空间对象。The query module 604 is configured to query the to-be-queried spatial object in the determined grid.
其中,在一个实施例中,如图7所示,所述层级确定模块602包括:Wherein, in an embodiment, as shown in FIG. 7, the level determining module 602 includes:
层级指示信息确定单元605,用于按照二进制组合ID从高位至低位的顺序,从所述二进制组合ID中确定出第一个赋值为1的位,所述第一个赋值为1的位为所述二进制组合ID中表示待查询空间对象在空间索引中的所属层级的层级指示位; The hierarchical indication information determining unit 605 is configured to determine, from the binary combination ID, a first bit assigned a value of 1 according to a binary combination ID from an upper order to a lower order, wherein the first bit assigned a value of 1 is a hierarchical indication bit indicating a hierarchy level of the spatial object to be queried in the spatial index in the binary combination ID;
初始ID总位数确定单元606,用于确定所述二进制组合ID中第一个赋值为1的位之后的总位数,该总位数为所述初始ID的总位数;The initial ID total number of bits determining unit 606 is configured to determine a total number of bits after the first bit of the binary combination ID that is assigned a value of 1, the total number of bits is the total number of bits of the initial ID;
层级确定单元607,用于用该总位数除以2得到该空间对象的所属层级。The level determining unit 607 is configured to divide the total number of bits by 2 to obtain the belonging level of the spatial object.
实施例五Embodiment 5
再一方面,基于相同的构思,本发明实施例还提供一种电子地图中建立空间索引的装置,如图8所示,所述装置包括:In another aspect, based on the same concept, the embodiment of the present invention further provides an apparatus for establishing a spatial index in an electronic map. As shown in FIG. 8, the apparatus includes:
经纬度表示模块801,用于将电子地图所包含的经纬度范围分别映射到均用m位二进制数表示的整数范围,其中,已预先将每一层电子地图分割为地理空间范围相同的22i个网格,i表示每一层电子地图的层级,i的取值为1到N,且m为大于或等于N的正整数,N为正整数;The latitude and longitude indicating module 801 is configured to map the latitude and longitude ranges included in the electronic map to integer ranges each represented by an m-bit binary number, wherein each layer of the electronic map has been previously divided into 2 2i networks having the same geographical space range. L, i represents the level of each layer of electronic map, i takes a value from 1 to N, and m is a positive integer greater than or equal to N, N is a positive integer;
经纬度确定模块802,用于针对每一层中的每一个空间对象,确定该空间对象的经度对应映射的m位二进制数,以及该空间对象的纬度对应映射的m位二进制数;The latitude and longitude determination module 802 is configured to determine, for each spatial object in each layer, an m-bit binary number of the longitude corresponding mapping of the spatial object, and an m-bit binary number corresponding to the latitude of the spatial object;
取位模块803,用于由高位到低位的顺序,从该空间对象的经度对应映射的m位二进制数中取i位以及纬度对应映射的m位二进制数中取i位;The bit-taking module 803 is configured to take the i-bit from the m-bit binary number of the longitude-corresponding mapping of the spatial object and the m-bit binary number of the latitude-corresponding mapping in the order from the upper bit to the lower bit;
初始ID生成模块804,用于由高位到低位的顺序,将取出的该空间对象的i位经度和i位纬度交错排列,得到2i位的二进制序列,该2i位的二进制序列表示该空间对象在第i层中所属的网格的初始ID;The initial ID generation module 804 is configured to interleave the extracted i-bit longitude and i-bit latitude of the spatial object from the high order to the low order to obtain a binary sequence of 2i bits, wherein the binary sequence of 2i bits indicates that the spatial object is The initial ID of the grid to which the i-th layer belongs;
组合ID生成模块805,用于将该空间对象的层级指示位和初始ID按照预设的组合规则进行组合,生成该空间对象在第i层中的二进制组合ID。The combined ID generation module 805 is configured to combine the hierarchical indication bit and the initial ID of the spatial object according to a preset combination rule to generate a binary combination ID of the spatial object in the i-th layer.
其中,在一个实施例中,如图9所示,所述组合ID生成模块805包括:In one embodiment, as shown in FIG. 9, the combined ID generating module 805 includes:
层级位添加单元806,用于在初始ID对应的二级制序列的最高位前增加一个表示层级指示位的bit位,将该bit位取值设为1;a level bit adding unit 806, configured to add a bit bit indicating a level indicator bit before the highest bit of the second-level sequence corresponding to the initial ID, and set the value of the bit bit to 1;
组合ID生成单元807,用于若层级指示位和初始ID构成的二级制序列的位数少于二进制组合ID的预设位数,则在所述层级指示位前增加L个bit位,并将所述L个bit位取值设为0,所述L等于所述预设位数减去所述层级指示位和初始ID所占用的位数之后剩余的位数。 The combined ID generating unit 807 is configured to add L bit positions before the level indicating bit if the number of bits of the two-level sequence formed by the level indicating bit and the initial ID is less than the preset number of bits of the binary combination ID, and The value of the L bit bits is set to 0, and the L is equal to the preset number of bits minus the number of bits remaining after the level indicator bit and the number of bits occupied by the initial ID.
关于上述实施例中的装置,其中各个模块执行操作的具体方式已经在有关该方法的实施例中进行了详细描述,此处将不做详细阐述说明。With regard to the apparatus in the above embodiments, the specific manner in which the respective modules perform the operations has been described in detail in the embodiment relating to the method, and will not be explained in detail herein.
本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art will appreciate that embodiments of the present invention can be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or a combination of software and hardware. Moreover, the invention can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present invention has been described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (system), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or FIG. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing device to produce a machine for the execution of instructions for execution by a processor of a computer or other programmable data processing device. Means for implementing the functions specified in one or more of the flow or in a block or blocks of the flow chart.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。The computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device. The apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device. The instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.
尽管已描述了本发明的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本发明范围的所有变更和修改。 While the preferred embodiment of the invention has been described, it will be understood that Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and the modifications and
显然,本领域的技术人员可以对本发明进行各种改动和变型而不脱离本发明的精神和范围。这样,倘若本发明的这些修改和变型属于本发明权利要求及其等同技术的范围之内,则本发明也意图包含这些改动和变型在内。 It is apparent that those skilled in the art can make various modifications and variations to the invention without departing from the spirit and scope of the invention. Thus, it is intended that the present invention cover the modifications and modifications of the invention

Claims (8)

  1. 一种电子地图中查询空间对象的方法,其特征在于,所述方法包括:A method for querying a spatial object in an electronic map, the method comprising:
    获取待查询空间对象的二进制组合标识ID,所述二进制组合ID中包括表示该待查询空间对象在空间索引中所属层级的层级指示位,以及表示该空间对象在该层级所属网格的初始ID;Obtaining a binary combination identifier ID of the space object to be queried, where the binary combination ID includes a hierarchical indication bit indicating a hierarchy of the spatial object to be queried in the spatial index, and an initial ID indicating a grid to which the spatial object belongs;
    根据二进制组合ID中的层级指示位,确定该待查询空间对象在空间索引中的所属层级;Determining, according to the hierarchical indicator bit in the binary combination ID, the belonging level of the spatial object to be queried in the spatial index;
    根据二进制组合ID中的初始ID,确定该待查询空间对象在层级指示位表示的层级中所属的网格;Determining, according to an initial ID in the binary combination ID, a mesh to which the to-be-queried spatial object belongs in a hierarchy indicated by the hierarchical indicator bit;
    在确定的网格中查询所述待查询空间对象。The space object to be queried is queried in the determined grid.
  2. 根据权利要求1所述的方法,其特征在于,所述根据二进制组合ID中的层级指示位,确定该待查询空间对象在空间索引中的所属层级,包括:The method according to claim 1, wherein the determining the belonging level of the to-be-queried spatial object in the spatial index according to the hierarchical indication bit in the binary combination ID comprises:
    按照二进制组合ID从高位至低位的顺序,从所述二进制组合ID中确定出第一个赋值为1的位,所述第一个赋值为1的位为所述二进制组合ID中表示待查询空间对象在空间索引中的所属层级的层级指示位;Determining, from the binary combination ID, a first bit assigned a value of 1 according to a binary combination ID from a high order to a low order, the first bit assigned a value of 1 indicates a space to be queried in the binary combination ID The level indicator of the level of the object in the spatial index;
    确定所述二进制组合ID中第一个赋值为1的位之后的总位数,该总位数为所述初始ID的总位数;Determining a total number of bits after the first bit of the binary combination ID assigned a value of 1, the total number of bits being the total number of bits of the initial ID;
    用该总位数除以2得到该空间对象的所属层级。Divide the total number of bits by 2 to get the level of the spatial object.
  3. 一种电子地图中建立空间索引的方法,其特征在于,所述方法包括:A method for establishing a spatial index in an electronic map, the method comprising:
    将电子地图所包含的经纬度范围分别映射到均用m位二进制数表示的整数范围,其中,已预先将每一层电子地图分割为地理空间范围相同的22i个网格,i表示每一层电子地图的层级,i的取值为1到N,且m为大于或等于N的正整数,N为正整数;The latitude and longitude range included in the electronic map is respectively mapped to an integer range represented by m-bit binary numbers, wherein each layer of the electronic map has been previously divided into 2 2i grids having the same geographical space range, and i represents each layer. The level of the electronic map, the value of i is 1 to N, and m is a positive integer greater than or equal to N, and N is a positive integer;
    针对每一层中的每一个空间对象,确定该空间对象的经度对应映射的m位二进制数,以及该空间对象的纬度对应映射的m位二进制数;Determining, by each spatial object in each layer, an m-bit binary number of the longitude corresponding mapping of the spatial object, and an m-bit binary number corresponding to the latitude of the spatial object;
    由高位到低位的顺序,从该空间对象的经度对应映射的m位二进制数中 取i位以及纬度对应映射的m位二进制数中取i位;From the high order to the low order, from the m-bit binary number of the longitude mapping of the spatial object Taking i bits and i bits in the m-bit binary number corresponding to the latitude mapping;
    由高位到低位的顺序,将取出的该空间对象的i位经度和i位纬度交错排列,得到2i位的二进制序列,该2i位的二进制序列表示该空间对象在第i层中所属的网格的初始ID;From the high order to the low order, the i-bit longitude and i-bit latitude of the extracted spatial object are staggered to obtain a binary sequence of 2i bits, and the binary sequence of 2i bits represents the mesh to which the spatial object belongs in the i-th layer. Initial ID
    将该空间对象的层级指示位和初始ID按照预设的组合规则进行组合,生成该空间对象在第i层中的二进制组合ID。The hierarchical indication bit and the initial ID of the spatial object are combined according to a preset combination rule to generate a binary combination ID of the spatial object in the i-th layer.
  4. 根据权利要求3所述的方法,其特征在于,所述将该空间对象的层级指示位和初始ID按照预设的组合规则进行组合,生成该空间对象在第i层中的二进制组合ID,包括:The method according to claim 3, wherein the hierarchical indication bit and the initial ID of the spatial object are combined according to a preset combination rule, and a binary combination ID of the spatial object in the i-th layer is generated, including :
    在初始ID对应的二级制序列的最高位前增加一个表示层级指示位的比特bit位,将该bit位取值设为1;Adding a bit bit indicating a level indication bit before the highest bit of the secondary sequence corresponding to the initial ID, and setting the bit bit to 1;
    若层级指示位和初始ID构成的二级制序列的位数少于二进制组合ID的预设位数,则在所述层级指示位前增加L个bit位,并将所述L个bit位取值设为0,所述L等于所述预设位数减去所述层级指示位和初始ID所占用的位数之后剩余的位数。If the number of bits of the hierarchical sequence formed by the hierarchical indicator bit and the initial ID is less than the preset number of bits of the binary combination ID, then L bits are added before the level indication bit, and the L bits are taken The value is set to 0, and the L is equal to the preset number of bits minus the number of bits remaining after the level indicator bit and the number of bits occupied by the initial ID.
  5. 一种电子地图中查询空间对象的装置,其特征在于,所述装置包括:An apparatus for querying a spatial object in an electronic map, wherein the apparatus comprises:
    获取模块,用于获取待查询空间对象的二进制组合标识ID,所述二进制组合ID中包括表示该待查询空间对象在空间索引中所属层级的层级指示位,以及表示该空间对象在该层级所属网格的初始ID;An acquiring module, configured to obtain a binary combination identifier ID of the spatial object to be queried, where the binary combination ID includes a hierarchical indication bit indicating a hierarchy of the spatial object to be queried in the spatial index, and a network indicating that the spatial object belongs to the hierarchy Initial ID of the grid;
    层级确定模块,用于根据二进制组合ID中的层级指示位,确定该待查询空间对象在空间索引中的所属层级;a hierarchy determining module, configured to determine, according to a hierarchical indication bit in the binary combination ID, a hierarchy of the spatial object to be queried in the spatial index;
    网格确定模块,用于根据二进制组合ID中的初始ID,确定该待查询空间对象在层级指示位表示的层级中所属的网格;a grid determining module, configured to determine, according to an initial ID in the binary combination ID, a grid to which the to-be-queried spatial object belongs in a hierarchy indicated by the hierarchical indicator bit;
    查询模块,用于在确定的网格中查询所述待查询空间对象。a query module, configured to query the to-be-queried spatial object in the determined grid.
  6. 根据权利要求5所述的装置,其特征在于,所述层级确定模块包括:The apparatus according to claim 5, wherein the level determining module comprises:
    层级指示信息确定单元,用于按照二进制组合ID从高位至低位的顺序,从所述二进制组合ID中确定出第一个赋值为1的位,所述第一个赋值为1的 位为所述二进制组合ID中表示待查询空间对象在空间索引中的所属层级的层级指示位;a hierarchical indication information determining unit, configured to determine, from the binary combination ID, a first bit assigned a value of 1 according to a binary combination ID from an upper order to a lower order, the first assignment being 1 Bits are hierarchical indication bits in the binary combination ID indicating the belonging level of the spatial object to be queried in the spatial index;
    初始ID总位数确定单元,用于确定所述二进制组合ID中第一个赋值为1的位之后的总位数,该总位数为所述初始ID的总位数;An initial ID total digit determining unit, configured to determine a total number of bits after the first one of the binary combination IDs assigned a value of 1, the total number of bits being the total number of bits of the initial ID;
    层级确定单元,用于用该总位数除以2得到该空间对象的所属层级。A level determining unit for dividing the total number of bits by 2 to obtain the belonging level of the spatial object.
  7. 一种电子地图中建立空间索引的装置,其特征在于,所述装置包括:An apparatus for establishing a spatial index in an electronic map, the apparatus comprising:
    经纬度表示模块,用于将电子地图所包含的经纬度范围分别映射到均用m位二进制数表示的整数范围,其中,已预先将每一层电子地图分割为地理空间范围相同的22i个网格,i表示每一层电子地图的层级,i的取值为1到N,且m为大于或等于N的正整数,N为正整数;A latitude and longitude representation module for mapping the latitude and longitude ranges included in the electronic map to integer ranges each represented by an m-bit binary number, wherein each layer of the electronic map has been previously divided into 2 2i grids having the same geographical space range , i denotes the level of each layer of electronic map, i takes a value from 1 to N, and m is a positive integer greater than or equal to N, and N is a positive integer;
    经纬度确定模块,用于针对每一层中的每一个空间对象,确定该空间对象的经度对应映射的m位二进制数,以及该空间对象的纬度对应映射的m位二进制数;a latitude and longitude determining module, configured to determine, for each spatial object in each layer, an m-bit binary number of the longitude corresponding mapping of the spatial object, and an m-bit binary number corresponding to the latitude of the spatial object;
    取位模块,用于由高位到低位的顺序,从该空间对象的经度对应映射的m位二进制数中取i位以及纬度对应映射的m位二进制数中取i位;The bit module is used for the order from the high bit to the low bit, and the i bit is taken from the m bit binary number of the longitude corresponding mapping of the spatial object and the i bit is taken from the m bit binary number of the latitude corresponding mapping;
    初始ID生成模块,用于由高位到低位的顺序,将取出的该空间对象的i位经度和i位纬度交错排列,得到2i位的二进制序列,该2i位的二进制序列表示该空间对象在第i层中所属的网格的初始ID;The initial ID generation module is configured to interleave the i-bit longitude and the i-bit latitude of the extracted spatial object in order from high to low, to obtain a binary sequence of 2i bits, and the binary sequence of the 2i bits indicates that the spatial object is in the first The initial ID of the grid to which the i layer belongs;
    组合ID生成模块,用于将该空间对象的层级指示位和初始ID按照预设的组合规则进行组合,生成该空间对象在第i层中的二进制组合ID。The combined ID generation module is configured to combine the hierarchical indication bit and the initial ID of the spatial object according to a preset combination rule to generate a binary combination ID of the spatial object in the i-th layer.
  8. 根据权利要求7所述的装置,其特征在于,所述组合ID生成模块包括:The device according to claim 7, wherein the combined ID generation module comprises:
    层级位添加单元,用于在初始ID对应的二级制序列的最高位前增加一个表示层级指示位的比特bit位,将该bit位取值设为1;a level bit adding unit, configured to add a bit bit indicating a level indicator bit before the highest bit of the second-level sequence corresponding to the initial ID, and set the value of the bit bit to 1;
    组合ID生成单元,用于若层级指示位和初始ID构成的二级制序列的位数少于二进制组合ID的预设位数,则在所述层级指示位前增加L个bit位,并将所述L个bit位取值设为0,所述L等于所述预设位数减去所述层级指示 位和初始ID所占用的位数之后剩余的位数。 a combined ID generating unit, if the number of bits of the secondary sequence formed by the hierarchical indicator bit and the initial ID is less than the preset number of bits of the binary combination ID, then L bits are added before the level indication bit, and The L bit bits take a value of 0, and the L is equal to the preset number of bits minus the level indication The number of bits remaining after the bit and the number of bits occupied by the initial ID.
PCT/CN2015/097021 2014-12-18 2015-12-10 Method and device for querying spatial object and establishing spatial index of electronic map WO2016095749A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410799760.3A CN105786822B (en) 2014-12-18 2014-12-18 Search space object and the method and device for establishing spatial index in electronic map
CN201410799760.3 2014-12-18

Publications (1)

Publication Number Publication Date
WO2016095749A1 true WO2016095749A1 (en) 2016-06-23

Family

ID=56125912

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/097021 WO2016095749A1 (en) 2014-12-18 2015-12-10 Method and device for querying spatial object and establishing spatial index of electronic map

Country Status (2)

Country Link
CN (1) CN105786822B (en)
WO (1) WO2016095749A1 (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111475597A (en) * 2020-03-31 2020-07-31 中国人民解放军战略支援部队信息工程大学 Non-rigid grid coding, spatial object unique identification and query method and device
CN111522892A (en) * 2019-02-02 2020-08-11 阿里巴巴集团控股有限公司 Geographic element retrieval method and device
CN111859187A (en) * 2020-06-30 2020-10-30 杭州欧若数网科技有限公司 POI query method, device, equipment and medium based on distributed graph database
CN113409408A (en) * 2021-06-17 2021-09-17 中国电子科技集团公司第二十八研究所 Airspace multilevel grid characterization and conflict detection method based on multi-way tree
CN115834530A (en) * 2022-09-22 2023-03-21 北京超图骏科数字技术有限公司 Battlefield environment entity data binary coding method and related device

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107941235A (en) * 2016-10-13 2018-04-20 阿里巴巴集团控股有限公司 A kind of methods of exhibiting of navigation map, device, the device and operating system
CN107273414B (en) * 2017-05-05 2019-01-22 广州恒巨信息科技有限公司 A kind of searching method based on geographical location
CN108090150B (en) * 2017-12-11 2020-12-15 厦门亿力吉奥信息科技有限公司 GIS space object storage method and system
CN108345628B (en) * 2017-12-20 2021-08-03 北京都在哪网讯科技有限公司 Position display method and device of multi-level grid map, processor and terminal
CN108416050A (en) * 2018-03-19 2018-08-17 南京市测绘勘察研究院股份有限公司 A kind of map(Collection)Index quick preparation method
CN108920462B (en) * 2018-06-29 2022-07-01 北京奇虎科技有限公司 Point of interest (POI) retrieval method and device based on map
CN109918461B (en) * 2019-01-28 2020-10-30 北京瓴域航空技术研究院有限公司 Multidimensional grid airspace application method
CN111061824B (en) * 2019-11-27 2023-07-25 北京中交兴路信息科技有限公司 Range judging method, device and equipment based on improved quadtree
CN113076321B (en) * 2021-04-20 2022-07-29 中移智行网络科技有限公司 Data processing method, device, terminal and readable storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5422814A (en) * 1993-10-25 1995-06-06 Trimble Navigation Limited Global position system receiver with map coordinate system outputs
CN101551252A (en) * 2009-05-22 2009-10-07 四川长虹电器股份有限公司 Method for vector chart making and rapid loading display
CN103049464A (en) * 2012-03-30 2013-04-17 北京峰盛博远科技有限公司 Heterogeneous geospatial data management technique based on spatial object generalized model and grid body indexing

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7746343B1 (en) * 2005-06-27 2010-06-29 Google Inc. Streaming and interactive visualization of filled polygon data in a geographic information system
CN102609525B (en) * 2012-02-10 2014-04-16 北京大学 Method for dissecting and unifying geographic grid based on longitude and latitude
CN103729802B (en) * 2013-12-20 2017-06-06 深圳供电局有限公司 Method for rapidly positioning and device based on grid equipment geography information hierarchical index

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5422814A (en) * 1993-10-25 1995-06-06 Trimble Navigation Limited Global position system receiver with map coordinate system outputs
CN101551252A (en) * 2009-05-22 2009-10-07 四川长虹电器股份有限公司 Method for vector chart making and rapid loading display
CN103049464A (en) * 2012-03-30 2013-04-17 北京峰盛博远科技有限公司 Heterogeneous geospatial data management technique based on spatial object generalized model and grid body indexing

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111522892A (en) * 2019-02-02 2020-08-11 阿里巴巴集团控股有限公司 Geographic element retrieval method and device
CN111522892B (en) * 2019-02-02 2024-01-09 阿里巴巴集团控股有限公司 Geographic element retrieval method and device
CN111475597A (en) * 2020-03-31 2020-07-31 中国人民解放军战略支援部队信息工程大学 Non-rigid grid coding, spatial object unique identification and query method and device
CN111475597B (en) * 2020-03-31 2022-11-22 中国人民解放军战略支援部队信息工程大学 Non-rigid grid coding, spatial object unique identification and query method and device
CN111859187A (en) * 2020-06-30 2020-10-30 杭州欧若数网科技有限公司 POI query method, device, equipment and medium based on distributed graph database
CN111859187B (en) * 2020-06-30 2024-02-20 杭州欧若数网科技有限公司 POI query method, device, equipment and medium based on distributed graph database
CN113409408A (en) * 2021-06-17 2021-09-17 中国电子科技集团公司第二十八研究所 Airspace multilevel grid characterization and conflict detection method based on multi-way tree
CN113409408B (en) * 2021-06-17 2022-09-13 中国电子科技集团公司第二十八研究所 Airspace multilevel grid characterization and conflict detection method based on multi-way tree
CN115834530A (en) * 2022-09-22 2023-03-21 北京超图骏科数字技术有限公司 Battlefield environment entity data binary coding method and related device

Also Published As

Publication number Publication date
CN105786822A (en) 2016-07-20
CN105786822B (en) 2019-05-24

Similar Documents

Publication Publication Date Title
WO2016095749A1 (en) Method and device for querying spatial object and establishing spatial index of electronic map
CN102609525B (en) Method for dissecting and unifying geographic grid based on longitude and latitude
CN107798054B (en) Trie-based range query method and device
CN109934265B (en) Method and device for determining address of ordinary station
US9719790B2 (en) Mapping uncertain geometries to graticules
WO2017162084A1 (en) Method and device for analyzing data similarity
CN107766433B (en) Range query method and device based on Geo-BTree
US9291700B1 (en) Systems and methods to identify home addresses of mobile devices
CN104091301B (en) A kind of tile pyramid parallel constructing method based on MapReduce
BR112015023617B1 (en) Method and system for generating a geocode trie and facilitating reverse geocode searches
CN104539750A (en) IP locating method and device
US9396249B1 (en) Methods and systems for encoding parent-child map tile relationships
CN106557574B (en) Target address matching method and system based on tree structure
CN106777302B (en) Method and device for converting space geographic coordinates
WO2018104207A1 (en) Encoding scheme for geographic position data
CN102298716B (en) Identifier generation method and device and application method of identifier
JP2021505978A (en) Storage and loading methods, devices, systems and storage media for visual self-location estimation maps
WO2019001223A1 (en) Extreme geographical geohash clustering method
CN111475597A (en) Non-rigid grid coding, spatial object unique identification and query method and device
US10003946B2 (en) Enhanced spatial index for point in polygon operations
CN109885638B (en) Three-dimensional space indexing method and system
WO2022193872A1 (en) Method and apparatus for determining spatial relationship, computer device, and storage medium
CN110555086A (en) Method and device for attributing resource points in grid
CN110989886B (en) Three-dimensional space grid selection method and device based on space map
JP5094904B2 (en) Regional information retrieval server and regional information retrieval method

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 15869257

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15869257

Country of ref document: EP

Kind code of ref document: A1