Geographic position encoding method, decoding method and apparatus
By determining the length of the encoded characters and calculating the granularity of longitude and latitude, the grid index is directly obtained for geocoding, which solves the problem of low encoding efficiency in existing technologies and achieves a more efficient encoding process.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHENGDU CELIS TECH CO LTD
- Filing Date
- 2025-12-05
- Publication Date
- 2026-04-17
AI Technical Summary
Existing technologies for geolocation coding are inefficient, especially when using a binary search method with high computational complexity.
By determining the length of the encoded characters, calculating the granularity of longitude and latitude division, directly obtaining the grid longitude and latitude indexes, and using the geocoding mapping relationship for encoding conversion, the binary search loop is avoided.
It improves the efficiency of geolocation coding, reduces computational complexity, and increases coding speed.
Smart Images

Figure CN121283575B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of geographic information technology, and in particular to a geographic location encoding method, decoding method and apparatus. Background Technology
[0002] In Geographic Information Systems (GIS), latitude and longitude coordinates need to be encoded and decoded to improve processing efficiency, protect user privacy, and facilitate indexing by business operations. Geohash is a commonly used geographic location encoding and decoding technique that divides the Earth's surface into multiple grids and converts latitude and longitude coordinates into strings based on the grid they belong to.
[0003] In related technologies, a binary search method is used to continuously narrow down the upper and lower limits of the interval, determine the grid where the latitude and longitude are located, and then convert the latitude and longitude into a string.
[0004] However, the above-mentioned geolocation coding method is inefficient. Summary of the Invention
[0005] Therefore, it is necessary to provide a geolocation encoding method, decoding method, and apparatus that can improve encoding efficiency in response to the above-mentioned technical problems.
[0006] Firstly, this application provides a geolocation coding method, including:
[0007] Obtain the longitude and latitude to be encoded corresponding to the target location;
[0008] Based on the longitude to be encoded and the longitude division granularity, the grid longitude index of the longitude to be encoded is determined, and based on the latitude to be encoded and the latitude division granularity, the grid latitude index of the latitude to be encoded is determined; the longitude division granularity and latitude division granularity are determined according to the length of the encoded character; the longitude division granularity represents the fineness of the grid division of the global longitude range, and the latitude division granularity represents the fineness of the grid division of the global latitude range;
[0009] Based on grid longitude and grid latitude indexes, a global index sequence for the target location is determined. Then, according to the geocoding mapping relationship, the global index sequence is encoded and converted to obtain the target geocode corresponding to the target location.
[0010] In one embodiment, the geolocation encoding method further includes:
[0011] The global bit length is determined based on the encoded character length and the basic bit length; the basic bit length is the number of bits corresponding to one character in the geocoding mapping relationship.
[0012] The global bit length is divided into longitude bit length and latitude bit length;
[0013] The granularity of longitude division is determined based on the longitude bit length, and the granularity of latitude division is determined based on the latitude bit length.
[0014] In one embodiment, determining the longitude division granularity based on the longitude bit length and determining the latitude division granularity based on the latitude bit length includes:
[0015] Based on the longitude bit length and preset base, the number of longitude divisions is determined to obtain the longitude division granularity; similarly, based on the latitude bit length and preset base, the number of latitude divisions is determined to obtain the latitude division granularity.
[0016] or,
[0017] Based on the longitude bit length and preset base, the number of longitude divisions is determined, and based on the number of longitude divisions and the global longitude range, the grid longitude span is determined, thus obtaining the longitude division granularity; based on the latitude bit length and preset base, the number of latitude divisions is determined, and based on the number of latitude divisions and the global latitude range, the grid latitude span is determined, thus obtaining the latitude division granularity.
[0018] In one embodiment, the longitude division granularity is the grid longitude span, and the latitude division granularity is the grid latitude span; based on the longitude to be encoded and the longitude division granularity, the grid longitude index of the longitude to be encoded is determined, and based on the latitude to be encoded and the latitude division granularity, the grid latitude index of the latitude to be encoded is determined, including:
[0019] The difference between the longitude to be encoded and the starting longitude of the global longitude range is processed to obtain the longitude difference value, and the difference between the latitude to be encoded and the starting latitude of the global latitude range is processed to obtain the latitude difference value;
[0020] The ratio of longitude difference to grid longitude span is rounded to obtain the grid longitude index of the longitude to be encoded, and the ratio of latitude difference to grid latitude span is rounded to obtain the grid latitude index of the longitude to be encoded.
[0021] In one embodiment, a global index sequence for the target location is determined based on the grid longitude index and the grid latitude index, including:
[0022] The grid longitude index is converted according to the preset base to obtain the longitude bit sequence, and the grid latitude index is converted according to the preset base to obtain the latitude bit sequence;
[0023] According to the preset mixing rules, the longitude bit sequence and the latitude bit sequence are mixed to obtain the global index sequence;
[0024] Based on the geocoding mapping relationship, the global index sequence is encoded and converted to obtain the target geocode corresponding to the target location, including:
[0025] The global index sequence is split according to the basic bit length to obtain each group of sub-global sequences; where the basic bit length is the number of bits corresponding to one character in the geocoding mapping relationship;
[0026] Based on the geocoding mapping relationship, each group of sub-global sequences is converted into the corresponding characters;
[0027] Based on the order of each sub-global sequence in the global index sequence, the corresponding characters are arranged sequentially to obtain the target geocode corresponding to the target location.
[0028] Secondly, this application also provides a geolocation decoding method, including:
[0029] Obtain the geocode to be decoded;
[0030] Based on the geocoding mapping relationship, the geocode to be decoded is decoded and converted to obtain the global index sequence corresponding to the geocode to be decoded. Based on the global index sequence, the grid longitude index and grid latitude index are determined.
[0031] Based on the grid longitude index and longitude division granularity, the target longitude of the geocode to be decoded is determined, and based on the grid latitude index and latitude division granularity, the target latitude of the geocode to be decoded is determined. The longitude division granularity and latitude division granularity are determined according to the length of the encoded characters. The longitude division granularity represents the fineness of the grid division of the global longitude range, and the latitude division granularity represents the fineness of the grid division of the global latitude range.
[0032] In one embodiment, the longitude division granularity is the longitude grid span, and the latitude division granularity is the latitude grid span; the target longitude to be decoded geocoding is determined based on the grid longitude index and the longitude division granularity, and the target latitude to be decoded geocoding is determined based on the grid latitude index and the latitude division granularity, including:
[0033] The longitude index and longitude grid span of the grid are multiplied to obtain the longitude product value, and the latitude index and latitude grid span of the grid are multiplied to obtain the latitude product value;
[0034] The target longitude is obtained based on the longitude product, the starting longitude of the global longitude range, and the longitude compensation value. Similarly, the target latitude is obtained based on the latitude product, the starting latitude of the global latitude range, and the latitude compensation value.
[0035] In one embodiment, based on the geocoding mapping relationship, the geocode to be decoded is decoded and converted to obtain the global index sequence corresponding to the geocode to be decoded, including:
[0036] Based on the geocoding mapping relationship, each character in the geocoding to be decoded is converted into a corresponding sub-global sequence;
[0037] Arrange the corresponding sub-global columns in the order in which each character is arranged in the geocode to be decoded, and obtain the global index sequence corresponding to the geocode to be decoded.
[0038] Based on the global index sequence, the grid longitude index and grid latitude index are determined, including:
[0039] According to the preset mixing rules, the global index sequence is split to obtain the longitude bit sequence and the latitude bit sequence;
[0040] The longitude bit sequence is converted according to the preset base to obtain the grid longitude index, and the latitude bit sequence is converted according to the preset base to obtain the grid latitude index.
[0041] Thirdly, this application also provides a geolocation coding device, comprising:
[0042] The first acquisition module is used to acquire the longitude and latitude to be encoded corresponding to the target location;
[0043] The first calculation module is used to determine the grid longitude index of the longitude to be encoded based on the longitude to be encoded and the longitude division granularity, and to determine the grid latitude index of the latitude to be encoded based on the latitude to be encoded and the latitude division granularity; the longitude division granularity and the latitude division granularity are determined according to the length of the encoded character; the longitude division granularity represents the fineness of the grid division of the global longitude range, and the latitude division granularity represents the fineness of the grid division of the global latitude range;
[0044] The first mapping module is used to determine the global index sequence of the target location based on the grid longitude index and the grid latitude index, and to encode the global index sequence according to the geocoding mapping relationship to obtain the target geocode corresponding to the target location.
[0045] Fourthly, this application also provides a geolocation decoding device, comprising:
[0046] The second acquisition module is used to acquire the geocode to be decoded;
[0047] The second mapping module is used to decode and transform the geocode to be decoded according to the geocode mapping relationship, obtain the global index sequence corresponding to the geocode to be decoded, and determine the grid longitude index and grid latitude index based on the global index sequence.
[0048] The second calculation module is used to determine the target longitude of the geocode to be decoded based on the grid longitude index and longitude division granularity, and to determine the target latitude of the geocode to be decoded based on the grid latitude index and latitude division granularity. The longitude division granularity and latitude division granularity are determined according to the length of the encoded characters. The longitude division granularity represents the fineness of the grid division of the global longitude range, and the latitude division granularity represents the fineness of the grid division of the global latitude range.
[0049] The aforementioned geographic location encoding method, decoding method, and apparatus, wherein the encoding method includes obtaining the longitude and latitude to be encoded corresponding to the target location; determining the grid longitude index of the longitude to be encoded based on the longitude to be encoded and the longitude division granularity, and determining the grid latitude index of the latitude to be encoded based on the latitude to be encoded and the latitude division granularity; determining the global index sequence of the target location based on the grid longitude index and the grid latitude index, and performing encoding conversion on the global index sequence according to the geographic encoding mapping relationship to obtain the target geographic code corresponding to the target location; the longitude division granularity and the latitude division granularity are determined according to the length of the encoded characters; the longitude division granularity represents the fineness of the grid division of the global longitude range, and the latitude division granularity represents the fineness of the grid division of the global latitude range. Thus, after determining the longitude and latitude granularity based on the length of the encoded characters, the grid longitude index and grid latitude index are calculated directly based on the longitude granularity. The global index sequence of the target location is then determined based on the grid longitude index and grid latitude index. This avoids the problem of high computational complexity and low coding efficiency caused by using a binary search method to determine the grid where the longitude and latitude to be encoded are located, as is the case in related technologies. The geographic location coding method provided in the above embodiment can improve the efficiency of geographic location coding. Attached Figure Description
[0050] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0051] Figure 1 This is a diagram illustrating the application environment of a geolocation coding method in one embodiment;
[0052] Figure 2 This is a flowchart illustrating a geolocation coding method in one embodiment;
[0053] Figure 3 This is a flowchart illustrating the steps for determining the granularity of longitude and latitude in one embodiment;
[0054] Figure 4 This is a flowchart illustrating the steps for obtaining the global index sequence in one embodiment;
[0055] Figure 5 This is a flowchart illustrating the geolocation coding method in another embodiment;
[0056] Figure 6 This is a flowchart illustrating a geographic location decoding method in one embodiment;
[0057] Figure 7 This is a flowchart illustrating the steps for obtaining the target longitude and target latitude in one embodiment;
[0058] Figure 8 This is a flowchart illustrating the geolocation decoding method in another embodiment;
[0059] Figure 9 This is a structural block diagram of a geolocation encoding device in one embodiment;
[0060] Figure 10 This is a structural block diagram of a geographic location decoding device in one embodiment;
[0061] Figure 11 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0062] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0063] It should be noted that the terms "first," "second," etc., used in this application can be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from the second element. The terms "comprising" and "having," and any variations thereof, used in this application, are intended to cover non-exclusive inclusion. The term "multiple" used in this application refers to two or more. The term "and / or" used in this application refers to one of the embodiments, or any combination of multiple embodiments.
[0064] The geolocation coding method provided in this application can be applied to, for example... Figure 1In the application environment shown, terminal 102 communicates with server 104 via a grid. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or located in the cloud or on other grid servers. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, drones, low-altitude aircraft, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, projection devices, etc. Portable wearable devices can include smartwatches, smart bracelets, head-mounted devices, etc. Head-mounted devices can be virtual reality (VR) devices, augmented reality (AR) devices, smart glasses, etc. Server 104 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.
[0065] In one exemplary embodiment, please refer to Figure 2 This paper provides a geolocation coding method, which can be applied to... Figure 1 Taking terminal 102 as an example, it can be understood that this method can also be applied to servers, and to systems that include both terminals and servers, and is implemented through the interaction between the terminal and the server. Figure 2 As shown, the method includes steps 202 to 206. Wherein:
[0066] Step 202: Obtain the longitude and latitude to be encoded corresponding to the target location.
[0067] The longitude and latitude to be encoded can be collectively referred to as the geographic coordinates to be encoded, which are the coordinate values of the target geographic location that need to be converted into Geohash encoding. For example, the data format of the longitude and latitude to be encoded is floating-point numbers. For instance, the longitude to be encoded is 121.43960190000007°, and the latitude to be encoded is 31.1932993°. For example, the longitude and latitude of the target location to be encoded are input into the encoding device by the business system according to current business requirements.
[0068] Step 204: Based on the longitude to be encoded and the longitude division granularity, determine the grid longitude index of the longitude to be encoded, and based on the latitude to be encoded and the latitude division granularity, determine the grid latitude index of the latitude to be encoded.
[0069] The longitude and latitude granularity are determined based on the length of the encoded characters. Longitude granularity indicates the fineness of grid division across the global longitude range, while latitude granularity indicates the fineness of grid division across the global latitude range. The encoded character length refers to the length of the encoded string to be generated, such as the Geohash encoded string. A longer encoded character length corresponds to a finer grid division. The encoded character length can be odd or even, for example, 6 or 7 characters. For example, the encoded character length is determined by the business system calling the encoding method based on the required geographic precision or grid granularity. For example, in a specific software, the encoded character length is a fixed value, and correspondingly, the longitude and latitude granularity are pre-stored fixed values. Yet another example, the encoded character length is a variable obtained in real-time based on specific application requirements; correspondingly, the longitude and latitude granularity need to be determined in real-time based on the encoded character length during the encoding process.
[0070] In one possible implementation, geolocation coding covers the entire Earth's surface, with a global longitude range of -180° to 180° and a global latitude range of -90° to 90°. In some possible implementations, geolocation coding covers a portion of the Earth's surface, such as a specific region, with the global longitude and global latitude ranges determined based on the latitude and longitude of the region's four boundaries.
[0071] In one possible implementation, after determining the total number of bits to be generated based on the length of the encoded characters, the total number of bits is allocated to longitude and latitude, thereby determining the longitude division granularity and the latitude division granularity.
[0072] Optionally, the grid longitude index of the longitude to be encoded refers to which grid the longitude to be encoded is in the global longitude range grid division, and the grid latitude index of the latitude to be encoded refers to which grid the latitude to be encoded is in the global latitude range grid division; the grid longitude index and the grid latitude index are non-negative decimal integers.
[0073] Step 206: Based on the grid longitude index and grid latitude index, determine the global index sequence of the target location, and according to the geocoding mapping relationship, encode the global index sequence to obtain the target geocode corresponding to the target location.
[0074] The global index sequence refers to the sequence data formed by converting the longitude grid index and latitude grid index into a preset base sequence and then arranging them according to specific rules.
[0075] The geocoding mapping relationship refers to a mapping relationship that converts a preset positional numeral system into Geohash encoded characters. For example, the geocoding mapping relationship uses a mapping relationship that converts binary bits into Geohash encoded characters, as shown in Table 1.
[0076] Table 1, Examples of Geocoding Mapping Relationships
[0077]
[0078] The geolocation coding method provided in the above embodiments obtains the length of the coded characters and the longitude and latitude to be coded corresponding to the target location; based on the longitude to be coded and the longitude division granularity, it determines the grid longitude index of the longitude to be coded, and based on the latitude to be coded and the latitude division granularity, it determines the grid latitude index of the latitude to be coded; based on the grid longitude index and the grid latitude index, it determines the global index sequence of the target location, and performs coding transformation on the global index sequence according to the geocoding mapping relationship to obtain the target geocode corresponding to the target location; the longitude division granularity and the latitude division granularity are determined according to the length of the coded characters; the longitude division granularity represents the fineness of the grid division of the global longitude range, and the latitude division granularity represents the fineness of the grid division of the global latitude range. Thus, after determining the longitude and latitude granularity based on the length of the encoded characters, the grid longitude index and grid latitude index are directly calculated. The global index sequence of the target location is then determined based on the grid longitude index and grid latitude index. This avoids the problem of high computational complexity and low coding efficiency caused by using a binary search method to determine the grid where the longitude and latitude to be encoded are located, as is the case in related technologies. The geographic location coding method provided in the above embodiment can improve the efficiency of geographic location coding.
[0079] In one exemplary embodiment, based on Figure 2 The illustrated embodiment pertains to the process of determining the granularity of longitude and latitude division. For example... Figure 3 As shown, the process includes steps 302 to 306, wherein:
[0080] Step 302: Determine the global bit length based on the encoded character length and the basic bit length.
[0081] The basic bit length is the number of bits corresponding to one character in the geocoding mapping relationship.
[0082] The global bit length is equal to the product of the encoded character length and the basic bit length. For example, in the geocoding mapping relationship shown in Table 1, a 32-character code table is used to map bits to Geohash characters, so 5 bits map to one Geohash character. For instance, the encoded character length is 6, the basic bit length is 5, and the global bit length is 30; or, for another example, the encoded character length is 7, the basic bit length is 5, and the global bit length is 35.
[0083] Step 304: Divide the global bit length into longitude bit length and latitude bit length.
[0084] In one possible implementation, the encoded character length is an even number, and correspondingly, the global bit length is also an even number, with the longitude bit length equal to the latitude bit length, both being half the global bit length. For example, the encoded character length is 6, the global bit length is 30 bits, and the longitude and latitude bit lengths are both 15 bits.
[0085] In one possible implementation, the encoded character length is odd, and correspondingly, the global bit length is also odd, with the longitude bit length being one more than the latitude bit length. For example, the encoded character length is 7, the global bit length is 35, the longitude bit length is 18 bits, and the latitude bit length is 17 bits. Thus, in scenarios where the global longitude range is larger than the global latitude range, such as in scenarios involving geolocation coding of the entire Earth's surface, the finer granularity of the longitude division results in a grid that is closer to a square, improving the uniformity of the grid division.
[0086] Step 306: Determine the longitude division granularity based on the longitude bit length, and determine the latitude division granularity based on the latitude bit length.
[0087] In one possible implementation, the longitude division granularity is the number of longitude divisions, and the latitude division granularity is the number of latitude divisions. In this implementation, the process of determining the longitude division granularity based on the longitude bit length and the latitude division granularity based on the latitude bit length includes: determining the number of longitude divisions based on the longitude bit length and a preset base to obtain the longitude division granularity; and determining the number of latitude divisions based on the latitude bit length and a preset base to obtain the latitude division granularity.
[0088] For example, the preset base is binary, the longitude bit length is n, the latitude bit length is m, and the number of longitude divisions is 2. n The number of latitude divisions is 2 m For example, when n=m=15, the number of longitude divisions and the number of latitude divisions are both 2. 15 =32768. For example, when n=18 and m=17, the number of longitude divisions is 2. 18=262144, the number of latitude divisions is 2 17 =131072.
[0089] The longer the encoded character length, the longer the corresponding longitude bit length and latitude bit length, and the more longitude and latitude divisions there are. This indicates a more refined grid division of the global longitude and latitude ranges, resulting in higher accuracy of the subsequent encoding results and more precise positioning.
[0090] In this embodiment, the longitude division granularity and latitude division granularity are defined as the longitude division quantity and latitude division quantity, respectively. Both the longitude division quantity and latitude division quantity are integers, which are convenient for representation and storage. In some implementations, the longitude division quantity and latitude division quantity corresponding to various character encoding lengths are pre-stored and directly called during the encoding process without real-time calculation, thereby improving encoding efficiency.
[0091] In this embodiment, the process of determining the grid longitude index and grid latitude index based on the number of longitude divisions and the number of latitude divisions can refer to the subsequent implementation method that defines the longitude division granularity and latitude division granularity as the grid longitude span and the grid latitude span, respectively.
[0092] In one possible implementation, the longitude division granularity is the grid longitude span, and the latitude division granularity is the grid latitude span. In this implementation, the process of determining the longitude division granularity based on the longitude bit length and the latitude division granularity based on the latitude bit length includes: determining the number of longitude divisions based on the longitude bit length and a preset base, and determining the grid longitude span based on the number of longitude divisions and the global longitude range, thus obtaining the longitude division granularity; determining the number of latitude divisions based on the latitude bit length and a preset base, and determining the grid latitude span based on the number of latitude divisions and the global latitude range, thus obtaining the latitude division granularity.
[0093] Among them, the grid longitude span refers to the number of angles of a grid in the longitude direction, and the grid latitude span refers to the number of angles of a grid in the latitude direction.
[0094] For example, with a global latitude range of -180° to 180°, the grid longitude span is: (180° - (-180°)) / 2 n With a global latitude range of -90° to 90°, the grid latitude span is (90° - (-90°)) / 2 mFor example, when n=m=15, the grid longitude span is (180°-(-180°)) / 32768=360° / 32768; the grid latitude span is (90°-(-90°)) / 32768=180° / 32768. As another example, when n=18 and m=17, the grid longitude span is (180°-(-180°)) / 262144=360° / 262144; the grid latitude span is (90°-(-90°)) / 131072=180° / 131072.
[0095] The longer the encoded character length, the longer the corresponding longitude bit length and latitude bit length, and the smaller the corresponding grid longitude span and grid latitude span. This indicates a more refined grid division of the global longitude and global latitude ranges, resulting in higher accuracy of the subsequent encoding results and more precise positioning.
[0096] In this embodiment, the process of determining the grid longitude index of the longitude to be encoded based on the longitude to be encoded and the longitude division granularity, and the process of determining the grid latitude index of the latitude to be encoded based on the latitude to be encoded and the latitude division granularity, includes: performing difference processing on the longitude to be encoded and the starting longitude of the global longitude range to obtain a longitude difference value, and performing difference processing on the latitude to be encoded and the starting latitude of the global latitude range to obtain a latitude difference value; rounding the ratio of the longitude difference value to the grid longitude span to obtain the grid longitude index of the longitude to be encoded, and rounding the ratio of the latitude difference value to the grid latitude span to obtain the grid longitude index of the longitude to be encoded.
[0097] For example, the longitude to be encoded is A, the latitude to be encoded is B, the global longitude range is -180° to 180°, and the global latitude range is -90° to 90°. That is, the starting longitude is -180°, the starting latitude is -90°, the longitude difference is A - (-180.0°), and the latitude difference is B - (-90.0°). The grid longitude index is floor((A - (-180.0°)) / (360° / 2). n The grid latitude index is floor((B-(-90.0°)) / (180° / 2). m )); where floor represents the floor operation.
[0098] For example, if n=m=15 and A=121.43960190000007°, B=31.1932993°, the corresponding grid longitude index is floor((121.43960190000007°-(-180.0°)) / (360° / 32768))=27437, and the grid latitude index is floor((31.1932993°-(-90.0°)) / (180° / 32768))=22062.
[0099] For example, if n=18, m=17, and A=121.43960190000007°, B=31.1932993°, the corresponding grid longitude index is floor((121.43960190000007°-(-180.0°)) / (360° / 262144))= 219501, and the grid latitude index is floor((31.1932993°-(-90.0°)) / (180° / 131072))=88250.
[0100] In the above implementation, the longitude division granularity and latitude division granularity are defined as the longitude division span and latitude division span, which intuitively and clearly demonstrates the definition of the longitude division granularity and latitude division granularity, improving the convenience of implementation and code migration.
[0101] In one exemplary embodiment, based on Figure 2 The illustrated embodiment describes the process of determining a global index sequence for a target location based on grid longitude and grid latitude indexes. Figure 4 As shown, the process includes steps 402 to 404, wherein:
[0102] Step 402: Convert the grid longitude index according to the preset base to obtain the longitude bit sequence, and convert the grid latitude index according to the preset base to obtain the latitude bit sequence.
[0103] Optionally, the grid longitude index and grid latitude index are in decimal form, and the grid longitude index and grid latitude index are converted into bit sequences corresponding to preset bases respectively.
[0104] For example, the preset base is binary, the grid longitude index is 27437, the corresponding longitude bit sequence is 110101100101101, the grid latitude index is 27437, the corresponding latitude bit sequence is 101011000101110.
[0105] Step 404: According to the preset mixing rules, the longitude bit sequence and the latitude bit sequence are mixed to obtain the global index sequence.
[0106] In one possible implementation, the preset mixing rule is a cross-arrangement rule with longitude bits first and latitude bits last. Taking a longitude bit length and a latitude bit length of 15 as an example, the longitude bit sequence is a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15; the latitude bit sequence is b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, and the corresponding global index sequence is a1, b1, a2, b2, a3, b3, a4, b4, a5, b5, a6, b6, a7, b7, a8, b8, a9, b9, a10, b10, a11, b11, a12, b12, a13, b13, a14, b14, a15, b15.
[0107] For example, the longitude bit sequence is 110101100101101, the latitude bit sequence is 101011000101110, and the global index sequence is 111001100111100000110011110110.
[0108] In another possible implementation, the preset mixing rule is a cross-arrangement rule with latitude bits first and longitude bits last.
[0109] In the two aforementioned implementations that employ cross-arrangement rules, the prefixes of the corresponding global index sequences of two geographically close regions are highly similar, which can improve the search efficiency for needs such as nearby searches.
[0110] In another possible implementation, the preset mixing rule is an arrangement rule where the longitude bit sequence as a whole comes first and the longitude bit sequence as a whole comes last. Taking a longitude bit length and a latitude bit length of 15 as an example, the longitude bit sequence is a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15; the latitude bit sequence is b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, and the corresponding global index sequence is a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15.
[0111] In another possible implementation, the preset mixing rule is an arrangement rule where the latitude bit sequence comes first and the longitude bit sequence comes last.
[0112] In one possible implementation of this embodiment, the global index is encoded and converted according to the geocoding mapping relationship to obtain the target geocode corresponding to the target location, including steps A2 to A6, wherein:
[0113] Step A2: Split the global index sequence according to the basic bit length to obtain each group of sub-global sequences; where the basic bit length is the number of bits corresponding to one character in the geocoding mapping relationship.
[0114] Step A4: Based on the geocoding mapping relationship, convert each group of sub-global sequences into the corresponding characters.
[0115] For example, the global index sequence is 111001100111100000110011110110, with a basic bit length of 5. The sub-global sequences and corresponding characters of each group are shown in Table 2.
[0116] Table 2, Subglobal Sequences and Corresponding Character Examples
[0117]
[0118] Step A6: Arrange the corresponding characters sequentially according to the order of each sub-global sequence in the global index sequence to obtain the target geocode corresponding to the target location.
[0119] For example, the characters shown in Table 2 are sorted sequentially according to the order of each group of sub-global sequences in the global index sequence, resulting in the target geocode wtw37q.
[0120] In one possible implementation of this embodiment, the longitude bit sequence and latitude bit sequence are shifted right bit by bit according to a preset mixing rule and placed into the bit sequence corresponding to the global index sequence. The number of bits placed is counted. When the number of bits reaches the number of bits corresponding to the basic bit length (e.g., k), the k bits are converted into corresponding characters according to the geocoding mapping relationship. The characters are written into the string corresponding to the target geocode in the order of writing from the least significant bit to the most significant bit. The bit count is then cleared and restarted. When the number of bits reaches the number of bits corresponding to the basic bit length, the k bits are converted into corresponding characters and written into the second least significant bit of the string corresponding to the target geocode. This process is repeated until both the longitude bit sequence and latitude bit sequence have moved to the most significant bit, and the string corresponding to the target geocode is output.
[0121] For example, the preset mixing rule is an alternating arrangement of longitude first and latitude last, with a basic bit length of 5. The longitude bit sequence and latitude bit sequence are shifted to the right bit by bit and interleaved into the bit storage position corresponding to the global index sequence. When the number of bits placed reaches 5, the 5 bits are converted into the corresponding characters according to the geocoding mapping relationship. The characters are written into the string corresponding to the target geocode in the order of writing from the least significant bit to the most significant bit, i.e., the first character is written to the least significant bit of the string. The bit count is cleared. When the bit count can reach 5 again, the 5 bits are converted into the corresponding characters and written to the second least significant bit of the string. This process is repeated until both the longitude bit sequence and latitude bit sequence are moved to the most significant bit, and the string corresponding to the target geocode is output.
[0122] In this embodiment, during the process of obtaining the global index sequence, each group of sub-global sequences is obtained synchronously by shifting, and then mapped and converted into corresponding characters, thereby reducing the computational complexity of obtaining the target geocode and improving the efficiency of obtaining the target geocode.
[0123] In one exemplary embodiment, please refer to Figure 5 This paper provides a geolocation coding method, which can be applied to... Figure 1 Taking terminal 102 as an example, it can be understood that this method can also be applied to servers, and to systems that include both terminals and servers, and is implemented through the interaction between the terminal and the server. Figure 5 As shown, the method includes steps 502 to 524. Wherein:
[0124] Step 502: Obtain the length of the encoded character and the longitude and latitude to be encoded corresponding to the target position.
[0125] Step 504: Determine the global bit length based on the encoded character length and the basic bit length; the basic bit length is the number of bits corresponding to one character in the geocoding mapping relationship.
[0126] Step 506: Divide the global bit length into longitude bit length and latitude bit length.
[0127] Step 508: Determine the number of longitude divisions based on the longitude bit length and the preset base, and determine the number of latitude divisions based on the latitude bit length and the preset base.
[0128] Step 510: Determine the grid longitude span based on the number of longitude divisions and the global longitude range, and determine the grid latitude span based on the number of latitude divisions and the global latitude range.
[0129] Step 512: Perform difference processing on the longitude to be encoded and the starting longitude of the global longitude range to obtain the longitude difference value; and perform difference processing on the latitude to be encoded and the starting latitude of the global latitude range to obtain the latitude difference value.
[0130] Step 514: Round the ratio of longitude difference to grid longitude span to obtain the grid longitude index of the longitude to be encoded, and round the ratio of latitude difference to grid latitude span to obtain the grid latitude index of the longitude to be encoded.
[0131] Step 516: Convert the grid longitude index according to the preset base to obtain the longitude bit sequence, and convert the grid latitude index according to the preset base to obtain the latitude bit sequence.
[0132] Step 518: According to the preset mixing rules, the longitude bit sequence and latitude bit sequence are mixed to obtain the global index sequence.
[0133] Step 520: Based on the basic bit length, split the global index sequence to obtain each group of sub-global sequences.
[0134] Step 522: Based on the geocoding mapping relationship, convert each group of sub-global sequences into the corresponding characters.
[0135] Step 524: Arrange the corresponding characters sequentially according to the order of each group of sub-global sequences in the global index sequence to obtain the target geocode corresponding to the target location.
[0136] For example, using the encoding method provided in this embodiment, the longitude to be encoded is 121.43960190000007°, the latitude to be encoded is 31.1932993°, the preset mixing rule is a cross arrangement of longitude first and latitude last, the global longitude range is -180° to 180°, the global latitude range is -90° to 90°, according to the geocoding mapping relationship shown in Table 1, when the encoding character length is 6, the target geocoding is wtw37q, and when the encoding character length is 7, the target geocoding is wtw37qt.
[0137] In one exemplary embodiment, please refer to Figure 6 A geolocation decoding method is provided, which can be applied to... Figure 1 Taking terminal 102 as an example, it can be understood that this method can also be applied to servers, and to systems that include both terminals and servers, and is implemented through the interaction between the terminal and the server. Figure 6 As shown, the method includes steps 602 to 606. Wherein:
[0138] Step 602: Obtain the geocode to be decoded.
[0139] Step 604: Based on the geocoding mapping relationship, decode the geocode to be decoded to obtain the global index sequence corresponding to the geocode to be decoded, and determine the grid longitude index and grid latitude index based on the global index sequence.
[0140] Step 606: Determine the target longitude of the geocode to be decoded based on the grid longitude index and longitude division granularity, and determine the target latitude of the geocode to be decoded based on the grid latitude index and latitude division granularity; the longitude division granularity and latitude division granularity are determined according to the length of the encoded characters; the longitude division granularity represents the fineness of the grid division of the global longitude range, and the latitude division granularity represents the fineness of the grid division of the global latitude range.
[0141] In this embodiment, the method for determining the longitude and latitude granularity based on the encoded character length is the same as that in the encoding method embodiment. In one possible implementation, the correspondence between the encoded character length, longitude granularity, and latitude granularity is pre-calculated and stored in a designated location. After determining the encoded character length, the corresponding longitude and latitude granularity are directly obtained according to the pre-stored correspondence, thereby improving encoding and decoding efficiency.
[0142] The geographic location decoding method provided in the above embodiments calculates the target longitude of the geographic code to be decoded directly based on the grid longitude index and the longitude division granularity, and calculates the target latitude of the geographic code to be decoded directly based on the grid latitude index and the latitude division granularity. However, the grid longitude index and the grid latitude index can only define an area of one grid granularity, and cannot obtain the precise original longitude and latitude. Therefore, the above encoding method and the corresponding decoding method can protect user privacy.
[0143] In one exemplary embodiment, based on Figure 6 In the illustrated embodiment, the longitude division granularity is the longitude grid span, and the latitude division granularity is the latitude grid span; in this embodiment, as... Figure 7 As shown, the process of determining the target longitude of the geocode to be decoded based on the grid longitude index and longitude division granularity, and the process of determining the target latitude of the geocode to be decoded based on the grid latitude index and latitude division granularity, includes steps 702 to 704, wherein:
[0144] Step 702: Perform multiplication on the grid longitude index and longitude grid span to obtain the longitude product value, and perform multiplication on the grid latitude index and latitude grid span to obtain the latitude product value.
[0145] Step 704: Based on the longitude product, the starting longitude of the global longitude range, and the longitude compensation value, obtain the target longitude; and based on the latitude product, the starting latitude of the global latitude range, and the latitude compensation value, obtain the target latitude.
[0146] However, based on the grid longitude index and grid latitude index, only a region can be defined, and it cannot be mapped to a specific point within the grid.
[0147] In one approach, without setting longitude and latitude compensation values (i.e., when both longitude and latitude compensation values are zero), the target longitude obtained based on the longitude product and the starting longitude of the global longitude range is the left boundary longitude of the grid in the longitude direction. The target latitude obtained based on the latitude product and the starting latitude of the global latitude range is the upper boundary latitude of the grid in the latitude direction. Here, the left boundary refers to the boundary of the grid in the longitude direction that is close to the starting longitude, and the upper boundary refers to the boundary of the grid in the latitude direction that is close to the starting latitude.
[0148] In one implementation, longitude and latitude compensation values are determined based on the needs of the business system. For example, the center point of the grid is used as the decoding coordinate point corresponding to the geocode to be decoded; that is, the longitude compensation value is half the longitude span of the grid, and the latitude compensation value is half the latitude span of the grid.
[0149] For example, if the grid longitude index is 27437 and the longitude grid span is 360° / 32768, the corresponding longitude product is 27437*360° / 32768; if the grid latitude index is 22062 and the longitude grid span is 180° / 32768, the corresponding longitude product is 22062* 80.0° / 32768, the longitude compensation value is half the grid longitude span, which can be understood as adding 0.5 longitude grids to the grid longitude index. The longitude compensation value is half the grid latitude span, which can be understood as adding 0.5 dimension grids to the grid latitude index. Thus, the calculation process of the target longitude can be written as ((27437*360.0°+(360.0°*0.5)) / 32768)-360.0°*0.5=121.4373779296875°, and the calculation process of the target latitude can be written as ((22062*180.0°+(180.0°*0.5)) / 32768)-180.0°*0.5=31.19293212890625°.
[0150] In the encoding method example, with an encoding character length of 6, the grid longitude index corresponding to the longitude to be encoded 121.43960190000007° and the latitude to be encoded 31.1932993° is 27437, and the grid latitude index is 22062. After decoding this set of grid longitude and latitude indices, the target longitude and target latitude are close to the longitude and latitude before encoding, but not exactly the same, thus protecting user privacy while achieving user positioning.
[0151] In one exemplary embodiment, based on Figure 7 The embodiment shown describes a process of decoding and converting a geocode to be decoded according to a geocode mapping relationship to obtain a global index sequence corresponding to the geocode to be decoded. This process includes: converting each character in the geocode to be decoded into a corresponding sub-global sequence according to the geocode mapping relationship; and arranging the corresponding sub-global columns in sequence according to the order of each character in the geocode to be decoded to obtain a global index sequence corresponding to the geocode to be decoded.
[0152] For example, according to the geocoding mapping relationship shown in Table 1, the process of converting the geocode to be decoded wtw37qt into a subglobal sequence character by character is shown in Table 3.
[0153] Table 3. Examples of converting geographic information to be decoded into corresponding sub-global sequences
[0154]
[0155] Arrange all sub-global sequences according to the order of characters in the geocoding to be decoded to obtain the global index sequence 11100110011110000011001111011011001.
[0156] In this embodiment, the process of determining the grid longitude index and grid latitude index based on the global index sequence includes: splitting the global index sequence according to a preset mixing rule to obtain a longitude bit sequence and a latitude bit sequence; converting the longitude bit sequence according to a preset base to obtain the grid longitude index; and converting the latitude bit sequence according to a preset base to obtain the grid latitude index.
[0157] For example, the preset mixing rule is a cross arrangement of longitude first and latitude last. Therefore, when splitting the global index sequence, the odd-numbered bits in the global index sequence are extracted as the longitude bit sequence, and the even-numbered bits in the global index sequence are extracted as the latitude bit sequence.
[0158] Specifically, the longitude bit sequence is converted according to a preset base to obtain a decimal grid longitude index, and the latitude bit sequence is converted according to a preset base to obtain a decimal grid latitude index.
[0159] In one exemplary embodiment, please refer to Figure 8 A geolocation decoding method is provided, which can be applied to... Figure 1 Taking terminal 102 as an example, it can be understood that this method can also be applied to servers, and to systems that include both terminals and servers, and is implemented through the interaction between the terminal and the server. Figure 8 As shown, the method includes steps 802 to 816. Wherein:
[0160] Step 802: Obtain the geocode to be decoded.
[0161] Step 804: Based on the geocoding mapping relationship, convert each character in the geocoding to be decoded into a corresponding sub-global sequence.
[0162] Step 806: Arrange the corresponding sub-global columns in order of the order of each character in the geocode to be decoded to obtain the global index sequence corresponding to the geocode to be decoded.
[0163] Step 808: According to the preset mixing rules, the global index sequence is split to obtain the longitude bit sequence and the latitude bit sequence.
[0164] Step 810: Convert the longitude bit sequence according to the preset base to obtain the grid longitude index, and convert the latitude bit sequence according to the preset base to obtain the grid latitude index.
[0165] Step 812: Determine the longitude and latitude granularity based on the length of the encoded characters corresponding to the geocode to be decoded; the longitude granularity indicates the fineness of the grid division of the global longitude range, and the latitude granularity indicates the fineness of the grid division of the global latitude range.
[0166] Step 814: Perform multiplication on the grid longitude index and longitude grid span to obtain the longitude product value, and perform multiplication on the grid latitude index and latitude grid span to obtain the latitude product value.
[0167] Step 816: Based on the longitude product, the starting longitude of the global longitude range, and the longitude compensation value, obtain the target longitude; and based on the latitude product, the starting latitude of the global latitude range, and the latitude compensation value, obtain the target latitude.
[0168] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.
[0169] It is understood that the term "based on" as used in this application is used to describe one or more factors that influence the determination, but does not exclude other factors that may influence the determination. For example, the phrase "determine A based on B" means that the determination of A can be based entirely or at least partially on factor B. That is, B is a factor that influences the determination of A, but does not exclude the fact that the determination of A is also based on C.
[0170] Based on the same inventive concept, this application also provides a geolocation encoding apparatus for implementing the geolocation encoding method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more geolocation encoding apparatus embodiments provided below can be found in the limitations of the geolocation encoding method described above, and will not be repeated here.
[0171] In one exemplary embodiment, such as Figure 9 As shown, a geolocation encoding device is provided, comprising: a first acquisition module 902, a first calculation module 904, and a first mapping module 906, wherein:
[0172] The first acquisition module 902 is used to acquire the length of the encoded character and the longitude and latitude to be encoded corresponding to the target position.
[0173] The first calculation module 904 is used to determine the grid longitude index of the longitude to be encoded based on the longitude to be encoded and the longitude division granularity, and to determine the grid latitude index of the latitude to be encoded based on the latitude to be encoded and the latitude division granularity; the longitude division granularity and the latitude division granularity are determined according to the length of the encoded character; the longitude division granularity represents the fineness of the grid division of the global longitude range, and the latitude division granularity represents the fineness of the grid division of the global latitude range.
[0174] The first mapping module 906 is used to determine the global index sequence of the target location based on the grid longitude index and the grid latitude index, and to encode the global index sequence according to the geocoding mapping relationship to obtain the target geocode corresponding to the target location.
[0175] In an exemplary embodiment, the geolocation coding device further includes a first granularity partitioning module, which includes a bit unit, a longitude grid management unit, and a latitude grid management unit. The bit unit is used to determine the global bit length based on the encoded character length and the basic bit length. The basic bit length is the number of bits corresponding to one character in the geolocation mapping relationship, and the global bit length is divided into longitude bit length and latitude bit length. The longitude grid management unit is used to determine the longitude partitioning granularity based on the longitude bit length, and the latitude grid management unit is used to determine the latitude partitioning granularity based on the latitude bit length.
[0176] In an exemplary embodiment, the longitude grid cell is used to determine the number of longitude divisions based on the longitude bit length and a preset base, thereby obtaining the longitude division granularity; the latitude grid cell is used to determine the number of latitude divisions based on the latitude bit length and a preset base, thereby obtaining the latitude division granularity.
[0177] In an exemplary embodiment, the longitude grid cell is used to determine the number of longitude divisions based on the longitude bit length and a preset base, and to determine the grid longitude span based on the number of longitude divisions and the global longitude range, thus obtaining the longitude division granularity; the latitude grid cell is used to determine the number of latitude divisions based on the latitude bit length and a preset base, and to determine the grid latitude span based on the number of latitude divisions and the global latitude range, thus obtaining the latitude division granularity.
[0178] In an exemplary embodiment, the longitude division granularity is the grid longitude span, and the latitude division granularity is the grid latitude span; the first calculation module 904 is used to perform difference processing on the longitude to be encoded and the starting longitude of the global longitude range to obtain a longitude difference, and to perform difference processing on the latitude to be encoded and the starting latitude of the global latitude range to obtain a latitude difference; the ratio of the longitude difference to the grid longitude span is rounded to obtain the grid longitude index of the longitude to be encoded, and the ratio of the latitude difference to the grid latitude span is rounded to obtain the grid latitude index of the longitude to be encoded.
[0179] In an exemplary embodiment, the first mapping module 906 includes a first conversion and mixing unit and a first character mapping unit. The first conversion and mixing unit is used to convert the grid longitude index according to a preset base to obtain a longitude bit sequence, and to convert the grid latitude index according to a preset base to obtain a latitude bit sequence. It also mixes the longitude bit sequence and the latitude bit sequence according to a preset mixing rule to obtain a global index sequence. The first character mapping unit is used to split the global index sequence according to a basic bit length to obtain each group of sub-global sequences. The basic bit length is the number of bits corresponding to one character in the geocoding mapping relationship. Each group of sub-global sequences is converted into corresponding characters according to the geocoding mapping relationship. The corresponding characters are arranged sequentially according to the order of each group of sub-global sequences in the global index sequence to obtain the target geocoding corresponding to the target location.
[0180] Based on the same inventive concept, this application also provides a geographic location decoding apparatus for implementing the geographic location decoding method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more geographic location decoding apparatus embodiments provided below can be found in the limitations of the geographic location decoding method described above, and will not be repeated here.
[0181] In one exemplary embodiment, such as Figure 10 As shown, a geographic location decoding device is provided, including: a second acquisition module 1002, a second mapping module 1004, and a second calculation module 1006, wherein:
[0182] The second acquisition module 1002 is used to acquire the geocode to be decoded.
[0183] The second mapping module 1004 is used to decode and transform the geocode to be decoded according to the geocode mapping relationship, obtain the global index sequence corresponding to the geocode to be decoded, and determine the grid longitude index and grid latitude index based on the global index sequence.
[0184] The second calculation module 1006 is used to determine the target longitude of the geocode to be decoded based on the grid longitude index and longitude division granularity, and to determine the target latitude of the geocode to be decoded based on the grid latitude index and latitude division granularity. The longitude division granularity and latitude division granularity are determined according to the length of the encoded characters; the longitude division granularity indicates the fineness of the grid division of the global longitude range, and the latitude division granularity indicates the fineness of the grid division of the global latitude range.
[0185] In an exemplary embodiment, the longitude division granularity is the longitude grid span, and the latitude division granularity is the latitude grid span; the second calculation module 1006 is used to perform multiplication processing on the grid longitude index and the longitude grid span to obtain the longitude product value, and to perform multiplication processing on the grid latitude index and the latitude grid span to obtain the latitude product value; based on the longitude product value, the starting longitude of the global longitude range and the longitude compensation value, the target longitude is obtained, and based on the latitude product value, the starting latitude of the global latitude range and the latitude compensation value, the target latitude is obtained.
[0186] In an exemplary embodiment, the second mapping module 1004 includes a second conversion and mixing unit and a second character mapping unit. The second conversion and mixing unit is used to convert each character in the geocode to be decoded into a corresponding sub-global sequence according to the geocode mapping relationship; and to arrange the corresponding sub-global columns in sequence according to the order of each character in the geocode to be decoded to obtain a global index sequence corresponding to the geocode to be decoded. The second character mapping unit is used to split the global index sequence according to a preset mixing rule to obtain a longitude bit sequence and a latitude bit sequence; to convert the longitude bit sequence according to a preset base to obtain a grid longitude index; and to convert the latitude bit sequence according to a preset base to obtain a grid latitude index.
[0187] Each module in the aforementioned geolocation encoding and decoding devices can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0188] In one exemplary embodiment, a geographic location encoding / decoding apparatus is provided, including the above-described geographic location encoding apparatus and geographic location decoding apparatus.
[0189] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 11As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When executed by the processor, the computer program implements a geolocation encoding method and / or a geolocation decoding method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0190] Those skilled in the art will understand that Figure 11 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0191] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0192] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.
[0193] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0194] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0195] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0196] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0197] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A geolocation coding method, characterized in that, The geographic location coding method includes: Get the preset encoded character length; Obtain the geographic coordinates of the target location in decimal form to obtain the longitude and latitude to be encoded; Based on the length of the encoded characters, the longitude division granularity and latitude division granularity are determined. The longitude division granularity represents the fineness of the grid division of the global longitude range, and the latitude division granularity represents the fineness of the grid division of the global latitude range. The longitude to be encoded is converted into a grid longitude index in decimal form according to the granularity of longitude, and the latitude to be encoded is converted into a grid latitude index in decimal form according to the granularity of latitude. Based on the grid longitude index and the grid latitude index, a global index sequence for the target location is determined, and the global index sequence is encoded and converted according to the geocoding mapping relationship to obtain the target geocode corresponding to the target location. The positional system of the global index sequence is a preset positional system corresponding to the geocoding mapping relationship.
2. The geolocation coding method according to claim 1, characterized in that, The step of determining the longitude and latitude granularity according to the length of the encoded characters includes: The global bit length is determined based on the encoded character length and the basic bit length; the basic bit length is the number of bits corresponding to one character in the geocoding mapping relationship. The global bit length is divided into longitude bit length and latitude bit length; The longitude division granularity is determined based on the longitude bit length, and the latitude division granularity is determined based on the latitude bit length.
3. The geolocation coding method according to claim 2, characterized in that, Determining the longitude division granularity based on the longitude bit length, and determining the latitude division granularity based on the latitude bit length, includes: Based on the longitude bit length and the preset base, the number of longitude divisions is determined to obtain the longitude division granularity; and based on the latitude bit length and the preset base, the number of latitude divisions is determined to obtain the latitude division granularity. or, Based on the longitude bit length and the preset base, the number of longitude divisions is determined, and based on the number of longitude divisions and the global longitude range, the grid longitude span is determined to obtain the longitude division granularity; based on the latitude bit length and the preset base, the number of latitude divisions is determined, and based on the number of latitude divisions and the global latitude range, the grid latitude span is determined to obtain the latitude division granularity.
4. The geolocation coding method according to claim 3, characterized in that, The longitude division granularity is the grid longitude span, and the latitude division granularity is the grid latitude span; converting the longitude to be encoded into a decimal grid longitude index according to the longitude division granularity, and converting the latitude to be encoded into a decimal grid latitude index according to the latitude division granularity, includes: The difference between the longitude to be encoded and the starting longitude of the global longitude range is processed to obtain the longitude difference value, and the difference between the latitude to be encoded and the starting latitude of the global latitude range is processed to obtain the latitude difference value. The ratio of the longitude difference to the grid longitude span is rounded to obtain the grid longitude index of the longitude to be encoded, and the ratio of the latitude difference to the grid latitude span is rounded to obtain the grid latitude index of the longitude to be encoded.
5. The geolocation coding method according to claim 1, characterized in that, Based on the grid longitude index and the grid latitude index, a global index sequence for the target location is determined, including: The grid longitude index is converted according to a preset base to obtain a longitude bit sequence, and the grid latitude index is converted according to the preset base to obtain a latitude bit sequence; According to a preset mixing rule, the longitude bit sequence and the latitude bit sequence are mixed to obtain the global index sequence; The step of encoding the global index sequence according to the geocoding mapping relationship to obtain the target geocode corresponding to the target location includes: The global index sequence is split according to the basic bit length to obtain each group of sub-global sequences; wherein, the basic bit length is the number of bits corresponding to one character in the geocoding mapping relationship; Based on the geocoding mapping relationship, each group of sub-global sequences is converted into corresponding characters; Based on the order of each sub-global sequence in the global index sequence, the corresponding characters are arranged sequentially to obtain the target geocode corresponding to the target location.
6. A geolocation decoding method, characterized in that, The geographic location decoding method includes: Obtain the preset encoded character length and the geocode to be decoded; Based on the length of the encoded characters, the longitude division granularity and latitude division granularity are determined. The longitude division granularity represents the fineness of the grid division of the global longitude range, and the latitude division granularity represents the fineness of the grid division of the global latitude range. According to the geocoding mapping relationship, the geocode to be decoded is decoded and converted to obtain the global index sequence corresponding to the geocode to be decoded. Based on the global index sequence, the grid longitude index and the grid latitude index in decimal form are determined. The base of the global index sequence is a preset base corresponding to the geocoding mapping relationship. The grid longitude index is converted into target longitude in decimal form according to the granularity of longitude, and the grid latitude index is converted into target latitude in decimal form according to the granularity of latitude.
7. The geographic location decoding method according to claim 6, characterized in that, The longitude division granularity is the longitude grid span, and the latitude division granularity is the latitude grid span; converting the grid longitude index into a target longitude in decimal form according to the longitude division granularity, and converting the grid latitude index into a target latitude in decimal form according to the latitude division granularity, includes: The longitude index of the grid and the longitude grid span are multiplied to obtain the longitude product value, and the latitude index of the grid and the latitude grid span are multiplied to obtain the latitude product value; The target longitude is obtained based on the longitude product, the starting longitude of the global longitude range, and the longitude compensation value; and the target latitude is obtained based on the latitude product, the starting latitude of the global latitude range, and the latitude compensation value.
8. The geographic location decoding method according to claim 7, characterized in that, Based on the geocoding mapping relationship, the geocode to be decoded is decoded and converted to obtain the global index sequence corresponding to the geocode to be decoded, including: Based on the geocoding mapping relationship, each character in the geocoding to be decoded is converted into a corresponding sub-global sequence; Arrange the corresponding sub-global columns sequentially according to the order of each character in the geocode to be decoded to obtain the global index sequence corresponding to the geocode to be decoded; The determination of the grid longitude index and grid latitude index based on the global index sequence includes: According to the preset mixing rules, the global index sequence is split to obtain a longitude bit sequence and a latitude bit sequence; The longitude bit sequence is converted according to a preset base to obtain the grid longitude index, and the latitude bit sequence is converted according to the preset base to obtain the grid latitude index.
9. A geographic location coding device, characterized in that, The geographic location encoding device includes: The first acquisition module is used to acquire the preset encoding character length and the decimal geographical coordinates of the target location to obtain the longitude and latitude to be encoded. The first granularity division module is used to determine the longitude division granularity and the latitude division granularity according to the length of the encoded character. The longitude division granularity represents the fineness of the grid division of the global longitude range, and the latitude division granularity represents the fineness of the grid division of the global latitude range. The first calculation module is used to convert the longitude to be encoded into a decimal grid longitude index according to the longitude granularity, and to convert the latitude to be encoded into a decimal grid latitude index according to the latitude granularity. The first mapping module is used to determine the global index sequence of the target location based on the grid longitude index and the grid latitude index, and to encode the global index sequence according to the geocoding mapping relationship to obtain the target geocode corresponding to the target location. The positional system of the global index sequence is a preset positional system corresponding to the geocoding mapping relationship.
10. A geolocation decoding device, characterized in that, The geographic location decoding device includes: The second acquisition module is used to acquire the preset encoded character length and the geographic code to be decoded; The first granularity division module is used to determine the longitude division granularity and the latitude division granularity according to the length of the encoded character. The longitude division granularity represents the fineness of the grid division of the global longitude range, and the latitude division granularity represents the fineness of the grid division of the global latitude range. The second mapping module is used to decode and convert the geocode to be decoded according to the geocode mapping relationship to obtain the global index sequence corresponding to the geocode to be decoded, and to determine the grid longitude index and grid latitude index in decimal form based on the global index sequence. The positional system of the global index sequence is a preset positional system corresponding to the geocode mapping relationship, and the grid longitude index and the grid latitude index are non-negative integers in decimal. The second calculation module is used to convert the grid longitude index into a target longitude in decimal form according to the longitude granularity, and to convert the grid latitude index into a target latitude in decimal form according to the latitude granularity.
Citation Information
Patent Citations
Region search method and device, electronic equipment and readable storage medium
CN115658836A