CN115774798A - Method, apparatus and storage medium for determining index of spatial data - Google Patents

Method, apparatus and storage medium for determining index of spatial data Download PDF

Info

Publication number
CN115774798A
CN115774798A CN202111038953.3A CN202111038953A CN115774798A CN 115774798 A CN115774798 A CN 115774798A CN 202111038953 A CN202111038953 A CN 202111038953A CN 115774798 A CN115774798 A CN 115774798A
Authority
CN
China
Prior art keywords
value
coordinate value
cell
index
cells
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111038953.3A
Other languages
Chinese (zh)
Inventor
王凯庆
金兵兵
张建兴
李林森
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Hikvision Digital Technology Co Ltd
Original Assignee
Hangzhou Hikvision Digital Technology Co Ltd
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 Hangzhou Hikvision Digital Technology Co Ltd filed Critical Hangzhou Hikvision Digital Technology Co Ltd
Priority to CN202111038953.3A priority Critical patent/CN115774798A/en
Publication of CN115774798A publication Critical patent/CN115774798A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the application discloses a method and a device for determining indexes of spatial data and a storage medium, and belongs to the technical field of data retrieval. In the embodiment of the application, the coordinate values contained in the spatial data are normalized by specifying the precision value, and then the index of the spatial data is determined according to the normalized value, so that the method is not only suitable for conventional geographic spatial data indexes, but also can be used for indexing the spatial data in an indoor and outdoor user-defined coordinate system, and is more flexible and convenient and better in applicability compared with a spatial hashing method.

Description

Method, apparatus and storage medium for determining index of spatial data
Technical Field
The present application relates to the field of data retrieval technologies, and in particular, to a method and an apparatus for determining an index of spatial data, and a storage medium.
Background
For any spatial object, the spatial attributes of the spatial object can be generally characterized by data such as position coordinates, shape size, and the like of the spatial object. In this case, data such as the position coordinates, shape, and size of the space object may be used as the space data of the space object. Since the amount of spatial data is usually large, an index may be created for the spatial data in order to more conveniently retrieve the spatial data when the spatial data is used later.
The related art generally adopts a spatial hash method to determine the index of the spatial data. The spatial hash is to take the earth as a two-dimensional plane, divide the two-dimensional plane into a plurality of rectangular areas, convert each longitude and latitude coordinate in each rectangular area into a character string, and then take the common prefix of a plurality of character strings corresponding to a plurality of longitude and latitude coordinates in the rectangular area as the index of all the longitude and latitude coordinates in the rectangular area. When the spatial hash method is adopted to determine the index of the spatial data, different coding tables need to be defined for the spatial data under different precision and different coordinate systems, which is complex.
Disclosure of Invention
The application provides a data distribution processing method, device, system and storage medium, which can reduce the hardware cost of a detection system on the premise of ensuring the data processing performance of the detection system. The technical scheme is as follows:
in one aspect, a method of determining an index of spatial data is provided, the method comprising:
determining a normalization value corresponding to each coordinate value in a plurality of coordinate values according to the specified precision value and the plurality of coordinate values included in the target space data;
converting the normalization value corresponding to each coordinate value into a binary character string, wherein the length of the binary character string is the designated precision value;
merging the binary character strings respectively corresponding to the coordinate values to obtain a merged character string;
and generating an index of the target space data according to the combined character string.
Optionally, the determining, by the target space data, a normalized value corresponding to each coordinate value of the plurality of coordinate values according to the specified precision value and the plurality of coordinate values included in the target space data includes:
according to the specified precision value, the longitude coordinate value and the latitude coordinate value, calculating a normalization value corresponding to the longitude coordinate value and a normalization value corresponding to the latitude coordinate value through a model;
a=(Lon-min Lon)*2 p /(max Lon-min Lon);
b=(Lat-min Lat)*2 p /(max Lat-min Lat);
the a is a normalized value corresponding to the longitude coordinate value, the Lon is the longitude coordinate value, the p is the designated precision value, the min Lon is a minimum longitude coordinate value, the max Lon is a maximum longitude coordinate value, the min Lat is a minimum latitude coordinate value, the max Lat is a maximum latitude coordinate value, the b is a normalized value corresponding to the latitude coordinate value, and the Lat is the latitude coordinate value.
Optionally, even digits of the merged character string are characters in the binary character string corresponding to the longitude coordinate value, and odd digits of the merged character string are characters in the binary character string corresponding to the latitude coordinate value.
Optionally, the specified precision value is any integer value from 1 to 31.
Optionally, the method further comprises:
acquiring a query range;
determining a minimum bounding rectangle of the query range;
and acquiring a query result according to the index prefix of the minimum circumscribed rectangle.
Optionally, obtaining a query result according to the index prefix of the minimum bounding rectangle, where the query result includes:
mapping the minimum circumscribed rectangle to a designated map;
dividing the designated map into a plurality of cells;
judging the position relation between each cell and the minimum circumscribed rectangle according to the index prefix of each cell in the plurality of cells and the index prefix of the minimum circumscribed rectangle;
adding a first cell contained within the minimum bounding rectangle to a first set if there is a first cell in the plurality of cells;
discarding a second cell if there is a second cell in the plurality of cells that is not included in the query range;
and if a third cell intersected with the query range exists in the plurality of cells, dividing the third cell into the plurality of cells again, and returning to execute the step of judging the position relationship between each cell and the minimum circumscribed rectangle according to the index prefix of each cell and the index prefix of the minimum circumscribed rectangle in the plurality of cells until the division times reach a specified threshold or until no cell intersected with the minimum circumscribed rectangle exists in the plurality of divided cells, and acquiring the query result according to the cell contained in the first set, the query range and the index of the stored spatial data.
In another aspect, an apparatus for determining an index of spatial data is provided, the apparatus comprising:
the determining module is used for determining a normalization value corresponding to each coordinate value in the coordinate values according to the designated precision value and the coordinate values included in the target space data;
the conversion module is used for converting the normalization value corresponding to each coordinate value into a binary character string, and the length of the binary character string is the designated precision value;
the merging module is used for merging the binary character strings respectively corresponding to the coordinate values to obtain merged character strings;
and the generating module is used for generating the index of the target space data according to the merging character string.
Optionally, the target space data includes a longitude coordinate value and a latitude coordinate value, and the determining module is mainly configured to:
according to the specified precision value, the longitude coordinate value and the latitude coordinate value, calculating a normalization value corresponding to the longitude coordinate value and a normalization value corresponding to the latitude coordinate value through a model;
a=(Lon-min Lon)*2 p /(max Lon-min Lon);
b=(Lat-min Lat)*2 p /(max Lat-min Lat);
the method comprises the steps of obtaining a longitude coordinate value, obtaining a min Lon, obtaining a min Lat, obtaining a normalization value corresponding to the longitude coordinate value, obtaining the Lat, and obtaining the longitude coordinate value, the latitude coordinate value, the designated precision value, the min Lon, the max Lat, the minimum latitude coordinate value, the maximum latitude coordinate value, the normalization value corresponding to the latitude coordinate value, and the Lat.
Optionally, even digits of the merged character string are characters in the binary character string corresponding to the longitude coordinate value, and odd digits of the merged character string are characters in the binary character string corresponding to the latitude coordinate value.
Optionally, the specified precision value is any integer value from 1 to 31.
Optionally, the apparatus further comprises: a query module to:
acquiring a query range;
determining a minimum bounding rectangle of the query range;
and acquiring a query result according to the index prefix of the minimum circumscribed rectangle.
Optionally, the query module is mainly configured to:
mapping the minimum circumscribed rectangle to a designated map;
dividing the designated map into a plurality of cells;
judging the position relation between each cell and the minimum circumscribed rectangle according to the index prefix of each cell in the plurality of cells and the index prefix of the minimum circumscribed rectangle;
adding a first cell contained within the minimum bounding rectangle to a first set if the first cell exists in the plurality of cells;
discarding a second cell if there is a second cell in the plurality of cells that is not included in the query range;
and if a third cell intersected with the query range exists in the plurality of cells, dividing the third cell into the plurality of cells again, and returning to execute the step of judging the position relationship between each cell and the minimum circumscribed rectangle according to the index prefix of each cell and the index prefix of the minimum circumscribed rectangle in the plurality of cells until the division times reach a specified threshold or until no cell intersected with the minimum circumscribed rectangle exists in the plurality of divided cells, and acquiring the query result according to the cell contained in the first set, the query range and the index of the stored spatial data.
In another aspect, a computer device is provided, the computer device includes a processor, a communication interface, a memory and a communication bus, the processor, the communication interface and the memory complete mutual communication through the communication bus, the memory is used for storing computer programs, and the processor is used for executing the programs stored in the memory to implement the steps of the method for determining an index of spatial data described above.
In another aspect, a computer-readable storage medium is provided, in which a computer program is stored which, when being executed by a processor, carries out the above-mentioned steps of the method of determining an index of spatial data.
In another aspect, a computer program product comprising instructions is provided, which when run on a computer, causes the computer to perform the steps of the above-described method of determining an index of spatial data.
The technical scheme provided by the application can at least bring the following beneficial effects:
in the embodiment of the application, the coordinate values contained in the spatial data are normalized by specifying the precision value, and then the index of the spatial data is determined according to the normalized value, so that the method is not only suitable for conventional geographic spatial data indexes, but also can be used for indexing the spatial data in an indoor and outdoor user-defined coordinate system, and is more flexible and convenient compared with a spatial hashing method and better in applicability.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a system architecture diagram according to a method for determining an index of spatial data provided in an embodiment of the present application;
FIG. 2 is a flowchart of a method for determining an index of spatial data according to an embodiment of the present disclosure;
FIG. 3 is a flowchart of a method for querying spatial data based on spatial data index according to an embodiment of the present application;
FIG. 4 is a diagram illustrating a partition of a bounding rectangle of a query range according to an embodiment of the present application;
FIG. 5 is a schematic structural diagram of an apparatus for determining an index of spatial data according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of a server according to an embodiment of the present application.
Detailed Description
To make the objects, technical solutions and advantages of the embodiments of the present application more clear, the embodiments of the present application will be further described in detail with reference to the accompanying drawings.
Before explaining the method for determining an index of spatial data provided in the embodiment of the present application in detail, an application scenario of the embodiment of the present application is introduced.
Currently, in various map applications, a user may set a query range to query for POI (Point of interest) information located within the query range. Each spatial object on the map can be represented by adopting spatial data, and because the number of the spatial data is huge, an index can be created for the spatial data. Therefore, when the POI information is queried, the POI information to be queried can be retrieved through the index of the spatial data.
Of course, in some other scenarios requiring querying spatial data, the corresponding spatial data may also be retrieved through the created index of spatial data.
Next, a system architecture related to the index method for determining spatial data provided in the embodiment of the present application is described.
Fig. 1 is a schematic diagram of a system architecture according to a method for determining an index of spatial data provided in an embodiment of the present application, and as shown in fig. 1, the system includes a server 101 and a query terminal 102. Wherein the server 101 and the inquiring terminal 102 establish a communication connection.
The server 101 may store spatial data of a plurality of spatial objects, where each spatial data includes a plurality of coordinate values of a corresponding spatial object, and besides, each spatial data may further include attribute information such as a shape, a size, and a distribution of the corresponding spatial object. Illustratively, each spatial data includes a longitude coordinate value and a latitude coordinate value, or each spatial data includes a two-dimensional coordinate of a certain position point under a certain coordinate system. The server 101 may determine an index of each spatial data by using the method provided in the embodiment of the present application, and store each spatial data and the corresponding index correspondingly.
The inquiry terminal 102 may receive an inquiry range set by a user, and then transmit the inquiry range to the server 101. After receiving the query range, the server 101 may obtain a query result corresponding to the query range according to the query range and the stored indexes of each spatial data. After that, the server 101 may feed back the obtained query result to the query terminal 102.
It should be noted that the server 101 may be a server or a server cluster, for example, the server 101 may be a server cluster in a data center. The query terminal 102 may be a terminal device such as a smart phone, a tablet computer, and a desktop computer, which is not limited in this embodiment.
Next, a method for determining an index of spatial data provided in an embodiment of the present application will be explained in detail.
Fig. 2 is a flowchart of a method for determining an index of spatial data according to an embodiment of the present application, where the method is applied to the server shown in fig. 1. Referring to fig. 2, the method comprises the steps of:
step 201: and determining a normalization value corresponding to each coordinate value in the coordinate values according to the specified precision value and the coordinate values included in the target space data.
Wherein the specified precision value may be any integer value between 1 and 31, for example, the specified precision value may be 1 or 31, and the specified precision value may be set by the user according to the required precision.
In the embodiment of the present application, a large amount of spatial data is stored in the server, where the spatial data may include information such as position coordinates, shape, size, distribution, and the like of a spatial object. For any one of the spatial data, the server may use it as the target spatial data, and then determine the index of the target spatial data according to the method provided by the embodiment of the present application.
For example, the position coordinates of the spatial object included in the spatial data may be longitude coordinate values and latitude coordinate values. In this case, the server may calculate a normalized value corresponding to the longitude coordinate value by the following model (1) based on the specified precision value and the longitude coordinate value in the target space data, and calculate a normalized value corresponding to the latitude coordinate value by the following model (2) based on the specified precision value and the latitude coordinate value in the target space data.
a=(Lon-min Lon)*2 p /(max Lon-min Lon) (1)
b=(Lat-min Lat)*2 p /(max Lat-min Lat) (2)
Wherein, a is a normalization value corresponding to the longitude coordinate value, lon is the longitude coordinate value, p is the designated precision value, b is a normalization value corresponding to the latitude coordinate value, and Lat is the latitude coordinate value.
For example, if the specified precision value is 31, the longitude coordinate value of the target space data is 120.235534, and the latitude coordinate value is 30.234982, then the normalized value corresponding to the longitude coordinate value can be obtained from the model (1) as follows:
a=(120.235534-(-180))*2 31 /(180-(-180))=1254100516。
the normalized value corresponding to the latitude coordinate value can be obtained according to the model (2) as follows:
b=(30.234982-(-90))*2 31 /(90-(-90))=1434459209。
alternatively, the coordinate values included in the spatial data may also be two-dimensional coordinates of the spatial object in a specific rectangular coordinate system. In this case, for example, when the spatial data includes an abscissa value and an ordinate value of the spatial object in a specific coordinate system, the longitude coordinate value in the above-described model (1) may be replaced with the abscissa value, and accordingly, the minimum longitude coordinate value may be replaced with the minimum abscissa value in the coordinate system, and the maximum longitude coordinate value may be replaced with the maximum abscissa value in the coordinate system. Similarly, the latitude coordinate value in the model (2) may be replaced by a vertical coordinate value, and accordingly, the minimum latitude coordinate value may be replaced by the minimum vertical coordinate value in the coordinate system, and the maximum latitude coordinate value may be replaced by the maximum vertical coordinate value in the coordinate system.
Therefore, in the embodiment of the application, the coordinate values in the conventional geographic space data can be normalized by the method, and the spatial data in the indoor and outdoor customized coordinate system can also be normalized, so that the index can be determined according to the normalized values in the following steps. Therefore, the method and the device are not only suitable for conventional geographic spatial data indexing, but also can index spatial data under an indoor and outdoor user-defined coordinate system, and are more flexible and convenient and better in applicability compared with a spatial hashing method.
Step 202: and converting the normalization value corresponding to each coordinate value into a binary character string, wherein the length of the binary character string is a specified precision value.
After obtaining the normalized value corresponding to each coordinate value in the target spatial data, the server may convert the normalized value corresponding to each coordinate value into a binary string.
Illustratively, still taking the above-mentioned specified precision value as 31, the normalized value obtained when the longitude coordinate value of the target space data is 120.235534 and the latitude coordinate value is 30.234982 as an example, the normalized value corresponding to the longitude coordinate value is converted into a binary string, the binary string corresponding to the obtained longitude coordinate value is 1001 0101 10000000 0001 0100, and the normalized value corresponding to the latitude coordinate value is converted into a binary string, the binary string corresponding to the obtained latitude coordinate value is 1010 1011 00000000 0011 1000 1001 001. As can be seen, when the specified precision value is 31, the lengths of the binary character string corresponding to the obtained longitude coordinate value and the binary character string corresponding to the latitude character string are both 31.
Step 203: and merging the binary character strings respectively corresponding to the coordinate values to obtain merged character strings.
After determining the binary strings corresponding to the plurality of coordinate values, the server may merge the binary strings corresponding to the plurality of coordinate values, so as to obtain a merged string.
Still taking the coordinate values as longitude coordinate values and latitude coordinate values as examples, the server may insert the binary string corresponding to the latitude coordinate values into the binary string corresponding to the longitude coordinate values to obtain the merged string. In the merged character string, the even digits are characters in the binary character string corresponding to the longitude coordinate value, the odd digits are the binary character string corresponding to the latitude coordinate value, in the merged character string, the character in the binary character string corresponding to the latitude coordinate value is between every two adjacent characters in the binary character string corresponding to the longitude coordinate value, and the character in the binary character string corresponding to the longitude coordinate value is between every two adjacent characters in the binary character string corresponding to the latitude coordinate value.
For example, for the binary character string corresponding to the longitude coordinate value and the binary character string corresponding to the latitude coordinate value given in step 202, after the two binary character strings are merged, the obtained merged character string is: 11001001100110110100000000000000000010111101000010010010010010.
optionally, in some possible implementations, even digits in the merged string may also be characters in the binary string corresponding to the latitude coordinate value, and odd digits are characters in the binary string corresponding to the longitude coordinate value.
Optionally, in some possible implementations, if the plurality of coordinate values included in the target space data are three coordinate values in a three-dimensional coordinate system, in this step, the server may perform cross fusion on binary strings corresponding to the respective coordinate values, so as to obtain a merged string.
For example, assuming that the binary string corresponding to the x coordinate value in the target space data is 1101, the binary string corresponding to the y coordinate value is 1001, and the binary string corresponding to the z coordinate value is 1100, the merged string may be 111101000110.
Step 204: and generating an index of the target spatial data according to the merged character string.
After generating the merged character string, if the length of the merged character string is equal to the reference threshold, directly converting the merged character string into a long integer value, and using the converted long integer value as the index of the target spatial data. Wherein the reference threshold may be determined according to a maximum possible value of the specified precision value. For example, when the designated precision value is an integer value between 1 and 31, the reference threshold may be 64, and of course, when the designated precision value is an integer value between 1 and 15, the reference threshold may be 32, which is not limited in this embodiment of the present application.
Alternatively, if the length of the merged string is not equal to the reference threshold, the server may complement 0 before the merged string according to the reference threshold, so that the length of the complemented string is equal to the reference threshold. The server may then convert the supplemented string to a long integer value, which is then used as an index for the target spatial data.
For example, for the merged character string corresponding to the longitude coordinate value and the latitude coordinate value of the foregoing example, since the length of the merged character string is 62, two bits 0 are supplemented before the merged character string, and then the supplemented character string is converted into a long integer value 363 1818 8479 8901 5698, which is an index of the target spatial data.
In the embodiment of the application, the coordinate values contained in the spatial data can be normalized by specifying the precision value, and then the index of the spatial data is determined according to the normalized value, so that the method is not only suitable for conventional geographic spatial data indexes, but also can be used for indexing the spatial data in an indoor and outdoor user-defined coordinate system, and is more flexible and convenient compared with a spatial hashing method and better in applicability.
Secondly, in the spatial hash method, the division level of the rectangular area may be generally selected according to the requirement of the user. Wherein the division level is divided into 1-12 levels. For example, when the user wants to divide the cell by a width of 40 km, the division level may be selected to be 4 levels, at which time, the width of the divided rectangular area will be 39.1 km, and the index of each latitude and longitude coordinate within the rectangular area will be a character string of length 4. However, the widths of the rectangular regions corresponding to two adjacent division levels in the division levels are large, for example, when the division level is 4, the width of the divided rectangular region is 39.1 km, and when the division level is 3, the width of the divided rectangular region is 156 km. In this case, if the user wants to divide the rectangular area by a width of 75 km, it is difficult to select a suitable division level. Therefore, in the current spatial hashing method, because the width of the rectangular region corresponding to different division levels has large jump, it is difficult to select an appropriate division level. In the embodiment of the present application, the designated precision value may be an integer value between 1 and 31, so that the jump of the area range that can be indicated by the indexes obtained according to different precisions is small, and the range that can be indicated by the indexes obtained according to different precisions is more precise.
In addition, in the embodiment of the present application, since the designated precision value may be an integer value between 1 and 31, the finally obtained index is a long integer value of 8 bytes, and the index obtained by spatial hashing is 12 bytes, so that the index of the spatial data determined by the embodiment of the present application saves more storage space.
Based on the method for determining the index of the spatial data, the embodiment of the application further provides a query method of the spatial data. Exemplarily, referring to fig. 3, the method comprises the steps of:
step 301: and acquiring a query range.
In the embodiment of the application, the query terminal can detect a query frame defined by a user on a map displayed by the query terminal, and then determine a query range corresponding to the query frame according to the query frame, wherein the query range comprises coordinate values of a plurality of position points. The query terminal may then send the query scope to the server. Accordingly, the server receives the inquiry range sent by the inquiry terminal.
Step 302: the minimum bounding rectangle of the query range is determined.
After receiving the query range, the server acquires the maximum abscissa, the minimum abscissa, the maximum ordinate and the minimum ordinate of the query range, generates a vertical line passing through the maximum abscissa and the minimum abscissa and a horizontal line passing through the minimum ordinate and the maximum ordinate, and takes a rectangle surrounded by the four lines as a minimum circumscribed rectangle of the query range.
Step 303: and obtaining a query result according to the index prefix of the minimum circumscribed rectangle.
After the minimum bounding rectangle of the query range is obtained, the server may determine, by the method described in fig. 2, an index of each of the four vertices of the minimum bounding rectangle, and then use the longest common prefix of the indexes of the four vertices as the index prefix of the minimum bounding rectangle. And then, the server can obtain a query result according to the index prefix, the designated map and the query range of the minimum circumscribed rectangle.
Illustratively, the server first maps the minimum bounding rectangle into a specified map. Thereafter, the designated map is divided into a plurality of cells. Judging the position relation between each cell and the minimum circumscribed rectangle according to the index prefix of each cell in the plurality of cells and the index prefix of the minimum circumscribed rectangle; adding a first cell to the first set if there is a first cell in the plurality of cells that is contained within the minimum bounding rectangle; if a second cell which is not contained in the minimum bounding rectangle exists in the plurality of cells, discarding the second cell; and if a third cell intersected with the minimum circumscribed rectangle exists in the plurality of cells, dividing the third cell into the plurality of cells again, returning to execute the step of judging the position relation between each cell and the minimum circumscribed rectangle according to the index prefix of each cell and the index prefix of the minimum circumscribed rectangle in the plurality of cells, and obtaining a query result according to the cells and the query range contained in the first set until the division times reach a specified threshold or until each divided cell is contained in the minimum circumscribed rectangle.
The designated map may be a planar map of an area where the query range is located, or the designated map may be a world map. The server may map the minimum bounding rectangle into the specified map according to the position coordinates of the four vertices of the minimum bounding rectangle. The server then divides the given map into 2 or 4 or other numbers of cells. After the multiple cells are obtained through division, the server may obtain an index prefix of each cell. The server may obtain the index prefix of the corresponding cell by referring to the manner of obtaining the index prefix of the minimum circumscribed rectangle described above.
After obtaining the index prefix of each cell, the server may compare the index prefix of each cell with the index prefix of the minimum bounding rectangle to determine the position relationship between each cell and the minimum bounding rectangle.
Illustratively, taking any cell as an example, the server may compare the index prefix of the cell with the index prefix of the minimum bounding rectangle. If the index prefix of the cell contains the index prefix of the smallest bounding rectangle, it can be determined that the cell is located within the smallest bounding rectangle, i.e., the smallest bounding rectangle contains the cell.
Alternatively, if the first N bits of the index prefix of the cell are the same as the first N bits of the index prefix of the minimum bounding rectangle, but the characters starting from the (N + 1) th bit in the two index prefixes are no longer the same, it may be determined that the cell is not contained within the minimum bounding rectangle.
Alternatively, if the first N bits of the index prefix of the cell and the first N bits of the index prefix of the minimum bounding rectangle are the same, and the characters on M bits consecutive from the N +1 th bit in the two index prefixes are also the same, it may be determined that the cell intersects the minimum bounding rectangle.
For each cell obtained by dividing the specified map, the positional relationship between the corresponding cell and the minimum bounding rectangle can be determined by referring to the above manner. Thereafter, if it is determined that there are one or more first cells included in the minimum bounding rectangle among the plurality of cells in the above manner, the server may add the one or more first cells to the first set. If there is a second cell in the plurality of cells that is not contained in the minimum bounding rectangle, then the cells may be discarded directly. If one or more third cells intersected with the minimum circumscribed rectangle exist in the multiple cells, the server can continuously divide each third cell into multiple cells according to the method for dividing the designated map, and judge the position relation between each cell and the minimum circumscribed rectangle according to the index prefix of each cell and the index prefix of the minimum circumscribed rectangle, and then add the cells contained in the minimum circumscribed rectangle in the newly divided cells to the first set, discard the cells not contained in the minimum circumscribed rectangle, and continuously divide the cells intersected with the minimum circumscribed rectangle until the division times reach a designated threshold or until the cells intersected with the minimum circumscribed rectangle do not exist in the multiple cells obtained by division, namely, the query result can be obtained according to all the cells contained in the minimum circumscribed rectangle and the query range in the first set.
Wherein, the specified threshold may be a preset number of dividing times. For example, if the specified threshold is 6, after 6 rounds of division, the division of the cells intersecting the minimum circumscribed rectangle in the divided cells is stopped, and the first set obtained at this time is obtained to obtain the query result.
After the first set is acquired, the server may sequentially compare, from the smallest cell in the first set, whether the coordinates of the location points included in each cell are included in the query range, and thereby determine a target location point that is not included in the query range. Then, for each cell in the first set, the server may search, according to the index prefix of the cell, a target index containing the index prefix from the indexes of the stored spatial data. If the target index is found, the server can judge whether the target index is the index of the determined target position point, if so, the target index is discarded, and if not, the spatial data indicated by the target index is acquired to obtain the spatial data in the cell. The number of the searched target indexes may be one or more.
For example, taking any target index as an example, the server may convert the target index into a binary string, and then disassemble the binary string to obtain a binary string corresponding to each coordinate value. And calculating a normalization value corresponding to each coordinate value according to the binary character string corresponding to each coordinate value, further calculating each coordinate value according to the normalization value corresponding to each coordinate value, and then acquiring spatial data containing the coordinate values from the stored spatial data to obtain the spatial data indicated by the target index.
For example, still taking the created index of the spatial data as an example, after the target index is converted into a binary string, the server may disassemble the characters on the even-numbered bits in the binary string according to the principle that the characters in the binary string corresponding to the longitude coordinate value are placed on the even-numbered bits and the characters in the binary string corresponding to the latitude coordinate value are placed on the odd-numbered bits, so as to obtain the binary string corresponding to the longitude coordinate value, and disassemble the characters on the odd-numbered bits, so as to obtain the binary string corresponding to the latitude coordinate value. Then, the server may convert the binary string corresponding to the longitude coordinate value into a decimal value to obtain a normalized value corresponding to the longitude coordinate value, and convert the binary string corresponding to the latitude coordinate value into a decimal value to obtain a normalized value corresponding to the latitude coordinate value. After obtaining the normalized value corresponding to the longitude coordinate value and the normalized value corresponding to the latitude coordinate value, the server may obtain the longitude coordinate value by calculation using the following model (3), and obtain the latitude coordinate value by calculation using the following model (4).
Lon=a*(max Lon-min Lon)/2 p +min Lon (3)
Lat=b*(max Lat-min Lat)/2 p +min Lat (4)
Wherein, a is a normalization value corresponding to the longitude coordinate value, lon is the longitude coordinate value, p is the designated precision value, min Lon is the minimum longitude coordinate value, max Lon is the maximum longitude coordinate value, min Lat is the minimum latitude coordinate value, max Lat is the maximum latitude coordinate value, b is the normalization value corresponding to the latitude coordinate value, lat is the latitude coordinate value.
Optionally, in some possible implementation manners, the server stores a mapping relationship between the target index and the spatial data, so that after the server obtains the target index, the server may also determine whether the target index is an index of a target location point that is not included in the query range, and if not, the server may directly obtain the spatial data according to the target index.
Optionally, in some possible cases, there may be no target index containing the index prefix in the index of the stored spatial data, that is, the stored spatial data does not contain spatial data whose coordinate values are located in the cell, and at this time, the target index cannot be found, and in this case, the spatial data in the cell is 0.
By the method, the server can acquire the spatial data of the position point contained in the query range in each cell in the first set, further take all the acquired spatial data as the query result of the query range, and return the query result to the query terminal. And if the spatial data in each cell are all 0, the query result is null.
For example, fig. 4 is a schematic diagram illustrating a limited number of partitions of a specific map according to an embodiment of the present application. As shown in fig. 4, the area 1 in the figure is the minimum bounding rectangle of the query range, and the specified map 2 is quartered to obtain cells 3 to 6, wherein the cells 3, 4, and 6 are discarded because the cells 3, 4, and 6 are neither contained in the area 1 nor intersect the area 1. The cell 5 intersects the area 1, so the division of the cell 5 is continued. Wherein the cells 5 are quartered to obtain cells 50 to 53. The cells 50 to 53 are intersected with the minimum bounding rectangle, so the four cells are divided continuously, and so on, until the cell located in the minimum bounding rectangle is found, the cell is added into the first set.
In the spatial hash method, when querying spatial data, it is necessary to obtain a corresponding cell according to a common prefix of a query range, and then retrieve the spatial data in the cell and eight cells adjacent to the cell. Therefore, in the spatial hash method, spatial data is actually queried by expanding a retrieval range, so that a large amount of irrelevant data is retrieved, and subsequent spatial computation performance is reduced. Therefore, the process of dividing the cells is actually to continuously reduce the retrieval range, reduce the detection quantity of irrelevant data and improve the subsequent space calculation performance.
Next, an apparatus for determining an index of spatial data provided in an embodiment of the present application will be described.
Fig. 5 is a schematic structural diagram of an apparatus 500 for determining an index of spatial data according to an embodiment of the present application, where the apparatus 500 for determining an index of spatial data may be implemented by software, hardware, or a combination of the two. Referring to fig. 5, the apparatus 500 includes:
a determining module 501, configured to determine, according to the specified precision value and a plurality of coordinate values included in the target space data, a normalization value corresponding to each coordinate value in the plurality of coordinate values;
a conversion module 502, configured to convert the normalization value corresponding to each coordinate value into a binary string, where the length of the binary string is a specified precision value;
a merging module 503, configured to merge binary strings corresponding to the multiple coordinate values, respectively, to obtain a merged string;
a generating module 504, configured to generate an index of the target spatial data according to the merged character string.
Optionally, the target space data includes a longitude coordinate value and a latitude coordinate value, and the determining module 501 is mainly configured to:
calculating a normalization value corresponding to the longitude coordinate value and a normalization value corresponding to the latitude coordinate value through the following model according to the specified precision value, the longitude coordinate value and the latitude coordinate value;
a=(Lon-min Lon)*2 p /(max Lon-min Lon);
b=(Lat-min Lat)*2 p /(max Lat-min Lat);
wherein, a is a normalization value corresponding to the longitude coordinate value, lon is the longitude coordinate value, p is the designated precision value, min Lon is the minimum longitude coordinate value, max Lon is the maximum longitude coordinate value, min Lat is the minimum latitude coordinate value, max Lat is the maximum latitude coordinate value, b is the normalization value corresponding to the latitude coordinate value, lat is the latitude coordinate value.
Optionally, even digits of the merged character string are characters in the binary character string corresponding to the longitude coordinate value, and odd digits of the merged character string are characters in the binary character string corresponding to the latitude coordinate value.
Optionally, the precision value is specified as any integer value from 1 to 31.
Optionally, the apparatus further comprises: a query module to:
acquiring a query range;
determining a minimum circumscribed rectangle of the query range;
and obtaining a query result according to the index prefix of the minimum circumscribed rectangle.
Optionally, the query module is mainly configured to:
mapping the minimum circumscribed rectangle into a designated map;
dividing a designated map into a plurality of cells;
judging the position relation between each cell and the minimum circumscribed rectangle according to the index prefix of each cell in the plurality of cells and the index prefix of the minimum circumscribed rectangle;
adding a first cell to the first set if there is a first cell in the plurality of cells that is contained within the minimum bounding rectangle;
discarding a second cell if the second cell is not contained within the minimum bounding rectangle;
and if a third cell intersected with the minimum circumscribed rectangle exists in the plurality of cells, dividing the third cell into the plurality of cells again, returning to execute the step of judging the position relation between each cell and the minimum circumscribed rectangle according to the index prefix of each cell and the index prefix of the minimum circumscribed rectangle in the plurality of cells, and obtaining a query result according to the cells, the query range and the stored indexes of the spatial data contained in the first set until the dividing times reach a specified threshold value or until no cell intersected with the minimum circumscribed rectangle exists in the plurality of divided cells.
In the embodiment of the application, the coordinate values contained in the spatial data can be normalized by specifying the precision value, and then the index of the spatial data is determined according to the normalized value, so that the method is not only suitable for conventional geographic spatial data indexes, but also can be used for indexing the spatial data in an indoor and outdoor user-defined coordinate system, and is more flexible and convenient compared with a spatial hashing method and better in applicability.
It should be noted that: in the apparatus for determining an index of spatial data according to the foregoing embodiment, when generating an index of spatial data, only the division of each functional module is illustrated, and in practical applications, the function distribution may be completed by different functional modules according to needs, that is, the internal structure of the apparatus is divided into different functional modules, so as to complete all or part of the functions described above. In addition, the apparatus for determining an index of spatial data and the method for determining an index of spatial data provided in the foregoing embodiments belong to the same concept, and specific implementation processes thereof are described in detail in the method embodiments and are not described herein again.
Fig. 6 is a block diagram illustrating a server 600 according to an example embodiment. The functions of the server in the above embodiments may be implemented by the server 600 shown in fig. 6. The server 600 may be a server in a cluster of background servers. Specifically, the method comprises the following steps:
the server 600 includes a Central Processing Unit (CPU) 601, a system Memory 604 including a Random Access Memory (RAM) 602 and a Read-Only Memory (ROM) 603, and a system bus 605 connecting the system Memory 604 and the CPU 601. The server 600 also includes a basic Input/Output system (I/O system) 606, which facilitates the transfer of information between devices within the computer, and a mass storage device 607, which stores an operating system 613, application programs 614, and other program modules 615.
The basic input/output system 606 includes a display 608 for displaying information and an input device 609 such as a mouse, keyboard, etc. for a user to input information. Wherein a display 608 and an input device 609 are connected to the central processing unit 601 through an input output controller 610 connected to the system bus 605. The basic input/output system 606 may also include an input/output controller 610 for receiving and processing input from a number of other devices, such as a keyboard, mouse, or electronic stylus. Similarly, input/output controller 610 also provides output to a display screen, a printer, or other type of output device.
The mass storage device 607 is connected to the central processing unit 601 through a mass storage controller (not shown) connected to the system bus 605. The mass storage device 607 and its associated computer-readable media provide non-volatile storage for the server 600. That is, mass storage device 607 may include a computer readable medium (not shown) such as a hard disk or CD-ROM (Compact disk Read-Only Memory) drive.
Without loss of generality, computer readable media may comprise computer storage media and communication media. Computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Computer storage media includes RAM, ROM, EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electrically Erasable Programmable Read-Only Memory), flash Memory or other solid state Memory device, CD-ROM, DVD (Digital Versatile disk), or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices. Of course, those skilled in the art will appreciate that computer storage media is not limited to the foregoing. The system memory 604 and mass storage 607 described above may be collectively referred to as memory.
According to various embodiments of the present application, the server 600 may also operate as a remote computer connected to a network through a network, such as the Internet. That is, the server 600 may be connected to the network 612 through the network interface unit 611 connected to the system bus 605, or may be connected to other types of networks or remote computer systems (not shown) using the network interface unit 611.
The memory further includes one or more programs, and the one or more programs are stored in the memory and configured to be executed by the CPU. The one or more programs include instructions for performing the method of determining an index of spatial data provided by embodiments of the present application.
Embodiments of the present application further provide a computer-readable storage medium, and when a processor of a server executes instructions in the storage medium, the server is enabled to execute the method for determining an index of spatial data provided in the foregoing embodiments. For example, the computer readable storage medium may be a ROM, a RAM, a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like. It is noted that the computer-readable storage medium referred to in the embodiments of the present application may be a non-volatile storage medium, in other words, a non-transitory storage medium.
It should be understood that all or part of the steps for implementing the above embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented in software, it may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. The computer instructions may be stored in the computer-readable storage medium described above.
That is, in some embodiments, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform the method of determining an index of spatial data provided by the above embodiments.
The above description should not be taken as limiting the embodiments of the present application, and any modifications, equivalents, improvements, etc. made within the spirit and principle of the embodiments of the present application should be included in the scope of the embodiments of the present application.

Claims (13)

1. A method of determining an index of spatial data, the method comprising:
determining a normalization value corresponding to each coordinate value in a plurality of coordinate values according to the specified precision value and the plurality of coordinate values included in the target space data;
converting the normalization value corresponding to each coordinate value into a binary character string, wherein the length of the binary character string is the designated precision value;
merging the binary character strings respectively corresponding to the coordinate values to obtain merged character strings;
and generating an index of the target spatial data according to the merged character string.
2. The method of claim 1, wherein the target space data includes longitude and latitude coordinate values, and wherein determining a normalized value for each of the plurality of coordinate values based on the specified precision value and the plurality of coordinate values included in the target space data comprises:
according to the specified precision value, the longitude coordinate value and the latitude coordinate value, calculating a normalization value corresponding to the longitude coordinate value and a normalization value corresponding to the latitude coordinate value through a model;
a=(Lon-min Lon)*2 p /(max Lon-min Lon);
b=(Lat-min Lat)*2 p /(max Lat-min Lat);
the a is a normalized value corresponding to the longitude coordinate value, the Lon is the longitude coordinate value, the p is the designated precision value, the min Lon is a minimum longitude coordinate value, the max Lon is a maximum longitude coordinate value, the min Lat is a minimum latitude coordinate value, the max Lat is a maximum latitude coordinate value, the b is a normalized value corresponding to the latitude coordinate value, and the Lat is the latitude coordinate value.
3. The method of claim 2, wherein the merged string comprises characters in the binary string corresponding to the longitude coordinate value in even digits and the latitude coordinate value in odd digits.
4. The method of claim 1, wherein the specified precision value is any integer value from 1 to 31.
5. The method of any of claims 1-4, further comprising:
acquiring a query range;
determining a minimum bounding rectangle of the query range;
and acquiring a query result according to the index prefix of the minimum circumscribed rectangle.
6. The method according to claim 5, wherein the obtaining the query result according to the index prefix of the minimum bounding rectangle comprises:
mapping the minimum circumscribed rectangle to a designated map;
dividing the designated map into a plurality of cells;
judging the position relation between each cell and the minimum circumscribed rectangle according to the index prefix of each cell in the plurality of cells and the index prefix of the minimum circumscribed rectangle;
adding a first cell contained within the minimum bounding rectangle to a first set if there is a first cell in the plurality of cells;
discarding a second cell if there is a second cell in the plurality of cells that is not included in the query range;
and if a third cell intersecting the query range exists in the multiple cells, dividing the third cell into the multiple cells again, and returning to execute the step of judging the position relationship between each cell and the minimum circumscribed rectangle according to the index prefix of each cell and the index prefix of the minimum circumscribed rectangle in the multiple cells until the division times reach a specified threshold or until no cell intersecting the minimum circumscribed rectangle exists in the multiple divided cells, and acquiring the query result according to the cells contained in the first set, the query range and the indexes of the stored spatial data.
7. An apparatus for determining an index of spatial data, the apparatus comprising:
the determining module is used for determining a normalization value corresponding to each coordinate value in the coordinate values according to the specified precision value and the coordinate values included in the target space data;
the conversion module is used for converting the normalization value corresponding to each coordinate value into a binary character string, and the length of the binary character string is the designated precision value;
the merging module is used for merging the binary character strings respectively corresponding to the coordinate values to obtain merged character strings;
and the generating module is used for generating the index of the target space data according to the merging character string.
8. The apparatus of claim 7, wherein the target space data comprises longitude and latitude coordinate values, and wherein the determining module is configured to:
according to the specified precision value, the longitude coordinate value and the latitude coordinate value, calculating a normalization value corresponding to the longitude coordinate value and a normalization value corresponding to the latitude coordinate value through a model;
a=(Lon-min Lon)*2 p /(max Lon-min Lon);
b=(Lat-min Lat)*2 p /(max Lat-min Lat);
the a is a normalized value corresponding to the longitude coordinate value, the Lon is the longitude coordinate value, the p is the designated precision value, the min Lon is a minimum longitude coordinate value, the max Lon is a maximum longitude coordinate value, the min Lat is a minimum latitude coordinate value, the max Lat is a maximum latitude coordinate value, the b is a normalized value corresponding to the latitude coordinate value, and the Lat is the latitude coordinate value.
9. The apparatus of claim 8, wherein the merged string comprises characters in binary strings corresponding to the longitude coordinate value in even digits, and the merged string comprises characters in binary strings corresponding to the latitude coordinate value in odd digits.
10. The apparatus of claim 7, wherein the specified precision value is any integer value from 1 to 31.
11. The apparatus of any of claims 7-10, further comprising: a query module to:
acquiring a query range;
determining a minimum bounding rectangle of the query range;
and acquiring a query result according to the index prefix of the minimum circumscribed rectangle.
12. The apparatus of claim 11, wherein the query module is configured to:
mapping the minimum circumscribed rectangle to a designated map;
dividing the designated map into a plurality of cells;
judging the position relation between each cell and the minimum circumscribed rectangle according to the index prefix of each cell in the plurality of cells and the index prefix of the minimum circumscribed rectangle;
adding a first cell contained within the minimum bounding rectangle to a first set if the first cell exists in the plurality of cells;
discarding a second cell of the plurality of cells if the second cell is not contained within the minimum bounding rectangle;
and if a third cell intersected with the minimum circumscribed rectangle exists in the plurality of cells, dividing the third cell into the plurality of cells again, and returning to execute the step of judging the position relation between each cell and the minimum circumscribed rectangle according to the index prefix of each cell and the index prefix of the minimum circumscribed rectangle in the plurality of cells until the division times reach a specified threshold or until no cell intersected with the minimum circumscribed rectangle exists in the plurality of divided cells, and acquiring the query result according to the cells contained in the first set, the query range and the stored indexes of the spatial data.
13. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 6.
CN202111038953.3A 2021-09-06 2021-09-06 Method, apparatus and storage medium for determining index of spatial data Pending CN115774798A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111038953.3A CN115774798A (en) 2021-09-06 2021-09-06 Method, apparatus and storage medium for determining index of spatial data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111038953.3A CN115774798A (en) 2021-09-06 2021-09-06 Method, apparatus and storage medium for determining index of spatial data

Publications (1)

Publication Number Publication Date
CN115774798A true CN115774798A (en) 2023-03-10

Family

ID=85387434

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111038953.3A Pending CN115774798A (en) 2021-09-06 2021-09-06 Method, apparatus and storage medium for determining index of spatial data

Country Status (1)

Country Link
CN (1) CN115774798A (en)

Similar Documents

Publication Publication Date Title
CN110413611B (en) Data storage and query method and device
CN111753041B (en) Data aggregation rendering method, device and system, electronic equipment and storage medium
KR20040095751A (en) A system and method employing a grid index for location and precision encoding
CN104750708A (en) Spatio-temporal data index building and searching methods, a spatio-temporal data index building and searching device and spatio-temporal data index building and searching equipment
CN107092623B (en) Interest point query method and device
CN113268557B (en) Rapid spatial index method suitable for display-oriented visual analysis
WO2019211057A1 (en) Methods and systems for simplified graphical depictions of bipartite graphs
CN111090712A (en) Data processing method, device and equipment and computer storage medium
WO2021232278A1 (en) Map acquisition method and apparatus, computer device, and storage medium
CN106605222A (en) Guided data exploration
WO2022242259A1 (en) Data processing method and apparatus, device, and medium
CN112417199A (en) Remote sensing image retrieval method, device, system and storage medium
CN112699195B (en) Geospatial data processing method, device, computer equipment and storage medium
CN111858613B (en) Service data retrieval method
CN111506682B (en) Map data processing method, data query method, device and electronic equipment
CN113076334B (en) Data query method, index generation method, device and electronic equipment
CN109697234B (en) Multi-attribute information query method, device, server and medium for entity
CN115774798A (en) Method, apparatus and storage medium for determining index of spatial data
CN115858709A (en) Multi-scale spatial data processing method, electronic device and storage medium
CN113139258B (en) Road data processing method, device, equipment and storage medium
CN113190549B (en) Multidimensional table data calling method, multidimensional table data calling device, server and storage medium
US11537622B2 (en) K-nearest neighbour spatial queries on a spatial database
CN113986828A (en) Method and device for storing mass files, electronic equipment and storage medium
CN113902874A (en) Point cloud data processing method and device, computer equipment and storage medium
CN112214562B (en) Data processing method, device, electronic equipment and machine-readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination