CN112711590A - Country code storage and query method and device, electronic equipment and storage medium - Google Patents

Country code storage and query method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN112711590A
CN112711590A CN202011614814.6A CN202011614814A CN112711590A CN 112711590 A CN112711590 A CN 112711590A CN 202011614814 A CN202011614814 A CN 202011614814A CN 112711590 A CN112711590 A CN 112711590A
Authority
CN
China
Prior art keywords
longitude
latitude
country code
index
value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202011614814.6A
Other languages
Chinese (zh)
Other versions
CN112711590B (en
Inventor
金泽豪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Bigo Technology Pte Ltd
Original Assignee
Bigo Technology Pte Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Bigo Technology Pte Ltd filed Critical Bigo Technology Pte Ltd
Priority to CN202011614814.6A priority Critical patent/CN112711590B/en
Publication of CN112711590A publication Critical patent/CN112711590A/en
Application granted granted Critical
Publication of CN112711590B publication Critical patent/CN112711590B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/29Geographical information databases

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Remote Sensing (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Navigation (AREA)

Abstract

The embodiment of the invention discloses a country code storage and query method, a device, electronic equipment and a storage medium, wherein the country code storage method comprises the following steps: generating a country code index table according to the country code of each country; rasterizing the global map according to a preset precision value to obtain a rasterized global map; determining a longitude and latitude index number of each grid point on the rasterized global map and a country code index number associated with the longitude and latitude index number; and generating a longitude and latitude index table according to the longitude and latitude index numbers and the country code index numbers, associating the country code index numbers in the longitude and latitude index table through the latitude index numbers, and storing the country code index table and the longitude and latitude index table to store the country codes. After the longitude and latitude index number is determined through the longitude and latitude of any one position, the country code of the position can be obtained by sequentially inquiring the longitude and latitude index table and the country code index table without depending on a third party interface, the table look-up logic is simple, the data size is small, the inquiry efficiency can be improved, and the memory consumption is reduced.

Description

Country code storage and query method and device, electronic equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of information query, in particular to a country code storage method, a country code query device, electronic equipment and a storage medium.
Background
At present, more and more mobile phones APP are popularized globally, the business is not limited to a certain country or region any more, and the mobile phones APP can perform different business logics according to different countries or regions, so that the determination of the country region code (ISO 3166-1) according to the longitude and latitude of the position of the mobile phone is a basic and important function.
At present, the function of obtaining the country code through the longitude and latitude of the position of the mobile phone is mostly inquired through the existing third party interface, the mobile phone APP cannot obtain the country code under the certain scenes that cannot depend on the third party, for example, the country code cannot be obtained through the third party under the scenes of third party inquiry interface failure or authority limitation, and the country code is inquired according to the existing database, so that the inquiry result is accurate, but the database is too huge.
Disclosure of Invention
The embodiment of the invention provides a country code storage method, a country code query device, electronic equipment and a storage medium, and aims to solve the problem that query of country codes needs to depend on a third party or needs a huge database in the prior art.
In a first aspect, an embodiment of the present invention provides a country code storage method, including:
generating a country code index table according to country codes of each country, wherein the country code index table comprises country code index numbers and country codes associated with the country code index numbers;
rasterizing the global map according to a preset precision value to obtain a rasterized global map;
determining a longitude and latitude index number of each grid point on the rasterized global map and a country code index number associated with the longitude and latitude index number;
generating a longitude and latitude index table according to the longitude and latitude index numbers and the country code index numbers, wherein each longitude and latitude index number in the longitude and latitude index table is associated with one country code index number;
and storing the country code index table and the longitude and latitude index table to store the country code.
In a second aspect, an embodiment of the present invention provides a country code query method, including:
when a country code query request of a target position is received, acquiring a longitude value and a latitude value of the target position;
determining a target longitude and latitude index number of the target position according to the longitude value and the latitude value;
determining longitude and latitude index numbers of adjacent areas of the target position;
querying a country code index number associated with the target longitude and latitude index number and the longitude and latitude index numbers of the adjacent areas in a preset longitude and latitude index table to obtain a plurality of country code index numbers;
querying country codes associated with the country code index numbers in a preset country code index table to obtain a plurality of country codes;
taking the country code with the largest number as the country code of the target position;
wherein the country code index table and the latitude and longitude index table are pre-stored in a storage medium by the country code storage method of the first aspect of the present invention.
In a third aspect, an embodiment of the present invention provides a country code storage apparatus, including:
the country code index table generating module is used for generating a country code index table according to country codes of each country, and the country code index table comprises country code index numbers and country codes related to the country code index numbers;
the rasterization module is used for rasterizing the global map according to a preset precision value to obtain a rasterized global map;
the longitude and latitude index number determination module is used for determining a longitude and latitude index number of each grid point on the rasterized global map and a country code index number associated with the longitude and latitude index number;
the longitude and latitude index table generating module is used for generating a longitude and latitude index table according to the longitude and latitude index numbers and the country code index numbers, and each longitude and latitude index number in the longitude and latitude index table is associated with one country code index number;
and the storage module is used for storing the country code index table and the longitude and latitude index table so as to store the country code.
In a fourth aspect, an embodiment of the present invention provides a country code query apparatus, including:
the longitude and latitude value acquisition module is used for acquiring a longitude value and a latitude value of a target position when a country code query request of the target position is received;
the target longitude and latitude index number determining module is used for determining a target longitude and latitude index number of the target position according to the longitude value and the latitude value;
the longitude and latitude index number determination module of the adjacent area is used for determining the longitude and latitude index number of the adjacent area of the target position;
a country code index number query module, configured to query the country code index numbers associated with the target longitude and latitude index number and the longitude and latitude index numbers of the adjacent areas in a preset longitude and latitude index table, to obtain a plurality of country code index numbers;
the country code query module is used for querying country codes associated with the country code index numbers in a preset country code index table to obtain a plurality of country codes;
and the country code determining module is used for taking the country code with the largest number as the country code of the target position.
Wherein the country code index table and the latitude and longitude index table are pre-stored in a storage medium by the country code storage method of the first aspect of the present invention.
In a fifth aspect, an embodiment of the present invention provides an electronic device, where the electronic device includes:
one or more processors;
a storage device for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors implement the country code storage method according to the first aspect of the present invention, and/or the country code query method according to the second aspect of the present invention.
In a sixth aspect, the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the country code storage method according to the first aspect of the present invention and/or the country code query method according to the second aspect of the present invention.
The method includes the steps of generating a country code index table according to country codes of each country, wherein the country code index table comprises country code index numbers and country codes related to the country code index numbers, rasterizing a global map according to preset precision values to obtain a rasterized global map, determining longitude and latitude index numbers of each grid point on the rasterized global map and country code index numbers related to the longitude and latitude index numbers, generating a longitude and latitude index table according to the longitude and latitude index numbers and the country code index numbers, associating one country code index number with each longitude and latitude index number in the longitude and latitude index table, and storing the country code index table and the longitude and latitude index table to store the country codes. The embodiment of the invention stores the country code through the country code index table and the longitude and latitude index table, after the longitude and latitude index number is determined through the longitude and latitude of any position, the country code of the position can be quickly obtained by sequentially inquiring the longitude and latitude index table and the country code index table, a third-party interface is not needed, the table look-up logic is simple, the data size is small, the inquiry efficiency can be improved, and the memory consumption is reduced.
Drawings
Fig. 1 is a flowchart illustrating steps of a country code storage method according to an embodiment of the present invention;
fig. 2A is a flowchart illustrating steps of a country code storage method according to a second embodiment of the present invention;
FIG. 2B is a block diagram of a rasterized global map in an embodiment of the invention;
FIG. 2C is a schematic view of grid points of a partial grid in an embodiment of the present invention;
FIG. 2D is a diagram of latitude and longitude index numbers of a partial grid in an embodiment of the invention;
fig. 3 is a flowchart illustrating steps of a country code query method according to a third embodiment of the present invention;
fig. 4 is a block diagram of a country code storage apparatus according to a fourth embodiment of the present invention;
fig. 5 is a block diagram of a country code query device according to a fifth embodiment of the present invention;
fig. 6 is a block diagram of an electronic device according to a sixth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Example one
Fig. 1 is a flowchart of steps of a country code storage method according to an embodiment of the present invention, where the country code storage method according to the embodiment of the present invention is applicable to a situation where a country code is stored in advance when a country code is queried through latitude and longitude information, and the method may be executed by a country code storage device implemented by the present invention, where the country code storage device may be implemented by hardware or software and integrated in an electronic device provided by the embodiment of the present invention, and specifically, as shown in fig. 1, the country code storage method according to the embodiment of the present invention may include the following steps:
s101, a country code index table is generated according to country codes of all countries, and the country code index table comprises country code index numbers and country codes related to the country code index numbers.
The country code may be a code representing a country with a certain number of letters, and the embodiment of the present invention establishes an internationally approved code with ISO3166-1 as countries and regions, and the code is divided into 3 types, i.e., a two-digit capital letter code, a three-digit capital letter code, and a three-digit numerical code, for example, a country code of china is CN, a country code of the united states is US, a country code of the uk is GB, and a country code of japan is JP, and in practical applications, the country code of each country can be obtained by querying ISO3166-1, and establishes a country code index table in which each country code index number is associated with a country code of a country. In one example, the country code index table may be a one-dimensional array, where the subscripts of the elements in the array are country code index numbers and the values of the elements are country codes.
And S102, rasterizing the global map according to a preset precision value to obtain a rasterized global map.
In an embodiment of the present invention, the global map may be a two-dimensional planar map, the map is divided into a longitude direction and a latitude direction, the preset precision value may be 1 ° or 0.1 °, and the like, and the embodiment of the present invention may arbitrarily set the precision value, and the global map is divided into a plurality of parts from the longitude direction and the latitude direction by the precision value to obtain a rasterized global map, the rasterized global map has a plurality of grid points, and each grid point serves as a sampling point.
S103, determining the longitude and latitude index number of each grid point on the rasterized global map and the country code index number associated with the longitude and latitude index number.
Specifically, the longitude and latitude index number of each grid point on the rasterized global map can be determined according to the longitude, the latitude and the precision on the global map, and the longitude and latitude index number expresses the serial number of each grid point and is used for searching the country code index number through the longitude and latitude index number. In an example of the present invention, the longitude and latitude index number of each grid point may be calculated according to the longitude value, the latitude value, and the precision value of the grid point, the country where the grid point is located is determined according to the location where the grid point is located, the country code of the country is obtained, and the country code index number associated with the country code is searched from the country code index table generated in S101 as the country code index number associated with the longitude and latitude index number of the grid point.
S104, generating a longitude and latitude index table according to the longitude and latitude index numbers and the country code index numbers, wherein each longitude and latitude index number in the longitude and latitude index table is associated with one country code index number.
Specifically, the longitude and latitude index number of each grid point and the country code index number associated with the longitude and latitude index number are stored as a longitude and latitude index table, and each longitude and latitude index number in the longitude and latitude index table uniquely corresponds to one country code index number.
And S105, storing the country code index table and the longitude and latitude index table to store the country code.
For example, the country code index table and the latitude and longitude index table may be stored in the storage medium in the form of an array, or the country code index table and the latitude and longitude index table may be stored in the storage medium in the form of a text after being serialized.
The method includes the steps of generating a country code index table according to country codes of each country, wherein the country code index table comprises country code index numbers and country codes related to the country code index numbers, rasterizing a global map according to preset precision values to obtain a rasterized global map, determining longitude and latitude index numbers of each grid point on the rasterized global map and country code index numbers related to the longitude and latitude index numbers, generating a longitude and latitude index table according to the longitude and latitude index numbers and the country code index numbers, associating one country code index number with each longitude and latitude index number in the longitude and latitude index table, and storing the country code index table and the longitude and latitude index table to store the country codes. The embodiment of the invention stores the country code through the country code index table and the longitude and latitude index table, after the longitude and latitude index number is determined through the longitude and latitude of any position, the country code of the position can be quickly obtained by sequentially inquiring the longitude and latitude index table and the country code index table, a third-party interface is not needed, the table look-up logic is simple, the data size is small, the inquiry efficiency can be improved, and the memory consumption is reduced.
Example two
Fig. 2A is a flowchart of steps of a country code storage method according to a second embodiment of the present invention, where the second embodiment of the present invention is optimized based on the first embodiment, specifically, as shown in fig. 2A, the country code storage method according to the second embodiment of the present invention may include the following steps:
s201, a country code index table is generated according to country codes of each country, and the country code index table comprises country code index numbers and country codes related to the country code index numbers.
The country code may be a country code represented by a certain number of letters, and the embodiment of the present invention establishes an internationally approved code using ISO3166-1 as countries and regions, and in practical applications, the country code of each country may be obtained by querying ISO3166-1, and establishes a country code index table in which each country code index number is associated with a country code of a country, as shown in table 1 below:
table 1:
Figure BDA0002876243650000081
Figure BDA0002876243650000091
s202, calculating the ratio of the total longitude value of the longitude to a preset precision value to obtain the number of the first grids in the longitude direction.
On the global map, the position of the initial meridian is 0 ° longitude, the west of the 0 ° longitude is 0 ° to-180 ° longitude, the east of the 0 ° longitude is 0 ° to +180 ° longitude, the total longitude value is 360 °, and the preset accuracy value is 1 ° as an example, the number of grids in the longitude direction is 360/1 ═ 360, that is, the total longitude value is 360 parts.
S203, calculating the ratio of the total latitude value to the preset precision value of the latitude to obtain the number of second grids in the latitude direction.
On a global map, assuming that the position of the equator is 0 ° latitude, the 0 ° latitude is 0 ° to-90 ° latitude in the south, the 0 ° latitude is 0 ° to +90 ° latitude in the north, the total latitude value is 180 °, and the preset precision value is 1 ° as an example, the number of grids in the latitude direction is 180/1 to 180, that is, the total latitude value is 180 parts.
And S204, rasterizing the global map to obtain a rasterized global map, wherein the number of grids of the rasterized global map in the longitudinal direction is equal to the first number of grids, and the number of grids in the latitudinal direction is equal to the second number of grids.
As shown in fig. 2B, which is a rasterized global map having a plurality of grid points as sampling points, in fig. 2B, the accuracy is 10 °, i.e., the global map is divided into 36 parts in the longitudinal direction and 18 parts in the latitudinal direction.
S205, obtaining the longitude value and the latitude value of each grid point.
As shown in fig. 2C, the diagram of a part of grid points is shown, the abscissa is a longitude value, the ordinate is a latitude value, the precision value is 10 °, the longitude value and the latitude value of each grid point can be obtained by traversing each grid point from bottom to top from left to right, for example, the longitude and latitude value of the grid point a at the lower left corner is (-180 °, -90 °), the longitude and latitude value of the grid point B at the upper left corner is (-180 °, -80 °), the longitude and latitude value of the grid point C at the upper left corner is (-180 °, -70 °), and by analogy, 19 grid points are obtained by traversing all grid points with longitude of-180 °, and then traversing all grid points with longitude-170 ° to left to obtain the longitude and latitude of 19 grid points which are respectively the grid point D (-170 °, -90 °), the grid point E (-170 °, -80 °), the grid point E, Grid point F (-170 °, -70 °) … …, and so on, traversing all grid points to obtain longitude and latitude values of all grid points.
S206, calculating the longitude index number of the grid point according to the longitude value and the preset precision value.
Alternatively, a first ratio of the longitude value to the preset precision value, a second ratio of-180 to the preset precision value, and a difference between the first ratio and the second ratio may be calculated as the longitude index of the grid point, for example, as shown in fig. 2C, if the longitude and latitude value of the grid point a at the lower left corner is (-180 °, -90 °), the longitude index of the grid point a may be calculated by the following formula:
longitude index lng x/P- (-180/P)
Wherein x is the longitude value of the grid point, P is the preset precision value, the longitude value of the grid point a is-180 °, the precision value 10 ° is substituted to obtain the longitude index number of the grid point a is 0, similarly, the longitude index number of the grid point B, C is also 0, for the grid point D, the longitude index number thereof is-170/10- (-180/10) is 1, and so on, the longitude index number 2 of the grid point with the longitude value of-160 ° and the longitude index number 3 of the grid point with the longitude value of-150 °.
And S207, calculating the latitude index number of the grid point according to the latitude value and the preset precision value.
Optionally, a third ratio of the latitude value to the preset precision value is calculated, a fourth ratio of-90 to the preset precision value is calculated, and a difference between the third ratio and the fourth ratio is calculated as the latitude index number of the grid point. For example, if the latitude and longitude value of grid point a at the lower left corner is (-180 °, -90 °) as shown in fig. 2C, the latitude index number of the grid point a can be calculated by the following formula:
latitude index lat ═ y/P- (-90/P)
Wherein y is the latitude value of the grid point, P is the preset precision value, the latitude index number of the grid point a is 0 obtained by substituting the latitude value of the grid point a of-90 degrees and the precision value of 10 degrees, similarly, the latitude index numbers of the grid point B, C are respectively 1 and 2, and for the grid point D, the longitude index number is-170/10- (-180) is 1, and the latitude index number is 0.
S208, calculating the longitude and latitude index numbers of the grid points based on the longitude index numbers and the latitude index numbers.
In an alternative embodiment of the present invention, a product of the longitude index and the second ratio may be calculated, and a sum of the product and the latitude index may be calculated as the longitude and latitude index. In one example, the second ratio is a ratio of 180 to the precision value, the second ratio is the number of grids in the latitude direction, and the latitude and longitude index is calculated as follows:
longitude and latitude Index number lng x 180/P + lat
As shown in fig. 2C:
if the longitude index number of the grid point A is 0 and the latitude index number is also 0, the longitude and latitude index number of the grid point A is 0;
if the longitude index number of the grid point B is 0 and the latitude index number is 1, the longitude and latitude index number of the grid point B is 1;
if the longitude index number of the grid point C is 0 and the latitude index number is 2, the longitude and latitude index number of the grid point C is 2;
if the longitude index number of the grid point D is 1 and the latitude index number is 0, the longitude and latitude index number of the grid point D is 18;
and calculating by analogy to obtain the longitude and latitude index numbers of the grid points, namely sequentially accumulating the longitude and latitude index numbers of the grid points from bottom to top and from left to right by 1.
S209, determining the country code of the country where the grid point is located according to the longitude value and the latitude value.
In one example of the present invention, a country to which a grid point belongs on a global map may be determined according to a longitude value and a latitude value of the grid point, and a country code of the country may be acquired as a country code of the country in which the grid point belongs by querying ISO 3166-1.
S210, determining a country code index number associated with the country code from the country code index table as a country code index number associated with the longitude and latitude index number.
As shown in table 1 above, after the country code of the country where the grid point is located is determined, the country code index number associated with the country code is searched through table 1, and the country code index number is used as the country code index number associated with the longitude and latitude index number of the grid point.
S211, generating a longitude and latitude index table according to the longitude and latitude index numbers and the country code index numbers, wherein each longitude and latitude index number in the longitude and latitude index table is associated with one country code index number.
The generated longitude and latitude index table is shown in the following table 2:
table 2:
Figure BDA0002876243650000121
Figure BDA0002876243650000131
s212, after the country code index table and the longitude and latitude index table are serialized, the country code is stored in a text form to be stored.
In an example, for table 1, the state code may be stored in the text in a manner of one country code per line, and for table 2, the same manner is used, when querying, the current line number is the index number, the content of the current line is the data corresponding to the index number, and in order to ensure the data is concise, two tables may also be stored in one text.
The method includes the steps of generating a country code index table according to country codes of each country, wherein the country code index table comprises country code index numbers and country codes related to the country code index numbers, rasterizing a global map according to preset precision values to obtain a rasterized global map, determining longitude and latitude index numbers of each grid point on the rasterized global map and country code index numbers related to the longitude and latitude index numbers, generating a longitude and latitude index table according to the longitude and latitude index numbers and the country code index numbers, associating one country code index number with each longitude and latitude index number in the longitude and latitude index table, and storing the country code index table and the longitude and latitude index table to store the country codes. The embodiment of the invention stores the country code through the country code index table and the longitude and latitude index table, after the longitude and latitude index number is determined through the longitude and latitude of any position, the country code of the position can be quickly obtained by sequentially inquiring the longitude and latitude index table and the country code index table, a third-party interface is not needed, the table look-up logic is simple, the data size is small, the inquiry efficiency can be improved, and the memory consumption is reduced.
Furthermore, the index table is stored in a text form, so that the data size is small, the query efficiency can be improved, and the memory consumption can be reduced.
EXAMPLE III
Fig. 3 is a flowchart of steps of a country code method according to a third embodiment of the present invention, where the method according to the third embodiment of the present invention is applicable to a case of querying a country code according to latitude and longitude, and the method may be executed by a country code querying device implemented by the present invention, where the country code querying device may be implemented by hardware or software and integrated in an electronic device according to the third embodiment of the present invention, and specifically, as shown in fig. 3, the country code querying method according to the third embodiment of the present invention may include the following steps:
s301, when a country code query request of a target position is received, a longitude value and a latitude value of the target position are obtained.
In an example of the present invention, the terminal may request to acquire a country code of a country where the current location is located, and then the current location where the terminal is located is a target location, and the terminal may acquire a longitude value and a latitude value of the location where the terminal is located through a positioning system.
S302, determining a target longitude and latitude index number of the target position according to the longitude value and the latitude value.
In an optional embodiment of the present invention, the longitude index of the target location may be calculated according to the longitude value and the preset precision value, the latitude index of the target location may be calculated according to the latitude value and the preset precision value, and the target longitude and latitude index of the target location may be calculated based on the longitude index and the latitude index, and specific details may refer to S206-S208 in embodiment two, which is not described in detail herein.
S303, determining longitude and latitude index numbers of adjacent areas of the target position.
In one example, a previous longitude and latitude index number and a subsequent longitude and latitude index number of the target longitude and latitude index number may be obtained, the target longitude and latitude index number is shifted forwards and backwards by a specified number of index numbers to obtain a longitude and latitude index number of a right adjacent region and a longitude and latitude index number of a left adjacent region, and the previous longitude and latitude index number, the subsequent longitude and latitude index number, the longitude and latitude index number of the left adjacent region and the longitude and latitude index number of the right adjacent region are used as the longitude and latitude index numbers of the adjacent regions of the target position, wherein the specified number is equal to a ratio of 180 to a preset precision.
As shown in fig. 2D, a schematic diagram of longitude and latitude index numbers of each grid point is shown, in fig. 2D, two longitude and latitude indexes adjacent to each other up and down are different by 1, and two longitude and latitude adjacent to each other left and right are different by 18 (precision value is 10, 180/10 is 18). Assuming that the longitude and latitude index number of the target position is 20, the former longitude and latitude index number is 19, the latter longitude and latitude index number is 21, the longitude and latitude index number of the left adjacent area is 2, and the longitude and latitude index number of the right adjacent area is 38.
S304, inquiring the country code index numbers associated with the target longitude and latitude index numbers and the longitude and latitude index numbers of the adjacent areas in a preset longitude and latitude index table to obtain a plurality of country code index numbers.
As in the longitude and latitude index table shown in table 2 in the second embodiment, after the target longitude and latitude index number and the longitude and latitude index numbers of the adjacent areas are determined, the country code index numbers associated with the target longitude and latitude index numbers and the longitude and latitude index numbers of the adjacent areas can be queried through table 2.
The longitude and latitude index table is pre-stored in the storage medium by implementing the country code storage method of the first embodiment or the second embodiment, which may be referred to specifically for the first embodiment or the second embodiment, and will not be described in detail herein.
S305, querying the country codes associated with the country code index numbers in a preset country code index table to obtain a plurality of country codes.
After obtaining the plurality of country code index numbers, the country codes associated with the plurality of country code index numbers may be searched in a prestored country code index table to obtain a plurality of country codes, as shown in table 1 in embodiment two, each country code index number is associated with one country code, and the country code associated with each country code index number may be obtained by looking up the table.
The country code index table is pre-stored in the storage medium by implementing the country code storage method of the first embodiment or the second embodiment, which may be referred to specifically for the first embodiment or the second embodiment, and will not be described in detail herein.
And S306, taking the country code with the largest number as the country code of the target position.
After the plurality of country codes are obtained through inquiry, the country code with the largest number can be used as the country code of the target position, the problem that the obtained country code is inaccurate due to the fact that the target position is located at a boundary point between countries can be avoided, and therefore the accuracy of the obtained country code of the target position is improved.
According to the country code query method of the embodiment of the invention, the country code index table and the latitude and longitude index table are pre-stored in the storage medium through the country code storage method of the first embodiment or the second embodiment, the country code index table is obtained by querying the latitude and longitude index table through the target latitude and longitude index table after the target latitude and longitude index number is determined according to the longitude value and the latitude value of the target position, and then the country code of the target position is obtained by querying the country code index table according to the country code index number.
Furthermore, longitude and latitude index numbers of adjacent areas of the target position are determined, country code index numbers associated with the target longitude and latitude index numbers and the longitude and latitude index numbers of the adjacent areas are inquired in a preset longitude and latitude index table to obtain a plurality of country code index numbers, country codes associated with the country code index numbers are inquired in a preset country code index table to obtain a plurality of country codes, the country codes with the largest number are used as the country codes of the target position, the problem that the obtained country codes are inaccurate due to the fact that the target position is located at boundary points among countries can be avoided, and therefore the accuracy of the obtained country codes of the target position is improved.
Example four
Fig. 4 is a block diagram of a country code storage apparatus according to a fourth embodiment of the present invention, and as shown in fig. 4, the country code storage apparatus according to the fourth embodiment of the present invention may specifically include the following modules:
a country code index table generating module 401, configured to generate a country code index table according to a country code of each country, where the country code index table includes a country code index number and a country code associated with the country code index number;
a rasterizing module 402, configured to rasterize the global map according to a preset precision value to obtain a rasterized global map;
a longitude and latitude index number determination module 403, configured to determine a longitude and latitude index number of each grid point on the rasterized global map and a country code index number associated with the longitude and latitude index number;
a latitude and longitude index table generating module 404, configured to generate a latitude and longitude index table according to the latitude and longitude index numbers and the country code index numbers, where each latitude and longitude index number in the latitude and longitude index table is associated with one country code index number;
a storage module 405, configured to store the country code index table and the longitude and latitude index table to store the country code.
The country code storage device provided by the embodiment of the invention can execute the country code storage method provided by the first embodiment and the second embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
EXAMPLE five
Fig. 5 is a block diagram of a country code query apparatus according to a fifth embodiment of the present invention, and as shown in fig. 5, the country code query apparatus according to the fifth embodiment of the present invention may specifically include the following modules:
a latitude and longitude value obtaining module 501, configured to obtain a latitude and longitude value of a target location when a country code query request of the target location is received;
a target longitude and latitude index number determination module 502, configured to determine a target longitude and latitude index number of the target location according to the longitude value and the latitude value;
a longitude and latitude index number determination module 503 for determining the longitude and latitude index numbers of the neighboring areas of the target location;
a country code index number query module 504, configured to be used by the country code index number query module, and configured to query, in a preset longitude and latitude index table, country code index numbers associated with the target longitude and latitude index number and the longitude and latitude index numbers of the adjacent areas, so as to obtain a plurality of country code index numbers;
a country code query module 505, configured to query country codes associated with the country code index numbers in a preset country code index table to obtain a plurality of country codes;
a country code determination module 506, configured to use the country code with the largest number as the country code of the target location.
The country code index table and the latitude and longitude index table are pre-stored in a storage medium by the country code storage method according to the first embodiment or the second embodiment.
The country code query device provided by the embodiment of the invention can execute the country code query method provided by the third embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
EXAMPLE six
Referring to fig. 6, a schematic structural diagram of an electronic device in one example of the invention is shown. As shown in fig. 6, the electronic device may specifically include: a processor 600, a memory 601, a display screen with touch functionality 602, an input device 603, an output device 604, and a communication device 605. The number of the processors 600 in the electronic device may be one or more, and one processor 600 is taken as an example in fig. 6. The processor 600, the memory 601, the display 602, the input device 603, the output device 604, and the communication device 605 of the electronic apparatus may be connected by a bus or other means, and the connection by the bus is exemplified in fig. 600.
Embodiments of the present invention also provide a computer-readable storage medium, where instructions, when executed by a processor of a device, enable the device to perform a country code storage method and/or a country code query method according to the above method embodiments.
It should be noted that, as for the embodiments of the apparatus, the electronic device, and the storage medium, since they are basically similar to the embodiments of the method, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the embodiments of the method.
In the description herein, references to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (14)

1. A country code storage method, comprising:
generating a country code index table according to country codes of each country, wherein the country code index table comprises country code index numbers and country codes associated with the country code index numbers;
rasterizing the global map according to a preset precision value to obtain a rasterized global map;
determining a longitude and latitude index number of each grid point on the rasterized global map and a country code index number associated with the longitude and latitude index number;
generating a longitude and latitude index table according to the longitude and latitude index numbers and the country code index numbers, wherein each longitude and latitude index number in the longitude and latitude index table is associated with one country code index number;
and storing the country code index table and the longitude and latitude index table to store the country code.
2. The country code storage method according to claim 1, wherein the rasterizing the global map according to a preset precision value to obtain a rasterized global map includes:
calculating the ratio of the total longitude value of the longitude to a preset precision value to obtain the number of first grids in the longitude direction;
calculating the ratio of the total latitude value of the latitude to the preset precision value to obtain the number of second grids in the latitude direction;
rasterizing the global map to obtain a rasterized global map, wherein the number of grids of the rasterized global map in the longitudinal direction is equal to the first number of grids, and the number of grids in the latitudinal direction is equal to the second number of grids.
3. The country code storage method according to claim 1, wherein the determining the longitude and latitude index number of each grid point on the rasterized global map and the country code index number associated with the longitude and latitude index number comprises:
acquiring a longitude value and a latitude value of each grid point;
calculating longitude index numbers of the grid points according to the longitude values and the preset precision values;
calculating latitude index numbers of the grid points according to the latitude values and the preset precision values;
calculating longitude and latitude index numbers of the grid points based on the longitude index numbers and the latitude index numbers;
determining a country code of a country where the grid point is located according to the longitude value and the latitude value;
and determining the country code index number associated with the country code from the country code index table as the country code index number associated with the longitude and latitude index number.
4. A country code storage method according to claim 3, wherein the longitude value ranges from-180 ° to 180 °, and the calculating of the longitude index number of the grid point from the longitude value and the preset precision value comprises
Calculating a first ratio of the longitude value to the preset precision value;
calculating a second ratio of-180 to the preset precision value;
and calculating the difference value of the first ratio and the second ratio as the longitude index number of the grid point.
5. The country code storage method according to claim 3, wherein the latitude value ranges from-90 ° to 90 °, and the calculating the dimension index number of the grid point according to the latitude value and the preset precision value comprises:
calculating a third ratio of the latitude value to the preset precision value;
calculating a fourth ratio of-90 to the preset precision value;
and calculating the difference value of the third ratio and the fourth ratio as the latitude index number of the grid point.
6. The country code storage method of claim 4, wherein the calculating longitude and latitude index numbers of the grid points based on the longitude index numbers and the latitude index numbers comprises:
calculating a product of the longitude index number and the second ratio;
and calculating the sum of the product and the latitude index number as the latitude and longitude index number.
7. The country code storage method of any one of claims 1 to 6, wherein the storing the country code index table and the latitude and longitude index table to store the country code comprises:
serializing the country code index table and the longitude and latitude index table, and storing the country code in a text form.
8. A country code query method, comprising:
when a country code query request of a target position is received, acquiring a longitude value and a latitude value of the target position;
determining a target longitude and latitude index number of the target position according to the longitude value and the latitude value;
determining longitude and latitude index numbers of adjacent areas of the target position;
querying a country code index number associated with the target longitude and latitude index number and the longitude and latitude index numbers of the adjacent areas in a preset longitude and latitude index table to obtain a plurality of country code index numbers;
querying country codes associated with the country code index numbers in a preset country code index table to obtain a plurality of country codes;
taking the country code with the largest number as the country code of the target position;
wherein the country code index table and the latitude and longitude index table are stored in a storage medium in advance by the country code storage method of any one of claims 1 to 7.
9. The country code query method of claim 8, wherein the determining a target longitude and latitude index number for the target location based on the longitude and latitude values comprises:
calculating a longitude index number of the target position according to the longitude value and a preset precision value;
calculating a dimension index number of the target position according to the latitude value and the preset precision value;
and calculating a target longitude and latitude index number of the target position based on the longitude index number and the latitude index number.
10. The country code query method according to claim 8 or 9, wherein the obtaining longitude and latitude index numbers of the neighboring areas of the target location comprises:
acquiring a previous longitude and latitude index number and a next longitude and latitude index number of the target longitude and latitude index number;
shifting the target longitude and latitude index numbers forwards and backwards by a specified number of index numbers to obtain longitude and latitude index numbers of a right adjacent area and longitude and latitude index numbers of a left adjacent area;
taking the previous longitude and latitude index number, the next longitude and latitude index number, the longitude and latitude index number of the left adjacent area and the longitude and latitude index number of the right adjacent area as the longitude and latitude index numbers of the adjacent areas of the target position;
wherein the specified number is equal to a ratio of 180 to the preset precision.
11. A country code storage device, comprising:
the country code index table generating module is used for generating a country code index table according to country codes of each country, and the country code index table comprises country code index numbers and country codes related to the country code index numbers;
the rasterization module is used for rasterizing the global map according to a preset precision value to obtain a rasterized global map;
the longitude and latitude index number determination module is used for determining a longitude and latitude index number of each grid point on the rasterized global map and a country code index number associated with the longitude and latitude index number;
the longitude and latitude index table generating module is used for generating a longitude and latitude index table according to the longitude and latitude index numbers and the country code index numbers, and each longitude and latitude index number in the longitude and latitude index table is associated with one country code index number;
and the storage module is used for storing the country code index table and the longitude and latitude index table so as to store the country code.
12. A country code inquiry apparatus, comprising:
the longitude and latitude value acquisition module is used for acquiring a longitude value and a latitude value of a target position when a country code query request of the target position is received;
the target longitude and latitude index number determining module is used for determining a target longitude and latitude index number of the target position according to the longitude value and the latitude value;
the longitude and latitude index number determination module of the adjacent area is used for determining the longitude and latitude index number of the adjacent area of the target position;
a country code index number query module, configured to query the country code index numbers associated with the target longitude and latitude index number and the longitude and latitude index numbers of the adjacent areas in a preset longitude and latitude index table, to obtain a plurality of country code index numbers;
the country code query module is used for querying country codes associated with the country code index numbers in a preset country code index table to obtain a plurality of country codes;
a country code determination module for taking a country code with the largest number as a country code of the target location;
wherein the country code index table and the latitude and longitude index table are stored in a storage medium in advance by the country code storage method of any one of claims 1 to 7.
13. An electronic device, characterized in that the electronic device comprises:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the country code storage method of any one of claims 1-7, and/or the country code query method of any one of claims 8-10.
14. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, implements the country code storage method according to any one of claims 1 to 7 and/or the country code query method according to any one of claims 8 to 10.
CN202011614814.6A 2020-12-30 2020-12-30 Country code storage method, device, electronic equipment and storage medium Active CN112711590B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011614814.6A CN112711590B (en) 2020-12-30 2020-12-30 Country code storage method, device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011614814.6A CN112711590B (en) 2020-12-30 2020-12-30 Country code storage method, device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN112711590A true CN112711590A (en) 2021-04-27
CN112711590B CN112711590B (en) 2024-06-18

Family

ID=75547444

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011614814.6A Active CN112711590B (en) 2020-12-30 2020-12-30 Country code storage method, device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112711590B (en)

Citations (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5839088A (en) * 1996-08-22 1998-11-17 Go2 Software, Inc. Geographic location referencing system and method
US20040225665A1 (en) * 2003-05-09 2004-11-11 Microsoft Corporation System and method for employing a grid index for location and precision encoding
US20080144655A1 (en) * 2006-12-14 2008-06-19 James Frederick Beam Systems, methods, and computer program products for passively transforming internet protocol (IP) network traffic
CN102445205A (en) * 2011-10-12 2012-05-09 北京世纪高通科技有限公司 Massive map data matching method and device
CN102855322A (en) * 2012-09-11 2013-01-02 哈尔滨工程大学 Map data storage method based on space exploration technology
CN105509743A (en) * 2015-11-24 2016-04-20 上海汽车集团股份有限公司 A positioning processing method, a business platform and a network system
CN106649821A (en) * 2016-12-29 2017-05-10 郑州星途信息科技有限公司 Space target index constructing method, space target collision pre-warning method, space target region query region and space target nearest neighbor query method
CN107018489A (en) * 2017-03-02 2017-08-04 惠州Tcl移动通信有限公司 A kind of mobile terminal loads the method and system of FM parameters automatically
CN107016086A (en) * 2017-04-01 2017-08-04 四川艾特赢泰智能科技有限责任公司 A kind of method for extracting behavior and position data in Android system GooglePlay
US20180011875A1 (en) * 2016-07-06 2018-01-11 Sap Se Platform-based data segregation
CN109710711A (en) * 2018-12-13 2019-05-03 中国联合网络通信集团有限公司 Map gridding method and platform
CN109992636A (en) * 2019-03-22 2019-07-09 中国人民解放军战略支援部队信息工程大学 Space-time code method, temporal index and querying method and device
CN111382212A (en) * 2020-03-02 2020-07-07 拉扎斯网络科技(上海)有限公司 Associated address acquisition method and device, electronic equipment and storage medium
CN112042231A (en) * 2019-02-20 2020-12-04 华为技术有限公司 Method for acquiring information and terminal equipment
WO2021152323A1 (en) * 2020-01-29 2021-08-05 Anthony Harrison A method of data communication

Patent Citations (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5839088A (en) * 1996-08-22 1998-11-17 Go2 Software, Inc. Geographic location referencing system and method
US20040225665A1 (en) * 2003-05-09 2004-11-11 Microsoft Corporation System and method for employing a grid index for location and precision encoding
US20080144655A1 (en) * 2006-12-14 2008-06-19 James Frederick Beam Systems, methods, and computer program products for passively transforming internet protocol (IP) network traffic
CN102445205A (en) * 2011-10-12 2012-05-09 北京世纪高通科技有限公司 Massive map data matching method and device
CN102855322A (en) * 2012-09-11 2013-01-02 哈尔滨工程大学 Map data storage method based on space exploration technology
CN105509743A (en) * 2015-11-24 2016-04-20 上海汽车集团股份有限公司 A positioning processing method, a business platform and a network system
US20180011875A1 (en) * 2016-07-06 2018-01-11 Sap Se Platform-based data segregation
CN106649821A (en) * 2016-12-29 2017-05-10 郑州星途信息科技有限公司 Space target index constructing method, space target collision pre-warning method, space target region query region and space target nearest neighbor query method
CN107018489A (en) * 2017-03-02 2017-08-04 惠州Tcl移动通信有限公司 A kind of mobile terminal loads the method and system of FM parameters automatically
CN107016086A (en) * 2017-04-01 2017-08-04 四川艾特赢泰智能科技有限责任公司 A kind of method for extracting behavior and position data in Android system GooglePlay
CN109710711A (en) * 2018-12-13 2019-05-03 中国联合网络通信集团有限公司 Map gridding method and platform
CN112042231A (en) * 2019-02-20 2020-12-04 华为技术有限公司 Method for acquiring information and terminal equipment
CN109992636A (en) * 2019-03-22 2019-07-09 中国人民解放军战略支援部队信息工程大学 Space-time code method, temporal index and querying method and device
WO2021152323A1 (en) * 2020-01-29 2021-08-05 Anthony Harrison A method of data communication
CN111382212A (en) * 2020-03-02 2020-07-07 拉扎斯网络科技(上海)有限公司 Associated address acquisition method and device, electronic equipment and storage medium

Non-Patent Citations (6)

* Cited by examiner, † Cited by third party
Title
PING JIANG 等: "Meshing Scheme Research of Our National Mid-low Latitude Region", 2019 CHINESE CONTROL CONFERENCE, 30 July 2019 (2019-07-30), pages 3910 - 3915, XP033632450, DOI: 10.23919/ChiCC.2019.8866255 *
RAWIA CHAKROUN 等: "Comparison between LCL and LLCL Filters For a Grid Connected Inverter Using Selective Harmonic Modulation", 《2020 5TH INTERNATIONAL CONFERENCE ON RENEWABLE ENERGIES FOR DEVELOPING COUNTRIES(REDEC)》, 30 June 2020 (2020-06-30), pages 1 - 6, XP033810285, DOI: 10.1109/REDEC49234.2020.9163595 *
张章;张福浩;陶坤旺;孙立坚;: "一种组织机构信息多级地理网格划分的方法", 测绘科学, no. 03, 20 March 2015 (2015-03-20), pages 52 - 56 *
谢明辉 等: "基于Google Map的GPS和GSM定位关键技术研究", 《吉林建筑大学学报》, vol. 31, no. 5, 31 October 2014 (2014-10-31), pages 60 - 63 *
郭少友 等: "关联数据环境下的关联服务研究", 《图书情报工作》, vol. 56, no. 11, 30 June 2012 (2012-06-30), pages 109 - 114 *
龙明 等: "基于Windows Mobile的移动GIS研究", 《测绘科学技术学报》, no. 06, 15 December 2007 (2007-12-15), pages 458 - 461 *

Also Published As

Publication number Publication date
CN112711590B (en) 2024-06-18

Similar Documents

Publication Publication Date Title
CN107239531B (en) Implementation method for expanding WMS service of GeoServer releasing custom tiles
CN103383682B (en) A kind of Geocoding, position enquiring system and method
CN103268730B (en) Electronic map interface shows the method and apparatus of association mark point
CN103927933B (en) A kind of magnanimity moves method and the device that target renders
CN107092623B (en) Interest point query method and device
EP2958033A1 (en) Tile-based distribution of searchable geospatial data to client devices
CN108932310B (en) Space service providing method and device, server and storage device
CN110909093B (en) Method and device for constructing intelligent landmark control network
CN103279539A (en) Interest point set displaying method, electronic map displaying method, interest point set displaying device and electronic map displaying device
KR20040095751A (en) A system and method employing a grid index for location and precision encoding
CN102368259A (en) Electronic map data storage and query method, device and system
US20150074583A1 (en) Method and device for correcting map view
US20170186225A1 (en) Method and apparatus for generating a composite indexable linear data structure to permit selection of map elements based on linear elements
CN111915690B (en) Thermodynamic diagram data shrinkage editing method based on vector tiles
CN103324749B (en) A kind of spatialization parsing based on received text address and method for correcting error
CN113272798A (en) Map acquisition method, map acquisition device, computer equipment and storage medium
CN112711590B (en) Country code storage method, device, electronic equipment and storage medium
CN110475204B (en) Method, device and equipment for analyzing reverse address of geographic fence
CN115357675B (en) Method and system for establishing image control point database through standardized processing of image control points
CN113360586B (en) Address aggregation degree query method, device, equipment and computer readable storage medium
WO2023123583A1 (en) Fusion method, apparatus and system suitable for geological data and geographic information data
CN103915035A (en) Data conversion method and data conversion apparatus
CN110989886A (en) Three-dimensional space grid selection method and device based on space map
CN116049330A (en) Independent coordinate system establishing method, device, computer equipment and storage medium
CN111738352B (en) Method, device and equipment for positioning inside of building entity

Legal Events

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