Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention. In addition, the technical features of each embodiment or the single embodiment provided by the invention can be combined with each other at will to form a feasible technical scheme, and the combination is not limited by the sequence of steps and/or the structural composition mode, but is necessarily based on the fact that a person of ordinary skill in the art can realize the combination, and when the technical scheme is contradictory or can not realize, the combination of the technical scheme is not considered to exist and is not within the protection scope of the invention claimed.
Fig. 1 is a flow chart of a spatial authentication method for space-time data service provided by the invention, and as shown in fig. 1, the method includes:
Step 1, grid division is carried out on space element areas of each administrative area to obtain a grid set corresponding to the space element areas of each administrative area, wherein the space element areas of each administrative area are irregular areas.
It can be understood that the space element region data of each level of administrative district of province, city, county and village is collected first, and then the space element region of each level of administrative district is subjected to grid division. For example, the map space element of a certain city comprises space elements of each administrative area, the space element area of each administrative area is divided into grids, and the space element area of each administrative area is divided into a plurality of small grids for subsequent accurate search.
In one possible embodiment of the present invention, the step 1 of performing grid division on the space element areas of each administrative area to obtain a grid set corresponding to each administrative area space element area includes:
and 11, acquiring the circumscribed rectangle of each administrative area space element area as an initial grid.
The step 11 of obtaining the circumscribed rectangle of each administrative area space element area as an initial grid includes:
wherein, the For the geographic coordinates of the ith data in the administrative space element area,In the horizontal direction of the axis of abscissa,In the vertical coordinate of the drawing, the drawing is,、、、And forming an external rectangle for the border range of the administrative area space element region according to the border range of the administrative area space element region.
It will be appreciated that referring to fig. 2, the inner square is the administrative space element area, the outer rectangular box is the circumscribed rectangle of the administrative space element area, as the initial grid containing the administrative space element area. The boundary line of the initial grid is available、、、To show that the four borderlines may form a rectangle.
And step 12, calculating the intersection ratio of the initial grid and the administrative area space element area.
It can be understood that the intersection ratio of the initial grid and the space element area of the administrative area is calculated, and a specific calculation formula is as follows:
wherein, the Representing the intersection area of the jth grid with the administrative space element area,Representing the mesh area.
And step 13, stopping grid division if the intersection ratio is greater than or equal to a second set threshold value, and performing step 14 on the initial grid by dividing the initial grid into four equal parts along the x direction and the y direction if the intersection ratio is less than the second set threshold value.
It will be appreciated that step 12 calculates the intersection ratio of the initial mesh and the administrative space element region, and if the intersection ratio is equal to or greater than the second set threshold (intersection ratio threshold), the mesh is used as a leaf node, and further division is stopped. Otherwise, if the intersection ratio is smaller than the second set threshold, then further recursive partitioning of the initial mesh is required. Specifically, the initial grid is equally divided into four small grids according to the x direction and the y direction.
The cross ratio threshold is determined according to the balance point of safety and performance, if the safety requirement is high, the cross ratio threshold can be adjusted to refine the grid, otherwise, if the safety is not high and the performance requirement is high, the cross ratio threshold can be adjusted to control the grid.
In the embodiment of the invention, the positive direction of the x axis is eastward, the negative direction is westward, the positive direction of the y axis is northward, the negative direction is southerly, and the representation of the four small grids is as follows:
wherein, the 、、、Respectively a grid after four times of the grid,Is half the width of the quarter front grid,Is half the height of the quarter front grid.
And 14, repeating the step 12 and the step 13 until the intersection ratio of each grid and the administrative area space element area is more than or equal to a second set threshold value, and acquiring a grid set corresponding to each administrative area space element area.
It can be understood that after dividing the grids four and the like, continuously calculating the intersection ratio of each grid and the administrative area space element area, then judging whether the intersection ratio is greater than or equal to a second set threshold, and if the intersection ratio of all the divided grids and the administrative area space element area is greater than the second set threshold, stopping continuously dividing to obtain a grid set corresponding to each administrative area element area.
It should be noted that, the present invention does not perform hierarchical storage on each administrative space element, and the plurality of administrative space elements are stored in one layer, so that the complex data organization is not generated.
And 2, acquiring a user access request, wherein the user access request comprises an administrative division code in which the user is located and a user request access range.
It is understood that, when a user accesses a space element region of an administrative area, the user can only access the space element of the administrative area where the user is located, and cannot access the space elements of other administrative areas. Therefore, when receiving the user access request, the administrative division code of the user and the access range requested by the user are acquired. Wherein, the administrative division code of the user can be obtained according to the user number.
And step 3, finding out a grid set of the administrative division where the user is located according to the administrative division code of the user.
It can be understood that, in step 1, a grid set of space element areas of each administrative district is obtained, and in this step, the grid set of the administrative district where the user is located is obtained according to the administrative district code where the user is located.
The quick and accurate range matching algorithm is also the key of the invention, and the corresponding relation between the administrative division codes and the grids is obtained through the step 1:
Wherein: Representing the grid set generated in the step 1, wherein the key is an administrative division code, Code is divided for the administrative region in which the user is located.
And step 4, judging whether a grid with the distance smaller than a first set threshold value from the user request access range exists in the grid set of the administrative division where the user is located, if so, the user has access right, otherwise, the user does not have access right.
It can be understood that after the grid set of the administrative division where the user is located and the user request access range are obtained, whether the user request access range is in the grid set of the administrative division where the user is located is judged, if yes, the user has access authority, and the space element query in the user request access range can be searched and pushed to the user. If the user request access range is not in the grid set of the administrative division where the user is located, the user does not have access rights, and the user is not allowed to access the space elements in the request access range.
In determining whether the user request access range is in the grid set of the administrative division in which the user is located, it is actually a process in which the user request access range matches the grids in the grid set of the administrative division in which the user is located.
In a possible embodiment of the present invention, the step 4 of determining whether a mesh with a distance smaller than a first set threshold from the access range requested by the user exists in the mesh set of the administrative division where the user is located, if so, the user has access rights, otherwise, the user does not have access rights includes:
and step 41, calculating the center point coordinates of the access range requested by the user and the center point coordinates of each grid in the grid set of the administrative division where the user is located respectively.
It can be understood that, the center point coordinates of the user request access range and the center point coordinates of each grid in the grid set are calculated respectively, and the center point coordinates can be expressed as:
wherein x and y are the abscissa and ordinate of the center point of the user request access range or grid, 、、、Requesting an access range or a frame range of the mesh for the user.
Step 42, sorting the user request access range and all grids based on each center point coordinate.
It will be appreciated that the user request access range and all grids are ordered according to the x-axis coordinates of the user request access range and the center point of the grid. For example, the user request access range and all grids are sorted in ascending order according to the x-coordinate.
Wherein, the The order of ordered space grids comprises the access range requested by a user and the arrangement order of all grids, and a and b are grid objects.
And step 43, retrieving grids with a distance meeting a first condition from the grid set of the administrative division where the user is located according to the x coordinate of the central point of the user request access range and the x coordinate of each grid in the grid set of the administrative division where the user is located, so as to obtain a plurality of candidate grids.
In a possible embodiment of the present invention, step 43 includes:
step 431, positioning the adjacent grids of the user request access range by a binary search method according to the x coordinate of the center point of the user request access range and the x coordinate of each grid in the grid set of the administrative division where the user is located.
It can be appreciated that based on the X-coordinate of the center point of the user request access range, the quick location to the nearby grid index is achieved by a binary search:
In the formula, As a result of the binary search,A binary search function for the package.
The binary search method is an existing search method, and is not described in detail herein. Specifically, based on the x-coordinate of the center point of the user request access range, a grid with a distance within a set threshold value from the x-coordinate of the center point of the user request access range is found out from the grid set by a binary search method, and is called a nearby grid.
And step 432, searching all grids with the distance meeting the first condition from the nearby grids along the positive direction and the negative direction of the x-axis by taking the nearby grids as starting positions, and taking the nearby grids and all the searched grids meeting the first condition as candidate grids.
Wherein, the grid with x coordinate meeting the condition is searched to the west and the east respectively by taking the nearby index as the starting position:
In the formula, 、Index sets for exploration in the west and east directions, index is a binary search starting index, w is a range grid width,、Is a retrieval function of the package.
It can be understood that, the nearby grids in the user request access range obtained by searching in step 431 are taken as the searching start positions, two-part searching is performed along the positive x-axis direction and the negative x-axis direction, all grids with the distances between the two directions and the nearby grids meeting the first condition are found, and the nearby grids and all the grids meeting the first condition are taken as candidate grids. The first condition may be a set distance.
And step 44, judging whether a plurality of candidate grids exist in which the distance from the y coordinate of the center point of the user request access range meets a second condition according to the y coordinate of the center point of the user request access range and the y coordinate of each candidate grid, if so, the user has access right, otherwise, the user does not have access right.
It will be appreciated that step 43 finds grids in the collection of grids that are closer to the x-coordinate of the user's request range, at which time it is also necessary to verify whether the y-axis coordinates of these grids are also closer to the y-coordinate of the user's request access range, and only if both the x-coordinate and the y-coordinate of the grids are closer to both the x-coordinate and the y-coordinate of the user's request access range, they are considered to match.
In verifying the y-coordinate of the candidate grids, if one candidate grid exists, the y-coordinate of the candidate grid satisfies the following conditionThe user has access rights, otherwise, the user does not have access rights;
wherein, the Is the firstThe y-coordinates of the center points of the candidate grids are spaced from the y-coordinates of the center points of the user request access range,Requesting the user for the height of the access range.
When the user needs to access the administrative district space element area, an access request can be sent to the Ngnix server, wherein the user access request comprises an administrative district code where the user is and a user request access range. When Ngnix server receives the access request of user, it jumps to space service through authority verification API, space service judges if the access range of user request is in the corresponding grid set of administrative division generation where user is located, if yes, it shows that the user has access authority, and space element data in the access range is pushed to user through Ngnix server. If the access request scope of the user is not in the grid set corresponding to the administrative division where the user is located, the user is not provided with the access right, and then a notification of refusing access is sent to the user through Ngnix server, so that the authentication of the access request of the user is achieved.
Referring to fig. 3, a space authentication system for space-time data service provided by the present invention includes:
The grid dividing module 301 is configured to perform grid division on the space element areas of each administrative area, so as to obtain a grid set corresponding to each administrative area space element area;
the acquiring module 302 is configured to acquire an administrative division code in which the user is located and a user request access range;
the searching module 303 is configured to search a grid set of the administrative division in which the user is located according to the code of the administrative division in which the user is located;
The judging module 304 is configured to judge whether a grid with a distance smaller than a first set threshold value from the user request access range exists in the grid set of the administrative division where the user is located, if so, the user has access rights, otherwise, the user does not have access rights.
It can be understood that the spatial authentication system for the spatial data service provided by the present invention corresponds to the spatial authentication method for the spatial data service provided by the foregoing embodiments, and the relevant technical features of the spatial authentication system for the spatial data service may refer to the relevant technical features of the spatial authentication method for the spatial data service, which are not described herein again.
Referring to fig. 4, fig. 4 is a schematic diagram of an embodiment of an electronic device according to an embodiment of the invention. As shown in fig. 4, an embodiment of the present invention provides an electronic device 400, including a memory 410, a processor 420, and a computer program 411 stored on the memory 410 and executable on the processor 420, wherein the processor 420 implements steps of a spatial authentication method for a spatio-temporal data service when executing the computer program 411.
Referring to fig. 5, fig. 5 is a schematic diagram of an embodiment of a computer readable storage medium according to the present invention. As shown in fig. 5, the present embodiment provides a computer-readable storage medium 500 on which a computer program 511 is stored, which computer program 511, when executed by a processor, implements the steps of a spatial authentication method for spatio-temporal data services.
The space authentication method and the space authentication system for the space-time data service are based on intelligent grid division and grid efficient matching mechanisms and technologies, control the authority of map access of a user each time, extract administrative division codes of the user when the user requests to access the map each time, search a grid set responding to administrative areas according to the administrative division codes of the user, calculate the space matching performance of the user request access range through a grid rapid matching algorithm, and finally filter and intercept map services according to the matching performance by combining with an Nginx server technology. The scheme considers the safety and performance trade-off point when the user accesses the map, if the safety requirement is high, the cross ratio threshold value can be adjusted to refine the grid, otherwise, if the safety is not high and the performance requirement is high, the safety requirement can be controlled by adjusting the threshold value.
In the foregoing embodiments, the descriptions of the embodiments are focused on, and for those portions of one embodiment that are not described in detail, reference may be made to the related descriptions of other embodiments.
It will be appreciated by those skilled in the art that embodiments of the present invention may 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 an embodiment combining software and hardware aspects. Furthermore, the present invention may 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, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) 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 block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create a system for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various modifications and variations can be made to the present invention without departing from the spirit or scope of the invention. Thus, it is intended that the present invention also include such modifications and alterations insofar as they come within the scope of the appended claims or the equivalents thereof.