A GeoHash determination method, device, equipment and medium

By constructing the target geofence and selecting an appropriate GeoHash length, the problem of inaccurate range caused by too many or too few GeoHash codes in the geofence is solved, achieving the effect of an appropriate number of GeoHash codes and accurate range.

CN113886386BActive Publication Date: 2025-10-10ZHEJIANG DAHUA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111122236.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-24
Publication Date
2025-10-10
Estimated Expiration
2041-09-24

AI Technical Summary

Technical Problem

In the prior art, there is a problem that the number of GeoHash codes in a geographic fence is too many or too few, resulting in inaccurate range.

Method used

By building a target geo-fence based on the location information of the geographic visualization range, determining the target area, and selecting an appropriate GeoHash length based on the target area, the target encoding length of each GeoHash block is determined to ensure the appropriate number of GeoHash codes and the accurate range.

Benefits of technology

This effectively controls the number of GeoHash codes in a geographic fence, ensuring the accuracy of the range represented by the GeoHash code and avoiding errors caused by too many or too few codes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113886386B_ABST
    Figure CN113886386B_ABST
Patent Text Reader

Abstract

The application discloses a GeoHash determination method, device, equipment and medium. In the embodiment of the application, the target GeoHash length of each GeoHash block is determined in advance according to the target area of a target geofence, and for each target GeoHash block contained in the target geofence, the target GeoHash encoding with the length of the target GeoHash length of the target GeoHash block is determined and saved. The length of the GeoHash encoding suitable in length can be selected according to the area of the constructed target geofence, so that the number of corresponding GeoHash encodings in the target geofence is appropriate, the saved target GeoHash encodings are prevented from being too many, and the accuracy of the range represented by the GeoHash encoding is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of geographic fence, and in particular to a GeoHash determination method, device, equipment and medium. BACKGROUND

[0002] With the rapid development of geographic fence technology, geographic fence is now widely used in various technical fields, such as Baidu map, shared bicycle, etc.

[0003] In the prior art, a geographic fence is generally constructed based on the maximum and minimum latitude and longitude of the map visualization range, wherein the geographic fence contains a plurality of GeoHash blocks, each GeoHash block corresponds to a GeoHash code, and each GeoHash code contained in the geographic fence is saved. Among them, different lengths of GeoHash codes can be used to represent corresponding GeoHash blocks, and the longer the length of the GeoHash code, the smaller the range of the GeoHash block represented by the GeoHash code. Generally speaking, the length of 10 GeoHash codes is the most common.

[0004] When the length of the GeoHash code is 10, if the constructed geographic fence is too large, since the range represented by the length of 10 GeoHash codes is fixed, the number of GeoHash blocks contained in the geographic fence is too large, resulting in too many GeoHash codes in the determined geographic fence. The number of GeoHash blocks corresponding to each GeoHash code in the geographic fence is also too large, and the cached GeoHash code is also too much; if the constructed geographic fence is too small, the number of GeoHash blocks contained in the geographic fence is too small, resulting in too few GeoHash codes corresponding to each GeoHash block in the geographic fence, causing the range represented by the GeoHash code to be inaccurate. SUMMARY

[0005] The present application provides a GeoHash determination method, device, equipment and medium, to solve the problem of too many GeoHash codes saved in the geographic fence constructed in the prior art, and too few GeoHash codes saved to increase the error of the GeoHash range.

[0006] In a first aspect, the present application provides a GeoHash determination method, the method comprising:

[0007] constructing a target geographic fence according to the position information of the geographic visualization range;

[0008] obtaining a target area of the target geographic fence, and determining a target GeoHash length according to the target area;

[0009] Determine each target GeoHash block contained in the target geofence, and for each target GeoHash block, determine and save a target GeoHash code corresponding to the target GeoHash block based on the location information of the target GeoHash block, where the length of the target GeoHash code is the target GeoHash length.

[0010] Furthermore, determining a target GeoHash length according to the target area includes:

[0011] Determining a target average area of ​​each GeoHash block in the target geofence based on the target area of ​​the target geofence and a preset first target number of GeoHash blocks;

[0012] The target GeoHash length corresponding to the target average area is determined according to the pre-saved correspondence between the GeoHash length and the area of ​​the GeoHash block.

[0013] Furthermore, determining a target GeoHash length according to the target area includes:

[0014] Randomly select a first candidate GeoHash length, and determine the candidate area of ​​each first candidate GeoHash block corresponding to the first candidate GeoHash length based on the pre-saved correspondence between GeoHash length and GeoHash block area;

[0015] determining, based on the target area and the candidate area, a second target number of first candidate GeoHash blocks included in the target geo-fence, and determining whether the second target number is within a preset range of a target number of GeoHash blocks;

[0016] If yes, the first candidate GeoHash length is determined as the target GeoHash length;

[0017] If not, a second candidate GeoHash length is randomly selected, and the selected second candidate GeoHash length is updated to the first candidate GeoHash length. The candidate area of ​​the candidate GeoHash block with the length of the first candidate GeoHash length is determined until the target GeoHash length is determined.

[0018] Furthermore, determining each target GeoHash block contained in the target geofence includes:

[0019] Taking a first GeoHash block containing the preset location information of the target geofence as a starting point, determining whether a second GeoHash block adjacent to the first GeoHash block and unrecognized is located within the target geofence;

[0020] If so, the second GeoHash block is updated to the first GeoHash block, and the second GeoHash block is marked as an unrecognized GeoHash block until each target GeoHash block included in the target geofence is determined.

[0021] Furthermore, the location information includes:

[0022] At least one of longitude and latitude;

[0023] The determining, starting from a first GeoHash block including the preset location information of the target geofence, whether a second GeoHash block adjacent to the first GeoHash block and unrecognized is located within the target geofence includes:

[0024] Determine a first longitude and latitude range corresponding to a second GeoHash block that is adjacent to the first GeoHash block and has not been identified, and determine whether the first longitude and latitude range is within a second longitude and latitude range corresponding to the target geofence; if so, determine that the second GeoHash block is within the target geofence; if not, determine that the second GeoHash block is not within the target geofence.

[0025] In a second aspect, the present invention further provides a device for determining a geocoding GeoHash, the device comprising:

[0026] A construction module, for constructing a target geo-fence according to location information of a geo-visualization range;

[0027] A determination module is configured to obtain a target area of ​​the target geofence and determine a target GeoHash length based on the target area; determine each target GeoHash block contained in the target geofence, and for each target GeoHash block, determine and store a target GeoHash code corresponding to the target GeoHash block based on the location information of the target GeoHash block, where the length of the target GeoHash code is the target GeoHash length.

[0028] Furthermore, the determination module is specifically configured to determine a target average area of ​​each GeoHash block in the target geofence based on the target area of ​​the target geofence and a preset first target number of GeoHash blocks; and determine a target GeoHash length corresponding to the target average area based on a pre-stored correspondence between GeoHash length and GeoHash block area.

[0029] Furthermore, the determination module is specifically configured to randomly select a first candidate GeoHash length, and determine the candidate area of ​​each first candidate GeoHash block corresponding to the first candidate GeoHash length based on a pre-stored correspondence between GeoHash lengths and GeoHash block areas; determine a second target number of first candidate GeoHash blocks to be included in the target geofence based on the target area and the candidate area, and determine whether the second target number is within a preset target number of GeoHash blocks; if so, determine the first candidate GeoHash length as the target GeoHash length; if not, randomly select a second candidate GeoHash length, update the selected second candidate GeoHash length to the first candidate GeoHash length, and determine the candidate area of ​​candidate GeoHash blocks having a length equal to the first candidate GeoHash length, until the target GeoHash length is determined.

[0030] Furthermore, the determination module is specifically configured to determine, starting from a first GeoHash block containing the preset location information of the target geofence, whether a second GeoHash block adjacent to the first GeoHash block and unrecognized is located within the target geofence; if so, update the second GeoHash block to the first GeoHash block and mark the second GeoHash block as an unrecognized GeoHash block, until each target GeoHash block contained in the target geofence is determined.

[0031] Furthermore, the determination module is specifically configured to determine a first longitude and latitude range corresponding to a second GeoHash block that is adjacent to the first GeoHash block and has not been identified, and determine whether the first longitude and latitude range is within a second longitude and latitude range corresponding to the target geofence; if so, determine that the second GeoHash block is within the target geofence; if not, determine that the second GeoHash block is not within the target geofence.

[0032] In the embodiment of the present application, according to the position information of the geographic visualization range, a target geographic fence is constructed, a target area of the target geographic fence is obtained, a target average area of each GeoHash block is determined according to the target area, a target GeoHash length is determined according to the target average area, each target GeoHash block contained in the target geographic fence is determined, and for each target GeoHash block, a target GeoHash code corresponding to the target GeoHash block is determined according to the position information of the target GeoHash block and saved, wherein the length of the target GeoHash code is the target GeoHash length. Since in the embodiment of the present application, the target GeoHash length of each GeoHash block is determined in advance according to the target area of the target geographic fence, and for each target GeoHash block contained in the target geographic fence, the target GeoHash code with the length of the target GeoHash length is determined and saved, the length of the GeoHash code can be effectively selected according to the area of the constructed target geographic fence, and the number of the corresponding GeoHash codes in the target geographic fence is ensured to be appropriate, the saved target GeoHash codes are prevented from being too many, and the accuracy of the range represented by the GeoHash code is ensured. BRIEF DESCRIPTION OF DRAWINGS

[0033] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0034] Figure 1 A process schematic diagram of a GeoHash determination method provided by the embodiment of the present application;

[0035] Figure 2 A process schematic diagram of determining a target GeoHash length provided by the embodiment of the present application;

[0036] Figure 3 A process schematic diagram of determining a GeoHash code contained in a geographic fence provided by the embodiment of the present application;

[0037] Figure 4 A process schematic diagram of determining each target GeoHash block contained in the target geographic fence provided by the embodiment of the present application;

[0038] Figure 5 A structure schematic diagram of a GeoHash determination device provided by the embodiment of the present application;

[0039] Figure 6 A schematic structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0040] To make the objectives, technical solutions, and advantages of the present invention more apparent, the present invention will be further described in detail below with reference to the accompanying drawings. It is apparent that the embodiments described are only some, not all, of the present invention. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without creative effort are intended to fall within the scope of protection of the present invention.

[0041] In this embodiment of the present invention, a target geofence is constructed based on the location information of the geographic visualization range, and a target area of ​​the target geofence is obtained. A target average area of ​​each GeoHash block is determined based on the target area, and a target GeoHash length is determined based on the target average area. Each target GeoHash block included in the target geofence is determined, and for each target GeoHash block, a target GeoHash code corresponding to the target GeoHash block is determined and saved based on the location information of the target GeoHash block. The length of the target GeoHash code is the target GeoHash length. In this embodiment of the present invention, the target GeoHash length of each GeoHash block is pre-determined based on the target area of ​​the target geofence. For each target GeoHash block contained in the target geofence, a target GeoHash code corresponding to the target GeoHash length is determined and stored. This effectively selects a GeoHash length appropriate for the area of ​​the constructed target geofence, thereby ensuring an appropriate number of GeoHash codes within the target geofence, avoiding excessive storage of target GeoHash codes, and ensuring the accuracy of the range represented by the GeoHash code.

[0042] To avoid the problem of too many corresponding GeoHash codes stored in a geofence and too few GeoHash codes in a geofence affecting the accuracy of the range represented by the GeoHash code, embodiments of the present invention provide a GeoHash determination method, apparatus, device, and medium.

[0043] Example 1:

[0044] Figure 1 A schematic diagram of a GeoHash determination method provided in an embodiment of the present invention includes the following steps:

[0045] S101: Construct a target geographic fence according to the location information of the geographic visualization range.

[0046] The geocoding GeoHash determination method provided by the embodiment of the present invention is applied to an electronic device, which may be a PC or a server.

[0047] In an embodiment of the present invention, a target geofence can be constructed in advance based on the location information of a geographic visualization range, wherein the geographic visualization range is the range of a geographic area where the location information is visible and known, such as a map. If a geofence is constructed for the area where Beijing is located, then the geographic visualization range can be the range corresponding to Beijing on the map. The target geofence is a virtual geographic boundary enclosed by a virtual fence, and the constructed target geofence is generally a polygon. Specifically, in an embodiment of the present invention, a target geofence can be constructed based on the longitude and latitude of the upper left corner vertex and the longitude and latitude of the lower right corner vertex of the geographic visualization range. If a geofence is constructed for Beijing, then the target geofence is constructed based on the longitude and latitude of the upper corner point and the longitude and latitude of the lower right corner of the range corresponding to Beijing on the map. The process of constructing a target geofence based on the longitude and latitude of the upper left corner vertex and the longitude and latitude of the lower right corner vertex of the geographic visualization range is a prior art and will not be described in detail here.

[0048] S102: Obtain a target area of ​​the target geo-fence, and determine a target GeoHash length according to the target area.

[0049] Since a longer GeoHash length corresponds to a GeoHash code, the range of the corresponding GeoHash block is smaller, and a shorter GeoHash length corresponds to a larger GeoHash block, the target geofence contains neither too many nor too few GeoHash codes, and therefore, to ensure that the target geofence contains neither too many nor too few GeoHash blocks, it is necessary to determine the appropriate length of the GeoHash codes corresponding to the GeoHash blocks within the target geofence. This appropriate length is also the target GeoHash length, where one GeoHash code corresponds to one GeoHash block.

[0050] To determine the target GeoHash length, in an embodiment of the present invention, after constructing the target geofence, the target area of ​​the target geofence is first obtained. Since the longitude and latitude of each location within the target geofence are known, the target area can be determined based on the longitude and latitude of each location within the target geofence. For example, if the target geofence is a polygon, the target area of ​​the target geofence is determined based on the longitude and latitude of each vertex of the polygon. The target GeoHash length is then determined based on the target area. Specifically, in an embodiment of the present invention, a correspondence between geofence area and GeoHash length can be pre-stored. After determining the target area corresponding to the target geofence, the target GeoHash length corresponding to the target area is determined based on this pre-stored correspondence between geofence area and GeoHash length.

[0051] S103: Determine each target GeoHash block contained in the target geofence, and for each target GeoHash block, determine and save a target GeoHash code corresponding to the target GeoHash block based on the location information of the target GeoHash block, where the length of the target GeoHash code is the target GeoHash length.

[0052] In an embodiment of the present invention, a geofence contains multiple GeoHash blocks, each of which corresponds to a GeoHash code. After determining the target GeoHash length, each target GeoHash block contained in the target geofence is determined, and the target GeoHash code corresponding to each target GeoHash block is determined, with the length of the target GeoHash code being the target GeoHash length. Specifically, when determining a target GeoHash code having a length equal to the target GeoHash length, the target GeoHash code is determined based on the longitude and latitude of the upper left corner of the target GeoHash block. The process of determining the target GeoHash code based on the longitude and latitude of the upper left corner of the target GeoHash block is conventional and is not further described here.

[0053] In this embodiment of the present invention, the target GeoHash length of each GeoHash block is pre-determined based on the target area of ​​the target geofence. For each target GeoHash block contained in the target geofence, a target GeoHash code corresponding to the target GeoHash length is determined and stored. This effectively selects a GeoHash length appropriate for the area of ​​the constructed target geofence, thereby ensuring an appropriate number of GeoHash codes stored within the target geofence, avoiding an excessive number of target GeoHash codes, and ensuring the accuracy of the range represented by the GeoHash code.

[0054] Example 2:

[0055] To determine the target GeoHash length, based on the above embodiment, in this embodiment of the present invention, determining the target GeoHash length according to the target area includes:

[0056] Determining a target average area of ​​each GeoHash block in the target geofence based on the target area of ​​the target geofence and a preset first target number of GeoHash blocks;

[0057] The target GeoHash length corresponding to the target average area is determined according to the pre-saved correspondence between the GeoHash length and the area of ​​the GeoHash block.

[0058] Since each GeoHash block within a geofence corresponds to a GeoHash code, to ensure an appropriate number of GeoHash codes within the geofence, the geofence also needs to have an appropriate number of GeoHash blocks. Therefore, in embodiments of the present invention, a first target number of GeoHash blocks may be preset. Subsequently, a target average area for each GeoHash block within the target geofence is determined based on the preset first target number of GeoHash blocks. A target GeoHash length is then determined based on the target average area of ​​each GeoHash block. To determine the target average area for each GeoHash block, the target average area for each GeoHash block within the target geofence may be determined based on the target area of ​​the target geofence and the preset first target number of GeoHash blocks. Specifically, the target average area for each GeoHash block within the target geofence may be determined based on the quotient of the target area of ​​the target geofence and the preset first target number of GeoHash blocks.

[0059] In this embodiment of the present invention, to determine the target GeoHash length, a correspondence between GeoHash lengths and GeoHash block areas is pre-stored. After determining the target average area for each GeoHash block within the target geofence, the target GeoHash length corresponding to the target average area is determined based on this pre-stored correspondence between GeoHash lengths and GeoHash block areas. The larger the target average area of ​​the GeoHash blocks, the smaller the target GeoHash length, and the smaller the target average area of ​​the GeoHash blocks, the larger the target GeoHash length.

[0060] To determine the target GeoHash length, based on the above embodiment, in this embodiment of the present invention, determining the target GeoHash length according to the target area includes:

[0061] Randomly select a first candidate GeoHash length, and determine the candidate area of ​​each first candidate GeoHash block corresponding to the first candidate GeoHash length based on the pre-saved correspondence between GeoHash length and GeoHash block area;

[0062] determining, based on the target area and the candidate area, a second target number of first candidate GeoHash blocks included in the target geo-fence, and determining whether the second target number is within a preset range of a target number of GeoHash blocks;

[0063] If yes, the first candidate GeoHash length is determined as the target GeoHash length;

[0064] If not, a second candidate GeoHash length is randomly selected, and the selected second candidate GeoHash length is updated to the first candidate GeoHash length. The candidate area of ​​the candidate GeoHash block with the length of the first candidate GeoHash length is determined until the target GeoHash length is determined.

[0065] In an embodiment of the present invention, to determine the target GeoHash length, the electronic device may also preset a range of the target number of GeoHash blocks. A first candidate GeoHash length is first randomly selected from a plurality of pre-stored GeoHash lengths. Then, based on the correspondence between the GeoHash lengths and the areas of the GeoHash blocks pre-stored in the electronic device, the candidate area of ​​the first candidate GeoHash block corresponding to the first candidate GeoHash length is determined.

[0066] Since the target area of ​​the target geofence is known, the second target number of GeoHash blocks to be included in the target geofence can be determined based on the quotient of the target area of ​​the target geofence and the candidate area of ​​the first candidate GeoHash block. To determine whether the first candidate GeoHash length is the target GeoHash length, in this embodiment of the present invention, it is determined whether the second target length is within a preset range of the target number of GeoHash blocks. If the second target number is within the preset range of the target number of GeoHash blocks, the first candidate GeoHash length is determined as the target GeoHash length. Otherwise, a second candidate GeoHash length is randomly selected from a plurality of pre-stored GeoHash lengths, and the selected second candidate GeoHash length is updated as the first candidate GeoHash length. The candidate area of ​​candidate GeoHash blocks having a length equal to the first candidate GeoHash length is then determined again until the target GeoHash length is determined.

[0067] Because a longer GeoHash length corresponds to a smaller coverage range of the GeoHash block corresponding to the GeoHash code of that GeoHash length, when it is determined that the second target number is not within the preset target number range of GeoHash blocks, when selecting the second candidate GeoHash length, to reduce the workload of the electronic device and improve the efficiency of determining the target GeoHash length, the second target number can be compared with the maximum and minimum target numbers within the preset target number range of GeoHash blocks. The second candidate GeoHash length can be estimated based on the comparison results.

[0068] Specifically, if the second target number is greater than the maximum target number, a second candidate GeoHash length that is shorter than the first candidate GeoHash length is selected to enable the subsequently selected second candidate GeoHash length to represent a larger area and thereby reduce the number of GeoHash blocks included in the target geofence. If the second target number is less than the minimum target number, a second candidate GeoHash length that is longer than the first candidate GeoHash length is selected to enable the subsequently selected second candidate GeoHash length to represent a smaller area and thereby increase the number of GeoHash blocks included in the target geofence.

[0069] For example, if the first candidate GeoHash length is 10, the second target number is 5, and the preset target number of GeoHash blocks is in the range of [6, 8], then the second candidate GeoHash length with a length less than 10 can be selected, for example, the second candidate GeoHash length can be set to 9 or 8, etc.

[0070] Figure 2 A schematic diagram of a process for determining the target GeoHash length provided by an embodiment of the present invention is now directed to Figure 2 Provide explanation.

[0071] First, a target geofence is constructed based on the latitude and longitude of the upper left and lower right corners of the geographic visualization range. The target area of ​​the target geofence is determined. A first candidate GeoHash length is randomly selected, and the candidate area corresponding to the first candidate GeoHash length is determined. The target area of ​​the target geofence is divided by the candidate area to estimate the second target number of GeoHash blocks contained in the target geofence. If the second target number falls within the preset target number of GeoHash blocks, the first candidate GeoHash length is determined as the target length. Otherwise, a second candidate GeoHash length is randomly selected and updated to the first candidate GeoHash length. The candidate area corresponding to the first candidate GeoHash length is determined. Subsequent judgments are then made based on the target area of ​​the target geofence and the candidate area until an appropriate target length is selected.

[0072] Figure 3 A schematic diagram of a process for determining the GeoHash code contained in a geographic fence provided by an embodiment of the present invention is now directed to Figure 3 Provide explanation.

[0073] First, build the target geofence, determine the target GeoHash length corresponding to the target geofence, determine all target GeoHash blocks contained in the target geofence, and determine the target GeoHash code corresponding to each target GeoHash block. The length of the target GeoHash code corresponding to each target GeoHash block is the target GeoHash length.

[0074] Example 3:

[0075] In order to determine each target GeoHash block in a target geofence, based on the above embodiments, in an embodiment of the present invention, determining each target GeoHash block contained in the target geofence includes:

[0076] determining whether a second GeoHash block adjacent to the first GeoHash block and not identified is located in the target geofence, the second GeoHash block containing preset position information of the target geofence;

[0077] If yes, the second GeoHash block is updated as the first GeoHash block, and the second GeoHash block is marked as a GeoHash block not identified until each target GeoHash block contained in the target geofence is determined.

[0078] In the embodiments of the present application, after the target geofence is constructed, in order to determine all target GeoHash blocks contained in the target geofence, a first GeoHash block containing preset position information of the target geofence can be taken as a starting point to determine whether a second GeoHash block adjacent to the first GeoHash block and not identified is located in the target geofence. Specifically, if a part of the second GeoHash block is in the area where the target geofence is located and a part of the second GeoHash block is not in the area where the target geofence is located, the second GeoHash block can also be considered to be located in the target geofence.

[0079] If the second GeoHash block is located in the target geofence, the second GeoHash block is updated as the first GeoHash block, and the second GeoHash block is marked as a GeoHash block not identified until each target GeoHash block contained in the target geofence is determined. The preset position is a known position in the target geofence.

[0080] Since the geofence is constructed based on the longitude and latitude of the upper left corner and the longitude and latitude of the lower right corner of the geographic visualization range, that is, the longitude and latitude of the upper left corner and the longitude and latitude of the lower right corner are contained in the target geofence and known, therefore, the preset position information of the target geofence can be the longitude and latitude of the upper left corner of the geographic visualization range, or the longitude and latitude of the lower right corner of the geographic visualization range.

[0081] In order to accurately determine all target GeoHash blocks contained in the target geofence, on the basis of the above-mentioned embodiments, in the embodiments of the present application, the position information includes:

[0082] at least one of longitude and latitude;

[0083] The determination whether a second GeoHash block adjacent to the first GeoHash block and not identified is located in the target geofence includes:

[0084] determining a first longitude and latitude range corresponding to a second GeoHash block adjacent to the first GeoHash block and not identified, determining whether the first longitude and latitude range is located in a second longitude and latitude range corresponding to the target geofence, if yes, determining that the second GeoHash block is located in the target geofence, if no, determining that the second GeoHash block is not located in the target geofence.

[0085] In the embodiment of the present application, the position information includes at least one of longitude and latitude. In order to determine whether the second GeoHash block adjacent to the first GeoHash block and not identified is a target GeoHash block contained in the target geofence, a first longitude and latitude range corresponding to the second GeoHash block adjacent to the first GeoHash block and not identified is determined, it is determined whether the first longitude and latitude range is located in a second longitude and latitude range corresponding to the target geofence, if yes, it is determined that the second GeoHash block is located in the target geofence, if no, it is determined that the second GeoHash block is not located in the target geofence.

[0086] Specifically, if the preset position information of the target geofence is the longitude and latitude of the upper left corner of the geographic visualization range, the GeoHash block containing the longitude and latitude of the upper left corner of the geographic visualization range can be taken as the first GeoHash block, and the first longitude and latitude range corresponding to the second GeoHash block adjacent to the first GeoHash block and not identified is determined taking the first GeoHash block as the starting point, if it is determined whether the first longitude and latitude range is located in the second longitude and latitude range corresponding to the target geofence, it is determined that the second GeoHash block is located in the target geofence, if no, it is determined that the second GeoHash block is not located in the target geofence.

[0087] If the preset position information of the target geofence is the longitude and latitude of the lower right corner of the geographic visualization range, the GeoHash block containing the longitude and latitude of the lower right corner of the geographic visualization range can be taken as the first GeoHash block, and the first longitude and latitude range corresponding to the second GeoHash block adjacent to the first GeoHash block and not identified is determined taking the first GeoHash block as the starting point, if it is determined whether the first longitude and latitude range is located in the second longitude and latitude range corresponding to the target geofence, it is determined that the second GeoHash block is located in the target geofence, if no, it is determined that the second GeoHash block is not located in the target geofence.

[0088] Figure 4 A process diagram for determining each target GeoHash block contained in the target geofence is provided for the embodiment of the present application, and now the process of determining each target GeoHash block contained in the target geofence is described in detail. Figure 4Provide explanation.

[0089] Taking the latitude and longitude of the upper left corner of the target geofence as the preset location information of the target geofence as an example, starting from the first GeoHash block containing the latitude and longitude of the upper left corner of the target geofence, determine the first latitude and longitude range corresponding to the second GeoHash block adjacent to the right side of the first GeoHash block and unrecognized. Then determine whether the first latitude and longitude range is within the second latitude and longitude range corresponding to the target geofence. If so, determine that the second GeoHash block is within the target geofence, and save the GeoHash code corresponding to the second GeoHash block. If not, determine that the second GeoHash block is not within the target geofence.

[0090] Starting from the first GeoHash block containing the longitude and latitude of the upper left corner of the target geofence, determine the first longitude and latitude range corresponding to the unrecognized second GeoHash block adjacent to the lower side of the first GeoHash block. Then determine whether the first longitude and latitude range is within the second longitude and latitude range corresponding to the target geofence. If so, determine that the second GeoHash block is within the target geofence and save the GeoHash code corresponding to the second GeoHash block. If not, determine that the second GeoHash block is not within the target geofence.

[0091] Then, all second GeoHash blocks within the target geofence are updated to first GeoHash blocks, and the second GeoHash blocks are marked as unrecognized GeoHash blocks, until each target GeoHash block contained in the target geofence is determined.

[0092] Example 4:

[0093] Figure 5 A schematic diagram of the structure of a GeoHash determination device provided in an embodiment of the present invention, the device comprising:

[0094] A construction module 501 is used to construct a target geo-fence based on the location information of the geo-visualization range;

[0095] Determination module 502 is configured to obtain a target area for the target geofence and determine a target GeoHash length based on the target area; determine each target GeoHash block contained in the target geofence, and for each target GeoHash block, determine and store a target GeoHash code corresponding to the target GeoHash block based on the location information of the target GeoHash block. The length of the target GeoHash code is the target GeoHash length.

[0096] In one possible implementation, the determination module 502 is specifically configured to determine a target average area for each GeoHash block in the target geofence based on the target area of ​​the target geofence and a preset first target number of GeoHash blocks; and determine a target GeoHash length corresponding to the target average area based on a pre-stored correspondence between GeoHash lengths and GeoHash block areas.

[0097] In one possible implementation, the determination module 502 is specifically configured to randomly select a first candidate GeoHash length, and determine the candidate area of ​​each first candidate GeoHash block corresponding to the first candidate GeoHash length based on a pre-stored correspondence between GeoHash lengths and GeoHash block areas; determine a second target number of first candidate GeoHash blocks to be included in the target geofence based on the target area and the candidate area, and determine whether the second target number is within a preset target number of GeoHash blocks; if so, determine the first candidate GeoHash length as the target GeoHash length; if not, randomly select a second candidate GeoHash length, update the selected second candidate GeoHash length to the first candidate GeoHash length, and determine the candidate area of ​​candidate GeoHash blocks having a length equal to the first candidate GeoHash length, until the target GeoHash length is determined.

[0098] In one possible implementation, the determination module 502 is specifically configured to determine, starting from a first GeoHash block containing preset location information of the target geofence, whether a second GeoHash block adjacent to the first GeoHash block and unrecognized is located within the target geofence; if so, updating the second GeoHash block to the first GeoHash block and marking the second GeoHash block as an unrecognized GeoHash block, until each target GeoHash block included in the target geofence is determined.

[0099] In one possible implementation, the determination module 502 is specifically configured to determine a first longitude and latitude range corresponding to a second GeoHash block that is adjacent to the first GeoHash block and has not been identified, and determine whether the first longitude and latitude range is within a second longitude and latitude range corresponding to the target geofence; if so, determining that the second GeoHash block is within the target geofence; if not, determining that the second GeoHash block is not within the target geofence.

[0100] Example 5:

[0101] On the basis of the above embodiments, an embodiment of the present invention further provides an electronic device, such as Figure 6 As shown, it includes: a processor 601 , a communication interface 602 , a memory 603 and a communication bus 604 , wherein the processor 601 , the communication interface 602 and the memory 603 communicate with each other via the communication bus 604 .

[0102] The memory 603 stores a computer program. When the program is executed by the processor 601, the processor 601 performs the following steps:

[0103] Build target geo-fences based on the location information of the geographic visualization range;

[0104] Obtaining a target area of ​​the target geo-fence, and determining a target GeoHash length based on the target area;

[0105] Determine each target GeoHash block contained in the target geofence, and for each target GeoHash block, determine and save a target GeoHash code corresponding to the target GeoHash block based on the location information of the target GeoHash block, where the length of the target GeoHash code is the target GeoHash length.

[0106] Furthermore, the processor 601 is further configured to determine a target average area of ​​each GeoHash block in the target geofence based on the target area of ​​the target geofence and a preset first target number of GeoHash blocks; and determine a target GeoHash length corresponding to the target average area based on a pre-stored correspondence between GeoHash length and GeoHash block area.

[0107] Furthermore, the processor 601 is further configured to randomly select a first candidate GeoHash length, and determine a candidate area of ​​each first candidate GeoHash block corresponding to the first candidate GeoHash length based on a pre-stored correspondence between GeoHash lengths and GeoHash block areas; determine a second target number of first candidate GeoHash blocks to be included in the target geofence based on the target area and the candidate area, and determine whether the second target number is within a preset target number of GeoHash blocks; if so, determine the first candidate GeoHash length as the target GeoHash length; if not, randomly select a second candidate GeoHash length, update the selected second candidate GeoHash length to the first candidate GeoHash length, and determine the candidate area of ​​candidate GeoHash blocks having a length equal to the first candidate GeoHash length, until the target GeoHash length is determined.

[0108] Furthermore, the processor 601 is further configured to determine, starting from a first GeoHash block containing the preset location information of the target geofence, whether a second GeoHash block adjacent to the first GeoHash block and unrecognized is located in the target geofence; if so, update the second GeoHash block to the first GeoHash block and mark the second GeoHash block as an unrecognized GeoHash block, until each target GeoHash block included in the target geofence is determined.

[0109] Furthermore, the processor 601 is further configured to determine a first longitude and latitude range corresponding to a second GeoHash block that is adjacent to the first GeoHash block and has not been identified, and determine whether the first longitude and latitude range is within a second longitude and latitude range corresponding to the target geofence; if so, determining that the second GeoHash block is within the target geofence; if not, determining that the second GeoHash block is not within the target geofence.

[0110] The communication bus mentioned in the server above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is used in the figure, but this does not mean that there is only one bus or only one type of bus.

[0111] The communication interface 602 is used for communication between the electronic device and other devices.

[0112] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk memory. Alternatively, the memory may be at least one storage device located away from the processor.

[0113] The above-mentioned processor can be a general-purpose processor, including a central processing unit, a network processor (NP), etc.; it can also be a digital signal processing processor (DSP), an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc.

[0114] Example 6:

[0115] Based on the above embodiments, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program executable by an electronic device. When the program is executed on the electronic device, the electronic device implements the following steps:

[0116] The memory stores a computer program, which, when executed by the processor, causes the processor to perform the following steps:

[0117] Build target geo-fences based on the location information of the geographic visualization range;

[0118] Obtaining a target area of ​​the target geo-fence, and determining a target GeoHash length based on the target area;

[0119] Determine each target GeoHash block contained in the target geofence, and for each target GeoHash block, determine and save a target GeoHash code corresponding to the target GeoHash block based on the location information of the target GeoHash block, where the length of the target GeoHash code is the target GeoHash length.

[0120] Furthermore, determining a target GeoHash length according to the target area includes:

[0121] Determining a target average area of ​​each GeoHash block in the target geofence based on the target area of ​​the target geofence and a preset first target number of GeoHash blocks;

[0122] The target GeoHash length corresponding to the target average area is determined according to the pre-saved correspondence between the GeoHash length and the area of ​​the GeoHash block.

[0123] Furthermore, determining a target GeoHash length according to the target area includes:

[0124] Randomly select a first candidate GeoHash length, and determine the candidate area of ​​each first candidate GeoHash block corresponding to the first candidate GeoHash length based on the pre-saved correspondence between GeoHash length and GeoHash block area;

[0125] determining, based on the target area and the candidate area, a second target number of first candidate GeoHash blocks included in the target geo-fence, and determining whether the second target number is within a preset range of a target number of GeoHash blocks;

[0126] If yes, the first candidate GeoHash length is determined as the target GeoHash length;

[0127] If not, a second candidate GeoHash length is randomly selected, and the selected second candidate GeoHash length is updated to the first candidate GeoHash length. The candidate area of ​​the candidate GeoHash block with the length of the first candidate GeoHash length is determined until the target GeoHash length is determined.

[0128] Furthermore, determining each target GeoHash block contained in the target geofence includes:

[0129] Taking a first GeoHash block containing the preset location information of the target geofence as a starting point, determining whether a second GeoHash block adjacent to the first GeoHash block and unrecognized is located within the target geofence;

[0130] If so, the second GeoHash block is updated to the first GeoHash block, and the second GeoHash block is marked as an unrecognized GeoHash block until each target GeoHash block included in the target geofence is determined.

[0131] Furthermore, the location information includes:

[0132] At least one of longitude and latitude;

[0133] The first GeoHash block containing the preset position information of the target geofence is taken as a starting point to determine whether a second GeoHash block adjacent to the first GeoHash block and not identified is located in the target geofence.

[0134] A first latitude-longitude range corresponding to the second GeoHash block adjacent to the first GeoHash block and not identified is determined, and it is determined whether the first latitude-longitude range is located in a second latitude-longitude range corresponding to the target geofence, if yes, it is determined that the second GeoHash block is located in the target geofence, and if no, it is determined that the second GeoHash block is not located in the target geofence.

[0135] In the embodiment of the present application, the target GeoHash length of each GeoHash block is determined according to the target area of the target geofence, and for each target GeoHash block contained in the target geofence, the target GeoHash encoding with the length of the target GeoHash length of the target GeoHash block is determined and saved, so that the length of the GeoHash encoding suitable in length can be selected according to the area of the constructed target geofence, and the number of the corresponding GeoHash encoding in the target geofence is ensured to be appropriate, the saved target GeoHash encoding is prevented from being too much, and the accuracy of the range represented by the GeoHash encoding is ensured.

[0136] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer usable program code.

[0137] The present application is described with reference to flowcharts and / or block diagrams of the method, device (system), and computer program product according to the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of the flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device that implements the functions specified in the flowcharts and / or block diagrams. Figure 1 The functions specified in one flow or multiple flows and / or blocks Figure 1 The device that implements the functions specified in one flow or multiple flows and / or blocks.

[0138] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0139] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0140] Obviously, those skilled in the art may make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if such changes and modifications fall within the scope of the claims and their equivalents, the present invention is intended to include such changes and modifications.

Claims

1. A method for determining a geocoding GeoHash, characterized in that: The method comprises: Build target geo-fences based on the location information of the geographic visualization range; Obtaining a target area of ​​the target geo-fence, and determining a target GeoHash length based on the target area; Determine each target GeoHash block contained in the target geofence, and for each target GeoHash block, determine and save a target GeoHash code corresponding to the target GeoHash block based on the location information of the target GeoHash block, where the length of the target GeoHash code is the target GeoHash length; The step of determining the target GeoHash length according to the target area includes: Determining a target average area of ​​each GeoHash block in the target geofence based on the target area of ​​the target geofence and a preset first target number of GeoHash blocks; Determine the target GeoHash length corresponding to the target average area based on the pre-saved correspondence between GeoHash length and GeoHash block area; Randomly select a first candidate GeoHash length, and determine the candidate area of ​​each first candidate GeoHash block corresponding to the first candidate GeoHash length based on the pre-saved correspondence between GeoHash length and GeoHash block area; determining, based on the target area and the candidate area, a second target number of first candidate GeoHash blocks included in the target geo-fence, and determining whether the second target number is within a preset range of a target number of GeoHash blocks; If yes, the first candidate GeoHash length is determined as the target GeoHash length; If not, a second candidate GeoHash length is randomly selected, and the selected second candidate GeoHash length is updated to the first candidate GeoHash length. The candidate area of ​​the candidate GeoHash block with the length of the first candidate GeoHash length is determined until the target GeoHash length is determined.

2. The method according to claim 1, characterized in that Determining each target GeoHash block contained within the target geofence includes: Taking a first GeoHash block containing the preset location information of the target geofence as a starting point, determining whether a second GeoHash block adjacent to the first GeoHash block and unrecognized is located within the target geofence; If so, the second GeoHash block is updated to the first GeoHash block, and the second GeoHash block is marked as an unrecognized GeoHash block until each target GeoHash block included in the target geofence is determined.

3. The method according to claim 2, characterized in that The location information includes: At least one of longitude and latitude; The determining, starting from a first GeoHash block including the preset location information of the target geofence, whether a second GeoHash block adjacent to the first GeoHash block and unrecognized is located within the target geofence includes: Determine a first longitude and latitude range corresponding to a second GeoHash block that is adjacent to the first GeoHash block and has not been identified, and determine whether the first longitude and latitude range is within a second longitude and latitude range corresponding to the target geofence; if so, determine that the second GeoHash block is within the target geofence; if not, determine that the second GeoHash block is not within the target geofence.

4. A device for determining a geocoding GeoHash, characterized in that: The device comprises: A construction module, for constructing a target geo-fence according to location information of a geo-visualization range; a determination module, configured to obtain a target area of ​​the target geofence and determine a target GeoHash length based on the target area; determine each target GeoHash block contained in the target geofence, and for each target GeoHash block, determine and store a target GeoHash code corresponding to the target GeoHash block based on the location information of the target GeoHash block, wherein the length of the target GeoHash code is the target GeoHash length; The determination module is specifically configured to determine a target average area of ​​each GeoHash block in the target geofence based on the target area of ​​the target geofence and a preset first target number of GeoHash blocks; determine a target GeoHash length corresponding to the target average area based on a pre-stored correspondence between GeoHash lengths and GeoHash block areas; randomly select a first candidate GeoHash length, and determine a candidate area of ​​each first candidate GeoHash block corresponding to the first candidate GeoHash length based on a pre-stored correspondence between GeoHash lengths and GeoHash block areas; and determine a target average area of ​​each first candidate GeoHash block corresponding to the target average area based on the pre-stored correspondence between GeoHash lengths and GeoHash block areas. The target area and the candidate area are compared to determine a second target number of first candidate GeoHash blocks contained in the target geofence, and whether the second target number is within a preset target number of GeoHash blocks. If so, the first candidate GeoHash length is determined as the target GeoHash length. If not, a second candidate GeoHash length is randomly selected, the selected second candidate GeoHash length is updated as the first candidate GeoHash length, and the candidate area of ​​candidate GeoHash blocks having a length equal to the first candidate GeoHash length is determined until the target GeoHash length is determined.

5. An electronic device, characterized in that: The electronic device comprises a processor, and the processor is configured to implement the steps of the method according to any one of claims 1 to 3 when executing a computer program stored in a memory.

6. A computer-readable storage medium, characterized in that The device stores a computer program, which implements the steps of the method according to any one of claims 1 to 3 when executed by a processor.

Citation Information

Patent Citations

  • Geographic index coding method and device, electronic equipment and readable storage medium

    CN111475747A

  • Electronic fence loading method and device, equipment and storage medium

    CN112333635A