Method and apparatus for querying meteorological data
By constructing a key-value pair index structure in memory, meteorological data can be queried directly using grid identifiers, solving the problems of low query efficiency and high resource consumption of meteorological data, and achieving efficient and economical query and storage results.
Patent Information
- Application Number
- CN202210043661.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-14
- Publication Date
- 2025-12-30
- Estimated Expiration
- 2042-01-14
AI Technical Summary
Existing technologies for querying meteorological data are inefficient and resource-intensive, especially when performing a full traversal in a distributed file system, which leads to long query times and high storage costs.
A key-value index structure is built in memory, where the key includes a grid identifier and the data value includes meteorological data. The meteorological data corresponding to the query request can be directly obtained from the index structure through the grid identifier, avoiding traversal of the distributed file system.
It improves the efficiency of meteorological data query, saves resources and storage costs, and reduces the waste of query time and storage space.
Smart Images

Figure CN114385932B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to map technology and big data in the field of data processing technology, and in particular to a method and apparatus for querying meteorological data. Background Technology
[0002] Meteorological data is used to reflect weather conditions and is one of the important basic data supporting the product development of the road data team's business line. It can be widely used in various application scenarios, including the discovery of road blockages caused by severe weather and water accumulation, road avoidance based on crowdsourced data, and intelligence and early warning of road blockages caused by severe weather.
[0003] In related technologies, meteorological data is usually partitioned by time and stored in a distributed file system in different files according to elements such as temperature data and precipitation data. However, when querying meteorological data, it is necessary to traverse all meteorological data within a certain sliding time window, which leads to technical problems such as long query time and low efficiency. Summary of the Invention
[0004] This disclosure provides a meteorological data query method and apparatus for improving the efficiency of meteorological data query.
[0005] According to a first aspect of this disclosure, a method for querying meteorological data is provided, comprising:
[0006] Receive a query request, wherein the query request is used to query meteorological data of a target geographical location;
[0007] The grid to which the target geographical location belongs in the preset grid is determined. The preset grid has a grid identifier. Based on the grid identifier corresponding to the target geographical location, the meteorological data corresponding to the query request is determined from the index structure in memory and output.
[0008] The index structure is a key-value pair data structure, where the key in the key-value pair includes a grid identifier, the data value in the key-value pair includes meteorological data, and the preset grid is obtained by performing grid cutting processing on a preset range area.
[0009] According to a second aspect of this disclosure, a meteorological data query device is provided, comprising:
[0010] A receiving unit is configured to receive a query request, wherein the query request is for querying meteorological data of a target geographical location;
[0011] The first determining unit is used to determine the grid to which the target geographical location belongs in the preset grid, wherein the preset grid has a grid identifier;
[0012] The second determining unit is used to determine and output the meteorological data corresponding to the query request from the index structure in memory based on the grid identifier corresponding to the target geographical location;
[0013] The index structure is a key-value pair data structure, where the key in the key-value pair includes a grid identifier, the data value in the key-value pair includes meteorological data, and the preset grid is obtained by performing grid cutting processing on a preset range area.
[0014] According to a third aspect of this disclosure, an electronic device is provided, comprising:
[0015] At least one processor; and
[0016] A memory communicatively connected to the at least one processor; wherein,
[0017] The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method described in the first aspect.
[0018] According to a fourth aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are configured to cause the computer to perform the method according to the first aspect.
[0019] According to a fifth aspect of this disclosure, a computer program product is provided, the computer program product comprising: a computer program stored in a readable storage medium, wherein at least one processor of an electronic device can read the computer program from the readable storage medium, and the at least one processor executes the computer program to cause the electronic device to perform the method described in the first aspect.
[0020] The meteorological data query method and apparatus of this disclosure, by constructing an index structure in memory with a key-value pair data structure, wherein the key in the key-value pair includes a grid identifier and the data value in the key-value pair includes meteorological data, and combining the grid identifier corresponding to the target geographical location, retrieves and outputs the meteorological data corresponding to the query request from the key-value pair, avoids the disadvantages of long traversal time and low efficiency caused by using a distributed file system to query meteorological data, improves query efficiency, and avoids the disadvantages of resource waste caused by using a distributed file system by querying meteorological data in memory, thus improving the technical effect of saving resources and storage costs.
[0021] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0022] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:
[0023] Figure 1 This is a schematic diagram based on the first embodiment of the present disclosure;
[0024] Figure 2 This is a schematic diagram according to the second embodiment of the present disclosure;
[0025] Figure 3 This is a schematic diagram of a grid according to an embodiment of the present disclosure;
[0026] Figure 4 This is a schematic diagram according to the third embodiment of the present disclosure;
[0027] Figure 5 This is a schematic diagram of a stack structure according to an embodiment of the present disclosure;
[0028] Figure 6 This is a schematic diagram according to the fourth embodiment of the present disclosure;
[0029] Figure 7 This is a schematic diagram according to the fifth embodiment of the present disclosure;
[0030] Figure 8 This is a schematic diagram according to the sixth embodiment of the present disclosure;
[0031] Figure 9 This is a block diagram of an electronic device used to implement the meteorological data query method of the present disclosure embodiments. Detailed Implementation
[0032] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0033] Meteorological data is a set of data reflecting the weather. It can be divided into climate data and weather data. Climate data refers to the collection, processing, and compilation of various raw data observed using conventional meteorological instruments and specialized meteorological equipment. Weather data refers to real-time meteorological data used for weather analysis and forecasting services.
[0034] In contrast, weather data transforms into climate data over time, and climate data is much broader in scope than weather data. Climate data is long-term data, while weather data is short-term data.
[0035] The meteorological data in this embodiment can be climate data, weather data, or a combination of both; this embodiment does not impose any limitations.
[0036] Meteorological data plays a crucial role in both production activities and people's travel. Taking production activities, specifically road construction, as an example, meteorological data is one of the essential foundational data sources supporting the development of road data team products. It can be widely applied in scenarios including identifying road closures due to severe weather and flooding, crowdsourced road avoidance, and early warning systems for severe weather-related disruptions. Regarding travel, people can use meteorological data to choose their travel time and / or location, thereby improving travel safety.
[0037] Meteorological data retrieval is an important aspect of utilizing meteorological data. Commonly used methods for meteorological data retrieval in related technologies include:
[0038] Meteorological data is partitioned based on time to obtain meteorological data for different time zones. Based on weather elements such as temperature and precipitation, the meteorological data for different time zones are stored in a distributed file system as different files. For example, temperature data is stored in a distributed file system as a separate file from precipitation data, and vice versa, precipitation data is stored in a distributed file system as a separate file from temperature data, so that meteorological data can be queried from the distributed file system.
[0039] For example, when querying meteorological data, a full traversal of the meteorological data within the sliding time window can be performed using a sliding time window method. This could involve traversing all temperature data files and all precipitation data files in the distributed file system to obtain the corresponding meteorological data.
[0040] However, when using the above method to query meteorological data, it is necessary to fully traverse the meteorological data within a certain sliding time window, which results in a long query time and low efficiency. In addition, storing meteorological data through a distributed file system consumes a relatively large amount of storage space, which means there are technical problems of high resource consumption and high cost.
[0041] To avoid at least one of the aforementioned technical problems, the inventors of this disclosure, through creative labor, arrived at the inventive concept of this disclosure: an index structure constructed in memory as a key-value pair data structure, wherein the key in the key-value pair includes a grid identifier and the data value in the key-value pair includes meteorological data, so that when a query request is received, the meteorological data corresponding to the query request is determined and output based on the grid identifier corresponding to the query position indicated by the query request.
[0042] Based on the above-mentioned inventive concept, this disclosure provides a method and apparatus for querying meteorological data, which is applied to map technology and big data in the field of data processing technology.
[0043] Figure 1 This is a schematic diagram based on the first embodiment of the present disclosure, as shown below. Figure 1 As shown, the meteorological data query method of this disclosure includes:
[0044] S101: Receive query request.
[0045] The query request is used to retrieve meteorological data for a target geographic location. The target geographic location can be one or more regions, or one or more coordinates.
[0046] For example, the execution subject in this embodiment is a meteorological data query device (hereinafter referred to as the query device). The query device can be a server (such as a cloud server or a local server), a computer, a terminal device, a processor, a chip, etc., and this embodiment does not limit it.
[0047] The following example can be used to implement receiving query requests:
[0048] In one example, the query device may include a display device that can control the display device to output a query box, in which the user can enter a query request.
[0049] In another example, the query device can be connected to a display device, and a query box can be displayed through the display device, where the user can enter a query request.
[0050] In other words, the query device and the display device can be an integrated unit or two separate devices; this embodiment does not impose any limitations. Furthermore, users can input their query requests into the query box using input devices such as a mouse or keyboard.
[0051] In another example, the query device may include a voice processing device, which allows users to initiate query requests via voice. The voice processing device then performs voice recognition processing on the received voice query request and transmits the processed query request to the query device.
[0052] Similarly, the query device and the voice processing device can be an integrated device or two separate devices; this embodiment does not impose any limitations.
[0053] It is worth noting that the above examples are only for illustrative purposes, illustrating the possible ways in which a query device may receive query requests, and should not be construed as limiting the ways in which query requests can be received.
[0054] S102: Determine the grid to which the target geographic location belongs in the preset grid. The preset grid has a grid identifier.
[0055] S103: Determine and output the meteorological data corresponding to the query request from the index structure in memory based on the grid identifier corresponding to the target geographical location.
[0056] The index structure is a key-value pair data structure. The key in the key-value pair includes the grid identifier, and the data value in the key-value pair includes meteorological data. The preset grid is obtained by performing grid cutting processing on a preset range area.
[0057] The preset range area can be set based on needs, historical records, and experiments, and this embodiment does not impose any limitations. For example, the preset range area can be a region worldwide, a region nationwide, or a region within a province, etc.
[0058] Mesh cutting processing refers to the process of dividing a preset area into meshes to obtain individual meshes within the preset area, with each mesh having a unique identifier ID (i.e., mesh identifier).
[0059] For example, the mesh cutting process can be implemented using a spatial indexing algorithm (such as a divide-and-conquer algorithm, specifically the S2 algorithm) to determine each mesh in a preset range area and the mesh identifier corresponding to each mesh based on the spatial indexing algorithm.
[0060] In this embodiment, meteorological data is stored in memory as key-value pairs, rather than in a distributed file system as in related technologies, and the grid identifier is used as the key in the key-value pairs to determine the corresponding meteorological data.
[0061] It is worth noting that by storing key-value pairs in memory, where the data values in the key-value pairs can represent meteorological data, compared to storing meteorological data in a distributed file system, storage space can be reduced, thus achieving the technical effect of saving storage resources. Furthermore, by storing meteorological data as data values in key-value pairs, the efficiency of meteorological data querying can be improved, and query resources can be saved.
[0062] For example, the grid to which the target geographic location belongs can be determined from a preset grid. Since the preset grid has a grid identifier, the grid to which the target geographic location belongs also has a grid identifier, so the grid identifier corresponding to the target geographic location can be determined.
[0063] Since meteorological data is stored in key-value pairs in memory, it is possible to directly determine the meteorological data from memory, specifically to retrieve the meteorological data corresponding to the query request from the key-value pairs in memory.
[0064] Based on the above analysis, this disclosure provides a method for querying meteorological data, including: receiving a query request, wherein the query request is used to query meteorological data of a target geographical location; determining the grid to which the target geographical location belongs in a preset grid, the preset grid having a grid identifier; determining and outputting meteorological data corresponding to the query request from an index structure in memory based on the grid identifier corresponding to the target geographical location; wherein the index structure is a key-value pair data structure, the key in the key-value pair includes the grid identifier, the data value in the key-value pair includes meteorological data, and the preset grid is obtained by performing grid cutting processing on a preset range area. In this embodiment, by constructing an index structure with a key-value pair data structure in memory, the key in the key-value pair includes the grid identifier, and the data value in the key-value pair includes meteorological data, and combining the grid identifier corresponding to the target geographical location to obtain and output meteorological data corresponding to the query request from the key-value pair, the technical feature of obtaining and outputting meteorological data corresponding to the query request from the key-value pair in combination with the grid identifier corresponding to the target geographical location avoids the disadvantages of long traversal time and low efficiency when querying meteorological data using a distributed file system, thus improving query efficiency. Furthermore, by querying meteorological data in memory, the disadvantages of resource waste caused by using a distributed file system can be avoided, thus improving the technical effect of saving resources and storage costs.
[0065] Figure 2 This is a schematic diagram based on the second embodiment of the present disclosure, as shown below. Figure 2 As shown, the meteorological data query method of this disclosure includes:
[0066] S201: Parse and process the data file of the preset range area to obtain coordinates and meteorological data.
[0067] It is understood that, in order to avoid redundant explanations, the technical features that are the same as those in the above embodiments will not be repeated in this embodiment.
[0068] The data file includes information related to meteorological data, such as the meteorological data itself and the corresponding coordinates. The data file can be in NetCDF format.
[0069] For example, this step can be understood as: obtaining a data file in netcdf format within a preset range, the data file including meteorological data and the coordinates corresponding to the meteorological data, parsing the data file to extract the meteorological data and the coordinates corresponding to the meteorological data from the data file.
[0070] In some embodiments, after parsing the data file, the parsed meteorological data can be preprocessed, such as performing at least one of outlier filtering, precision truncation, and encoding on the parsed meteorological data.
[0071] The outlier filtering process refers to removing abnormal meteorological data from the parsed meteorological data, and this embodiment does not limit the determination of outliers.
[0072] In one example, the normal value range can be predetermined (similarly, the normal value range can be determined based on experience or historical records, etc.), and meteorological data that do not belong to the normal value range in the parsed meteorological data can be identified as outliers and removed.
[0073] In another example, meteorological data with a value of 0 can be identified as outliers and removed.
[0074] Outlier filtering serves several purposes. First, it filters out inaccurate meteorological data, ensuring the reliability and accuracy of the retained data. Second, it reduces storage space for outliers, saving memory resources. Third, it prevents outliers from interfering with the output and query data, improving their accuracy and reliability. Fourth, it reduces query time, increasing query efficiency.
[0075] Precision truncation refers to the adaptive adjustment of the number of bits in the analyzed meteorological data to avoid cumbersome representation. For example, precipitation of 0.12345 mm is truncated to 0.123 mm.
[0076] By using precision truncation processing, on the one hand, the drawback of cumbersome data representation caused by excessive data bits can be avoided; on the other hand, storage space can be reduced, thereby achieving the technical effect of saving storage resources; and on the other hand, the processed meteorological data can be made more consistent.
[0077] Encoding processing refers to processing the parsed meteorological data based on a preset number of integers. For example, processing the parsed meteorological data based on a 32-bit integer (int32). Through encoding processing, the storage space of meteorological data stored in memory can be relatively reduced, thereby saving storage resources and improving query efficiency.
[0078] In this embodiment, preprocessing the analyzed meteorological data using one or more of the above methods can avoid data redundancy and improve the efficiency of data processing.
[0079] Among these processes, outlier filtering, precision truncation, and encoding can be performed sequentially on the meteorological data obtained from the analysis.
[0080] S202: Perform grid cutting processing on the preset range area to obtain the grid identifiers of each grid in the preset range area, and determine the mapping relationship between the analyzed meteorological data and each grid identifier in the preset range area based on the analyzed coordinates.
[0081] For example, the spatial indexing algorithm described in the above embodiments can be used to perform grid cutting processing on the preset range area to divide the preset range area into multiple grids, such as... Figure 3 As shown, each grid has a grid identifier.
[0082] For example, a preset area can be divided into grids based on a preset cutting level. The cutting level can be determined based on requirements, historical records, and experiments, and this embodiment does not limit it. For example, if the cutting level is 13, the preset area can be divided into a series of grids of approximately 1km*1km in size based on this cutting level.
[0083] The coordinates obtained through parsing can be used as the basis for mapping, and meteorological data can be mapped to each grid identifier to construct the mapping relationship.
[0084] In some embodiments, determining the mapping relationship between the parsed meteorological data and the grid identifiers of a preset range area based on the parsed coordinates includes the following steps:
[0085] The first step is to perform interval segmentation on the obtained coordinates and meteorological data according to the preset time interval to obtain the coordinates and meteorological data of each time interval.
[0086] Similarly, the time interval can be determined based on demand, historical records, and experiments, and this embodiment does not impose any limitations. For example, the time interval can be 5 minutes, and the time range can be represented by [T, T+5] (in minutes).
[0087] For example, a data file can include data from the 24 hours preceding the current time, and data from the next 72 hours, also based on the current time. Then, with 5-minute intervals, the 96(72+24) hours can be divided into different time zones, thus obtaining the coordinates (such as latitude and longitude coordinates, which can be represented by [lat, lng], where lat is latitude and lng is longitude) and meteorological data for each time zone.
[0088] The second step is to determine the mapping relationship between the meteorological data in each time interval and the grid markers of the preset range area, based on the coordinates within each time interval.
[0089] For example, in conjunction with the above embodiments, the number of time intervals = (96*60) / 5 = 1142, that is, there are a total of 1142 time intervals. Then, for each time interval, the mapping relationship between the meteorological data and each grid identifier is determined based on the latitude and longitude coordinates within that time interval.
[0090] In this embodiment, by combining time intervals to determine time intervals, the mapping relationship can be determined in units of time intervals, which can improve the efficiency of determining the mapping relationship and improve the technical effect of the determined mapping relationship having higher accuracy and reliability.
[0091] S203: Based on the parsed coordinates, parsed meteorological data, mapping relationships, and grid identifiers of the preset range area, construct a key-value pair index structure in memory.
[0092] In other words, an index structure is stored in memory. The data structure of this index structure is a key-value pair, and this key-value pair can be used to represent coordinates, meteorological data, and grid identifiers.
[0093] It is worth noting that in this embodiment, by combining the parsed coordinates, the parsed meteorological data, the mapping relationship, and the grid identifiers of each grid in the preset range area to construct key-value pairs, the key-value pairs can fully represent the correspondence between coordinates and meteorological data, and between grid identifiers and meteorological data. Thus, when the meteorological data corresponding to the query request is determined based on the key-value pairs, the determined meteorological data corresponding to the query request can have a high degree of accuracy and reliability.
[0094] Based on the above analysis, it can be seen that the mapping relationship can be determined based on the time interval, and correspondingly, key-value pairs can be further constructed by combining the time interval. For example, in some embodiments, key-value pairs are constructed based on the parsed coordinates, parsed meteorological data, mapping relationship, and grid identifiers of each grid within a preset range, including the following steps:
[0095] First step: Determine the timestamp of each time interval by the maximum time of each time interval.
[0096] For example, in conjunction with the above embodiments, if the time interval is [T, T+5], then the maximum time is T+5, and correspondingly, T+5 is the timestamp of the time interval.
[0097] The second step is to construct key-value pairs based on the parsed coordinates, parsed meteorological data, mapping relationships, timestamps, and grid identifiers for the preset range area.
[0098] In other words, in this embodiment, in addition to representing coordinates, meteorological data, and grid identifiers, key-value pairs can further represent time-related information, namely timestamps. By representing richer content through key-value pairs, key-value pairs can have higher reliability, diversity, and flexibility. Thus, when combining key-value pairs to determine the meteorological data corresponding to a query request, the efficiency of determining the meteorological data corresponding to the query request can be improved, which is the technical effect of improving the efficiency of meteorological data query.
[0099] Of course, in other embodiments, the minimum time of each time interval can be used to determine the timestamp of each time interval, such as determining T as the timestamp.
[0100] In some embodiments, the second step may include the following sub-steps:
[0101] The first sub-step involves constructing the keys in key-value pairs from the parsed coordinates, grid identifiers within the preset range, and timestamps.
[0102] The second sub-step: Based on the mapping relationship and the grid identifiers of each grid in the preset range area, the parsed meteorological data is constructed into data values in key-value pairs.
[0103] For example, a key-value pair includes two parts: a key and a data value. In this embodiment, the key in the key-value pair may include three dimensions: the parsed coordinates, the grid identifier, and the timestamp. The data value in the key-value pair includes the parsed meteorological data.
[0104] The key-value pair data structure can be represented in the following way:
[0105] map <cellid,map<coordinate,map<time,weatherData> >>
[0106] Where cellid is the grid identifier, coordinate is the parsed coordinate, time is the timestamp, and weatherData is the parsed meteorological data.
[0107] In this embodiment, by determining the grid identifier, timestamp, and parsed coordinates as the keys in the key-value pairs, and determining the parsed meteorological data as the data values in the key-value pairs, it is possible to query the corresponding meteorological data from different dimensions, thereby improving the technical effect of query flexibility and diversity.
[0108] In some embodiments, after the index structure is constructed as described above, if a new data file is obtained, i.e., newly added meteorological data is obtained, the index structure can be updated based on the newly added meteorological data, and the update process can include the following steps:
[0109] First step: Perform a deep copy of the index structure to obtain backup data.
[0110] Deep copy refers to a process where the source object (i.e., the index structure) and the copied object (i.e., the backup data) are independent of each other; changes to one object will not affect the other. In other words, the index structure and the backup data are two independent objects; processing the backup data will not affect the index structure, and vice versa.
[0111] The first step is to merge the backup data with the newly added meteorological data to obtain the updated index structure. This updated index structure is then used for subsequent meteorological data queries.
[0112] For example, the merging process can be understood as the process of merging the key and data value in a key-value pair, such as adding a new key and data value. For specific implementation methods, please refer to the principle of constructing key-value pairs mentioned above, which will not be repeated here.
[0113] In this embodiment, updating the index structure through deep copying and merging processes can achieve independence between the preceding and subsequent index structures, avoiding data interference between them, thereby improving the reliability and accuracy of the update. Furthermore, when meteorological data is queried based on the updated index structure, the reliability and effectiveness of the query can be improved.
[0114] In some embodiments, the updated index structure can be obtained based on the time constancy of the stored meteorological data, that is, the time of the meteorological data stored in the index structure before and after the update is the same, such as 96 hours.
[0115] For example, determine the duration corresponding to the newly added meteorological data, and use this duration and the current time to determine the elimination time interval. The time interval with the longest distance from the current time is the key and data value within the elimination time interval are removed from the backup data.
[0116] In some embodiments, after obtaining the updated index structure, the original index structure can be deleted from memory to free up storage space and improve query efficiency.
[0117] Based on the above analysis, it can be seen that meteorological data is a process that changes over time. Therefore, data files can be obtained based on time periods. After constructing key-value pairs based on data files from earlier time periods, the key-value pairs can be updated based on data files from later time periods, and so on.
[0118] In some embodiments, progress data representing the progress of meteorological data can be configured in memory, specifically based on time complexity, so that the progress data is updated accordingly when previous key-value pairs are updated.
[0119] S204: Receive query request.
[0120] The query request is used to retrieve meteorological data for a target geographical location.
[0121] S205: Determine the grid to which the target geographic location belongs in the preset grid. The preset grid has a grid identifier.
[0122] S206: Determine and output the meteorological data corresponding to the query request from the index structure in memory based on the grid identifier corresponding to the target geographical location.
[0123] It is worth noting that in some embodiments, meteorological data queries can be implemented by combining time complexity, that is, by querying meteorological data within a constant time range. If the meteorological data query is completed within this constant time range, that is, if the meteorological data corresponding to the query request is determined within this constant time range, then the meteorological data corresponding to the query request is output. Conversely, if the meteorological data corresponding to the query request is not found within this constant time range, then a query failure message can be output to avoid the disadvantage of excessive query time affecting the user query experience, and to avoid the disadvantage of wasting query resources due to repeated queries.
[0124] It should be understood that the above-described embodiments for constructing key-value pairs can be independent embodiments, and the above-described updates to key-value pairs can also be independent embodiments, or they can be combined to obtain new embodiments. This disclosure does not limit the scope of the embodiments.
[0125] Figure 4 This is a schematic diagram based on the third embodiment of the present disclosure, as shown below. Figure 4 As shown, the meteorological data query method of this disclosure includes:
[0126] S401: Receive query request.
[0127] The query request is used to retrieve meteorological data for a target geographical location.
[0128] Similarly, to avoid redundant explanations, the technical features that are the same as those in the above embodiments will not be repeated in this embodiment.
[0129] S402: Determine the grid to which the target geographic location belongs in the preset grid. The preset grid has a grid identifier.
[0130] The preset grid is obtained by cutting a preset range of regions into grids.
[0131] S403: From the grid identifiers of each key-value pair, determine the grid identifier that is the same as the grid identifier corresponding to the target geographic location.
[0132] The memory includes an index structure, which is a key-value pair data structure. The key in the key-value pair includes a grid identifier, and the data value in the key-value pair includes meteorological data.
[0133] This step can be understood as determining the key in the key-value pair that corresponds to the grid identifier of the target geographic location.
[0134] S404: Retrieve the meteorological data corresponding to the same grid identifier as the determined key-value pair, and determine the meteorological data corresponding to the query request based on the retrieved meteorological data.
[0135] In this embodiment, by combining the key of the characterizing grid identifier in the key-value pair, the data value (i.e., meteorological data) corresponding to the key can be determined, which can improve query efficiency.
[0136] In some embodiments, the key in the key-value pair also includes the coordinates corresponding to the meteorological data. Accordingly, determining the meteorological data corresponding to the query request based on the obtained meteorological data includes the following steps:
[0137] First step: From the coordinates of each key-value pair, obtain the coordinates of the area covered by the same grid identifier as the determined coordinates.
[0138] As can be seen from the above embodiments, a grid identifier is an identifier for a region, which may include multiple coordinates. Therefore, in this step, the coordinates included in the region covered by the same grid identifier can be determined from the coordinates representing the values in the key-value pairs, that is, the coordinates in the grid to which the target geographic location belongs can be determined.
[0139] The second step is to determine the coordinates closest to the target geographical location from the acquired coordinates, and then extract the meteorological data corresponding to the coordinates closest to the target geographical location from the acquired meteorological data.
[0140] The extracted meteorological data is the meteorological data corresponding to the query request.
[0141] Based on the above analysis, considering that the coordinates are obtained through parsing, there may be differences in the precision of the division, the presence of decimal places, and certain errors. The coordinates in the key-value pair may not be exactly the same as the coordinates corresponding to the target geographical location. Therefore, we can determine the coordinates that are relatively closest to the target geographical location from each coordinate in the key-value pair, and determine the corresponding data value (i.e., meteorological data) from the key-value pair based on the coordinates. This will ensure that the determined meteorological data has a high degree of accuracy and reliability.
[0142] As can be seen from the above embodiments, the key in the key-value pair can also include a timestamp. Accordingly, if the query request carries a query time, the meteorological data corresponding to the query request can be determined by combining the timestamp and the query time. For example, this can be achieved through the following steps:
[0143] First step: Determine the timestamp corresponding to the query time in the key-value pair.
[0144] For example, the time interval corresponding to the query time can be determined based on the above time interval division method, and the maximum time value corresponding to the time interval can be determined as the timestamp in the key-value pair corresponding to the query time.
[0145] The second step is to extract the meteorological data with the timestamp corresponding to the query time from the acquired meteorological data.
[0146] The extracted meteorological data is determined to be the meteorological data corresponding to the query request.
[0147] In this embodiment, by combining the query time and timestamp, the meteorological data corresponding to the query request is determined, thereby improving query efficiency. It is understood that this embodiment and the aforementioned coordinate-based method for querying meteorological data can be independent embodiments, or they can be combined to obtain new embodiments, thereby improving the flexibility and diversity of queries.
[0148] It is worth noting that the above-mentioned query method using timestamps can be understood as a "time query method", and the query method using coordinates can be understood as a "point query method". In other embodiments, it can also be a "spatial query method" and a "Top N query method".
[0149] The "spatial query method" is explained as follows:
[0150] The "spatial query method" can also be called the "regional query method." In contrast to the "point query method" which queries a specific location (such as specific coordinates), the "spatial query method" queries meteorological data for a certain area.
[0151] For example, the target geographic location includes at least two input coordinates. A query area is generated based on each input coordinate, and the grid to which the query area belongs is determined from a preset grid. The grid identifier corresponding to the grid is determined, and the same grid identifier is determined from the key-value pair, so as to determine the meteorological data corresponding to the same grid identifier from the data values in the key-value pair.
[0152] In this embodiment, the query area is determined based on multiple input coordinates, and the grid identifier corresponding to the query area is determined. The data value of the key-value pair corresponding to the grid identifier of the query area is then determined as the meteorological data corresponding to the query request, thereby realizing the query of meteorological data and achieving the technical effect of query flexibility and diversity.
[0153] Similarly, this embodiment can also be combined with timestamps to form new embodiments.
[0154] In some embodiments, each input coordinate is the vertex coordinate of the polygon corresponding to the query region.
[0155] In other words, an input coordinate can be determined as the vertex coordinate, thereby obtaining multiple vertices, and a polygon can be determined based on the multiple vertices. The area enclosed by this polygon is the query area, which improves the reliability and efficiency of determining the query area.
[0156] The "Top N query method" is explained below:
[0157] "Top N query method" refers to querying meteorological data for the top N (N is a positive integer greater than 1) regions whose target geographical location meets the meteorological data requirements.
[0158] Meteorological data requests can include precipitation data requests, such as querying the 10 regions with the most precipitation; meteorological data requests can also include temperature data requests, such as querying the 10 regions with the highest temperature. The unit of temperature data can be degrees Celsius (°C). Meteorological data requests can also include other meteorological data-related requests, which will not be listed here.
[0159] For example, the query device can construct a heap structure or a tree structure in memory based on the meteorological data requirements, sequentially select data values from the key-value pairs to traverse the heap structure or tree structure, obtain the data values in the key-value pairs that satisfy the meteorological data, and determine the data values in the key-value pairs that satisfy the meteorological data as the meteorological data corresponding to the query request.
[0160] The heap structure can be either a min-heap or a max-heap; this embodiment does not limit the type. The construction principles of heap and tree structures can be found in relevant technical descriptions, and will not be repeated here.
[0161] Taking the small top pile structure and precipitation data as an example, combined with... Figure 5 The following is an illustrative explanation of how to determine the meteorological data corresponding to a query request:
[0162] As can be seen from the above embodiments, precipitation data can characterize precipitation amount, and the unit of precipitation amount can be millimeters. Accordingly, if the meteorological data requirement is to identify the seven regions with the highest precipitation, then a system can be constructed in memory as follows: Figure 5 The small top heap shown has 7 heaps, and the data for each heap is the precipitation (in millimeters).
[0163] like Figure 5 As shown, each circle represents a pile, and the value in the pile is the precipitation data. For example, 0.1 in the pile represents 0.1 millimeters of precipitation, and so on. These values will not be listed here.
[0164] Iterate through the data values in the key-value pairs (i.e., meteorological data, specifically precipitation in the meteorological data), and when the precipitation is greater than the precipitation in any pile, replace the smallest precipitation in each pile with the traversed precipitation, and so on, until the 7 piles with the most precipitation are obtained, and determine the region corresponding to the precipitation in each of the 7 piles, thus obtaining the 7 regions with the most precipitation.
[0165] like Figure 5 As shown, the precipitation obtained by traversing the key-value pairs is 0.9 mm, so the 0.9 mm precipitation is used to replace the 0.1 mm precipitation.
[0166] In this embodiment, by constructing a heap structure or a tree structure to determine the meteorological data corresponding to the query request, it is possible to quickly obtain the corresponding meteorological data based on the meteorological data requirement, thereby improving the efficiency and reliability of the query.
[0167] Based on the above analysis, it can be seen that the technical solution provided in this disclosure can support different query methods, thereby making the query of meteorological data more flexible and diverse, and improving the technical effect of adaptability and timeliness of multiple query methods.
[0168] S405: Output the meteorological data corresponding to the query request.
[0169] In some embodiments, if the meteorological data corresponding to the query request is an array or a sequence list, then S405 may include: traversing the array or sequence list to convert the array or sequence list into a data stream, and outputting the meteorological data corresponding to the query request based on the data stream.
[0170] In this embodiment, meteorological data corresponding to the query request is output via a data stream. On the one hand, this enables greater diversity and flexibility in outputting meteorological data corresponding to the query request. On the other hand, it avoids the drawback of low transmission speed caused by excessive data volume, thereby improving the efficiency of transmitting meteorological data corresponding to the query request.
[0171] For example, the amount of meteorological data corresponding to the query request can be determined first, and then compared with a preset data amount threshold. If the data amount reaches (i.e., is greater than or equal to) the data amount threshold, the meteorological data corresponding to the query request can be output in the form of a data stream; otherwise, if the data amount does not reach (i.e. is less than) the data amount threshold, the meteorological data corresponding to the query request can be output directly.
[0172] Similarly, the data volume threshold can be determined based on demand, historical records, and experiments, and this embodiment does not impose any limitations.
[0173] In this embodiment, determining whether to use a data stream to transmit the meteorological data corresponding to the query request is based on the size of the meteorological data corresponding to the query request, which can ensure the effectiveness and reliability of data transmission as much as possible.
[0174] Figure 6 This is a schematic diagram based on the fourth embodiment of the present disclosure, as shown below. Figure 6 As shown, the meteorological data query device 600 of this embodiment includes:
[0175] The receiving unit 601 is used to receive a query request, wherein the query request is used to query meteorological data of a target geographical location.
[0176] The first determining unit 602 is used to determine the grid to which the target geographical location belongs in the preset grid, wherein the preset grid has a grid identifier.
[0177] The second determining unit 603 is used to determine the meteorological data corresponding to the query request from the index structure in memory based on the grid identifier corresponding to the target geographical location.
[0178] Output unit 604 is used to output meteorological data corresponding to the query request.
[0179] The index structure is a key-value pair data structure. The key in the key-value pair includes the grid identifier, and the data value in the key-value pair includes meteorological data. The preset grid is obtained by performing grid cutting processing on a preset range area.
[0180] Figure 7 This is a schematic diagram based on the fifth embodiment of the present disclosure, as shown below. Figure 7As shown, the meteorological data query device 700 of this embodiment includes:
[0181] The parsing unit 701 is used to parse the data file of the preset range area to obtain coordinates and meteorological data.
[0182] The processing unit 702 is used to perform at least one of the following on the parsed meteorological data: outlier filtering, precision truncation, and encoding.
[0183] The cutting unit 703 is used to perform grid cutting processing on a preset range area to obtain the grid identifiers of each grid in the preset range area.
[0184] The third determining unit 704 is used to determine the mapping relationship between the analyzed meteorological data and the grid identifiers of the preset range area based on the coordinates obtained from the analysis.
[0185] Combination Figure 7 It is understood that, in some embodiments, the third determining unit 704 includes:
[0186] The segmentation subunit 7041 is used to perform interval segmentation processing on the parsed coordinates and the parsed meteorological data according to a preset time interval, so as to obtain the coordinates and meteorological data of each time interval.
[0187] The fourth determining subunit 7042 is used to determine the mapping relationship between meteorological data in each time interval and grid identifiers in a preset range area, based on the coordinates in each time interval.
[0188] The first building unit 705 is used to build key-value pairs based on the parsed coordinates, parsed meteorological data, mapping relationships, and grid identifiers of each grid in a preset range area.
[0189] Combination Figure 7 It is understood that, in some embodiments, the first building unit 705 includes:
[0190] The fifth determining subunit 7051 is used to determine the timestamp of each time interval by the maximum time of each time interval.
[0191] Sub-unit 7052 is constructed to build key-value pairs based on the parsed coordinates, parsed meteorological data, mapping relationships, timestamps, and grid identifiers of the preset range area.
[0192] In some embodiments, constructing subunit 7052 includes:
[0193] The first construction module is used to construct the keys in key-value pairs from the parsed coordinates, grid identifiers of the preset range area, and timestamps.
[0194] The second construction module is used to construct the parsed meteorological data into key-value pairs based on the mapping relationship and the grid identifiers of each grid in the preset range area.
[0195] Acquisition unit 706 is used to acquire newly added meteorological data.
[0196] Copy unit 707 is used to perform a deep copy of the index structure to obtain backup data.
[0197] Merging unit 708 is used to merge backup data with newly added meteorological data to obtain an updated index structure.
[0198] The receiving unit 709 is used to receive a query request, wherein the query request is used to query meteorological data of a target geographical location.
[0199] The first determining unit 710 is used to determine the grid to which the target geographical location belongs in the preset grid, wherein the preset grid has a grid identifier.
[0200] Combination Figure 7 It is understood that, in some embodiments, the target geographic location includes at least two input coordinates; the first determining unit 710 includes:
[0201] Generating sub-unit 7101 is used to generate a query area based on each input coordinate.
[0202] The third determining subunit 7102 is used to determine the grid to which the query area belongs from the preset grid.
[0203] In some embodiments, each input coordinate is the vertex coordinate of the polygon corresponding to the query region.
[0204] The second determining unit 711 is used to determine the meteorological data corresponding to the query request from the index structure in memory based on the grid identifier corresponding to the target geographical location.
[0205] The index structure is a key-value pair data structure. The key in the key-value pair includes the grid identifier, and the data value in the key-value pair includes meteorological data. The preset grid is obtained by performing grid cutting processing on a preset range area.
[0206] Combination Figure 7 It is understood that, in some embodiments, the second determining unit 711 includes:
[0207] The first determining subunit 7111 is used to determine, from each grid identifier of the key-value pair, the grid identifier that is the same as the grid identifier corresponding to the target geographic location.
[0208] The acquisition sub-unit 7112 is used to retrieve meteorological data corresponding to the same grid identifier determined from the key-value pair.
[0209] The second determining subunit 7113 is used to determine the meteorological data corresponding to the query request based on the acquired meteorological data.
[0210] In some embodiments, the key in the key-value pair further includes the coordinates corresponding to the meteorological data; the second determining subunit 7113 includes:
[0211] The acquisition module is used to obtain the coordinates of the area covered by the same grid identifier as the determined coordinates from the coordinates of the key-value pairs.
[0212] The first determining module is used to determine the coordinates closest to the target geographical location from the acquired coordinates.
[0213] The first extraction module is used to extract meteorological data corresponding to the coordinates closest to the target geographical location from the acquired meteorological data. The extracted meteorological data is the meteorological data corresponding to the query request.
[0214] In some embodiments, the key in the key-value pair further includes a timestamp corresponding to the meteorological data; the query request carries the query time; the second determining subunit 7113 includes:
[0215] The second determination module is used to determine the timestamp corresponding to the query time in the key-value pair.
[0216] The second extraction module is used to extract meteorological data with timestamps corresponding to the query time from the acquired meteorological data, wherein the extracted meteorological data is determined to be the meteorological data corresponding to the query request.
[0217] Output unit 712 is used to output meteorological data corresponding to the query request.
[0218] Combination Figure 7 It is understood that, in some embodiments, if the meteorological data corresponding to the query request is an array or a sequence list, the output unit 712 includes:
[0219] The sixth determining subunit 7121 is used to determine the amount of meteorological data corresponding to the query request.
[0220] The conversion subunit 7122 is used to traverse the array or sequence list to convert the array or sequence list into a data stream if the data volume reaches a preset data volume threshold.
[0221] Output subunit 7123 is used to output meteorological data corresponding to the query request in a data stream manner.
[0222] In some embodiments, the target geographic location is the top N regions that meet the meteorological data requirements, where N is a positive integer greater than 1; the device 700 further includes:
[0223] The second building unit 713 is used to build a heap structure or a tree structure in memory based on meteorological data requirements.
[0224] Traversal unit 714 is used to sequentially select data value pairs from the key-value pairs and traverse the heap structure or tree structure to obtain the data values in the key-value pairs that satisfy the meteorological data.
[0225] The fourth determining unit 715 is used to determine the data value in the key-value pair that satisfies the meteorological data as the meteorological data corresponding to the query request.
[0226] Figure 8 This is a schematic diagram based on the sixth embodiment of the present disclosure, as shown below. Figure 8 As shown, the electronic device 800 in this disclosure may include a processor 801 and a memory 802.
[0227] Memory 802 is used to store programs. Memory 802 may include volatile memory, such as random-access memory (RAM), such as static random-access memory (SRAM), double data rate synchronous dynamic random-access memory (DDR SDRAM), etc.; memory may also include non-volatile memory, such as flash memory. Memory 802 is used to store computer programs (such as application programs, functional modules, etc. that implement the above methods), computer instructions, etc. The computer programs, computer instructions, etc., can be partitioned and stored in one or more memories 802. Furthermore, the computer programs, computer instructions, data, etc., can be accessed by processor 801.
[0228] The aforementioned computer programs and instructions can be stored in one or more partitions of memory 802. Furthermore, the aforementioned computer programs and instructions can be invoked by processor 801.
[0229] The processor 801 is configured to execute the computer program stored in the memory 802 to implement the various steps in the methods described in the above embodiments.
[0230] For details, please refer to the relevant descriptions in the preceding method embodiments.
[0231] The processor 801 and the memory 802 can be independent structures or integrated structures. When the processor 801 and the memory 802 are independent structures, the memory 802 and the processor 801 can be coupled together via bus 803.
[0232] The electronic device in this embodiment can execute the technical solution in the above method. Its specific implementation process and technical principle are the same, and will not be repeated here.
[0233] The collection, storage, use, processing, transmission, provision, and disclosure of user personal information (such as location-related information in query requests) involved in the technical solution disclosed herein comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0234] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0235] According to embodiments of this disclosure, this disclosure also provides a computer program product comprising: a computer program stored in a readable storage medium, at least one processor of an electronic device being able to read the computer program from the readable storage medium, and the at least one processor executing the computer program causing the electronic device to perform the scheme provided in any of the above embodiments.
[0236] Figure 9 A schematic block diagram of an example electronic device 900 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0237] like Figure 9As shown, device 900 includes a computing unit 901, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 902 or a computer program loaded from storage unit 908 into random access memory (RAM) 903. RAM 903 may also store various programs and data required for the operation of device 900. The computing unit 901, ROM 902, and RAM 903 are interconnected via bus 904. Input / output (I / O) interface 905 is also connected to bus 904.
[0238] Multiple components in device 900 are connected to I / O interface 905, including: input unit 906, such as keyboard, mouse, etc.; output unit 907, such as various types of monitors, speakers, etc.; storage unit 908, such as disk, optical disk, etc.; and communication unit 909, such as network card, modem, wireless transceiver, etc. Communication unit 909 allows device 900 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0239] The computing unit 901 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 901 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 901 performs the various methods and processes described above, such as the meteorological data query method. For example, in some embodiments, the meteorological data query method can be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 908. In some embodiments, part or all of the computer program can be loaded and / or installed on device 900 via ROM 902 and / or communication unit 909. When the computer program is loaded into RAM 903 and executed by the computing unit 901, one or more steps of the meteorological data query method described above can be performed. Alternatively, in other embodiments, the computing unit 901 can be configured to perform the meteorological data query method by any other suitable means (e.g., by means of firmware).
[0240] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0241] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0242] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0243] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0244] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0245] Computer systems can include clients and servers. Clients and servers are generally geographically separated and typically interact via communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. A server can be a cloud server, also known as a cloud computing server or cloud host, a hosting product within the cloud computing service ecosystem, addressing the shortcomings of traditional physical hosts and VPS (Virtual Private Server, or simply "VPS") services, such as high management difficulty and weak business scalability. Servers can also be servers for distributed systems or servers incorporating blockchain technology.
[0246] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.
[0247] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A method for querying meteorological data, comprising: receiving a query request, wherein the query request is used to query meteorological data of a target geographical location; determining a grid to which the target geographical location belongs in a preset grid, the preset grid having a grid identifier, and determining and outputting meteorological data corresponding to the query request from an index structure in memory according to the grid identifier corresponding to the target geographical location; wherein the index structure is a data structure of key-value pairs, the key in the key-value pair includes a grid identifier, the data value in the key-value pair includes meteorological data, and the preset grid is obtained by grid cutting processing of a preset range region based on a spatial index algorithm; the method further comprises: parsing a data file of the preset range region obtained to obtain coordinates and meteorological data; grid cutting processing the preset range region to obtain each grid identifier of the preset range region, and determining a mapping relationship between the parsed meteorological data and each grid identifier of the preset range region according to the parsed coordinates; constructing the key-value pairs in memory according to the parsed coordinates, the parsed meteorological data, the mapping relationship, and each grid identifier of the preset range region; the method further comprises: obtaining newly added meteorological data; deeply copying the index structure to obtain backup data, and merging the backup data with the newly added meteorological data to obtain an updated index structure; configuring progress data for representing progress related to meteorological data in memory based on time complexity, and updating the progress data when updating a previous key-value pair. 2.According to the method of claim 1, the target geographical location is the first N regions satisfying the meteorological data demand, N is a positive integer greater than 1; the method further comprises: constructing a heap structure or a tree structure in the memory based on the meteorological data demand, and sequentially selecting data values from the key-value pairs to traverse the heap structure or the tree structure to obtain data values in the key-value pairs satisfying the meteorological data; determining the data values in the key-value pairs satisfying the meteorological data as the meteorological data corresponding to the query request.
3. The method of claim 1, wherein, determining the meteorological data corresponding to the query request from the index structure in memory according to the grid identifier corresponding to the target geographical location, comprises: determining a grid identifier identical to the grid identifier corresponding to the target geographical location from each grid identifier of the key-value pairs; obtaining meteorological data corresponding to the determined identical grid identifier from the key-value pairs, and determining the meteorological data corresponding to the query request according to the obtained meteorological data.
4. The method of claim 3, wherein, the key in the key-value pair further includes coordinates corresponding to the meteorological data; determining the meteorological data corresponding to the query request according to the obtained meteorological data, comprises: obtaining each coordinate included in a region covered by the determined identical grid identifier from each coordinate of the key-value pairs; The closest coordinate to the target geographic location is determined from the obtained coordinates, and the closest coordinate corresponding to the target geographic location is extracted from the obtained meteorological data, wherein the extracted meteorological data is the meteorological data corresponding to the query request. 5.The method of claim 3 or 4, wherein the key in the key-value pair further comprises a time stamp corresponding to the meteorological data. The query request carries a query time; The meteorological data corresponding to the query request is determined according to the obtained meteorological data, including: The timestamp corresponding to the query time in the key-value pair is determined. The meteorological data corresponding to the timestamp is extracted from the obtained meteorological data, wherein the extracted meteorological data is determined as the meteorological data corresponding to the query request.
6. The method of claim 1, wherein, The target geographic location includes at least two incoming coordinates; The grid to which the target geographic location belongs in the preset grid is determined, including: The query area is generated according to each of the incoming coordinates, and the grid to which the query area belongs in the preset grid is determined.
7. The method of claim 6, wherein, Each of the incoming coordinates is the vertex coordinate of the polygon corresponding to the query area.
8. The method of claim 1, wherein, According to the parsed coordinates, a mapping relationship between the parsed meteorological data and the grid identifiers of the preset range area is determined, including: The parsed coordinates and the parsed meteorological data are interval divided according to a preset time interval, to obtain the coordinates of each time interval and the meteorological data of each time interval; According to the coordinates in each time interval, a mapping relationship between the meteorological data in each time interval and the grid identifiers of the preset range area is determined.
9. The method of claim 8, wherein, According to the parsed coordinates, the parsed meteorological data, the mapping relationship, and the grid identifiers of the preset range area, the key-value pair is constructed, including: The maximum time of each time interval is determined as the timestamp of each time interval, and the key-value pair is constructed according to the parsed coordinates, the parsed meteorological data, the mapping relationship, the timestamps, and the grid identifiers of the preset range area.
10. The method of claim 9, wherein, According to the parsed coordinates, the parsed meteorological data, the mapping relationship, the timestamps, and the grid identifiers of the preset range area, the key-value pair is constructed, including: The parsed coordinates, the grid identifiers of the preset range area, and the timestamps are constructed as the keys in the key-value pair; According to the mapping relationship and the grid identifiers of the preset range area, the parsed meteorological data is constructed as the data value in the key-value pair.
11. The method of claim 7, after parsing the obtained data file of the preset range area to obtain coordinates and meteorological data, the method further comprising: At least one of outlier filtering processing, precision truncation processing, and encoding processing is performed on the parsed meteorological data.
12. The method of any one of claims 1-11, wherein, If the meteorological data corresponding to the query request is an array or a list, outputting the meteorological data corresponding to the query request, including: The array or list is traversed to convert the array or list into a data stream, and the meteorological data corresponding to the query request is output in a data stream-based manner.
13. The method of claim 12, further comprising: determining a data volume of the meteorological data corresponding to the query request; and traversing the array or list to convert the array or list into a data stream, including: traversing the array or list to convert the array or list into a data stream if the data volume reaches a preset data volume threshold.
14. A device for querying meteorological data, comprising: a receiving unit configured to receive a query request, wherein the query request is used to query meteorological data of a target geographical location; a first determining unit configured to determine a grid to which the target geographical location belongs in a preset grid, the preset grid having a grid identifier; a second determining unit configured to determine, from an index structure in a memory, meteorological data corresponding to the query request according to a grid identifier corresponding to the target geographical location; and an output unit configured to output the meteorological data corresponding to the query request; wherein the index structure is a data structure of key-value pairs, a key in the key-value pair includes a grid identifier, and a data value in the key-value pair includes meteorological data, the preset grid is obtained by grid cutting processing of a preset range region based on a spatial index algorithm; the device further comprises: an analyzing unit configured to analyze a data file of the preset range region to obtain coordinates and meteorological data; a cutting unit configured to perform grid cutting processing on the preset range region to obtain each grid identifier of the preset range region; a third determining unit configured to determine a mapping relationship between the analyzed meteorological data and each grid identifier of the preset range region according to the analyzed coordinates; and a first constructing unit configured to construct the key-value pairs in the memory according to the analyzed coordinates, the analyzed meteorological data, the mapping relationship, and each grid identifier of the preset range region; the device further comprises: an obtaining unit configured to obtain newly added meteorological data; a copying unit configured to perform deep copying on the index structure to obtain backup data; a merging unit configured to merge the backup data and the newly added meteorological data to obtain an updated index structure; and an updating unit configured to configure progress data related to progress of meteorological data in the memory based on time complexity, and to update the progress data correspondingly when updating a previous key-value pair.
15. The device of claim 14, wherein the target geographical location is a top N region satisfying a meteorological data demand, N being a positive integer greater than 1; the device further comprises: a second constructing unit configured to construct a heap structure or a tree structure in the memory based on the meteorological data demand; a traversing unit configured to traverse the heap structure or the tree structure by sequentially selecting data values from the key-value pairs to obtain data values in the key-value pairs satisfying the meteorological data; and a fourth determining unit configured to determine the data values in the key-value pairs satisfying the meteorological data as the meteorological data corresponding to the query request. 16. The apparatus of claim 14, wherein, The first determining sub-unit is configured to determine, from the grid identifiers of the key-value pairs, a grid identifier that is the same as a grid identifier corresponding to the target geographic location; The obtaining sub-unit is configured to obtain, from the key-value pairs, meteorological data corresponding to the determined same grid identifier; The second determining sub-unit is configured to determine, according to the obtained meteorological data, meteorological data corresponding to the query request.
17. The apparatus of claim 16, wherein, The keys in the key-value pairs further include coordinates corresponding to meteorological data; and the second determining sub-unit includes: The obtaining module is configured to obtain, from the coordinates of the key-value pairs, coordinates included in a region covered by the determined same grid identifier; The first determining module is configured to determine, from the obtained coordinates, a coordinate closest to the target geographic location; The first extracting module is configured to extract, from the obtained meteorological data, meteorological data corresponding to the coordinate closest to the target geographic location, wherein the extracted meteorological data is the meteorological data corresponding to the query request.
18. The apparatus of claim 16 or 17, the key in the key-value pair further comprising a time stamp corresponding to the meteorological data; The query request carries a query time; The second determining sub-unit includes: The second determining module is configured to determine a timestamp corresponding to the query time in the key-value pairs; The second extracting module is configured to extract, from the obtained meteorological data, meteorological data corresponding to the timestamp corresponding to the query time, wherein the extracted meteorological data is determined as the meteorological data corresponding to the query request.
19. The apparatus of claim 14, wherein, The target geographic location includes at least two incoming coordinates; The first determining unit includes: The generating sub-unit is configured to generate a query region according to the incoming coordinates; The third determining sub-unit is configured to determine, from the preset grid, a grid to which the query region belongs.
20. The apparatus of claim 19, wherein, Each of the incoming coordinates is a vertex coordinate of a polygon corresponding to the query region.
21. The apparatus of claim 14, wherein, The third determining unit includes: The segmenting sub-unit is configured to perform interval segmentation processing on the parsed coordinates and the parsed meteorological data according to a preset time interval, to obtain coordinates of each time interval and meteorological data of each time interval; The fourth determining sub-unit is configured to determine, in units of time intervals, a mapping relationship between meteorological data in each time interval and the grid identifiers of the preset range region, according to the coordinates in each time interval.
22. The apparatus of claim 20, wherein, The first constructing unit includes: The fifth determining sub-unit is configured to determine, as a timestamp of each time interval, a maximum time of each time interval; The constructing sub-unit is configured to construct the key-value pairs according to the parsed coordinates, the parsed meteorological data, the mapping relationship, the timestamps, and the grid identifiers of the preset range region.
23. The apparatus of claim 22, wherein, The constructing sub-unit includes: The first constructing module is configured to construct, as keys in the key-value pairs, the parsed coordinates, the grid identifiers of the preset range region, and the timestamps; The second constructing module is configured to construct, as data values in the key-value pairs, the parsed meteorological data according to the mapping relationship and the grid identifiers of the preset range region.
24. The apparatus of claim 14, further comprising: The processing unit is configured to perform at least one of outlier filtering, precision truncation, and encoding on the parsed meteorological data.
25. The apparatus of any one of claims 14-24, wherein, If the meteorological data corresponding to the query request is an array or a list, the output unit comprises: a conversion sub-unit configured to traverse the array or the list to convert the array or the list into a data stream; and an output sub-unit configured to output the meteorological data corresponding to the query request in a data stream manner.
26. The apparatus of claim 25, wherein the output unit further comprises: a sixth determination sub-unit configured to determine a data amount of the meteorological data corresponding to the query request; and the conversion sub-unit is configured to traverse the array or the list to convert the array or the list into a data stream if the data amount reaches a preset data amount threshold.
27. An electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-13.
28. A non-transitory computer readable storage medium having stored thereon computer instructions, wherein, The computer instructions are used to enable the computer to perform the method of any one of claims 1-13.
29. A computer program product comprising a computer program which, when executed by a processor, implements the steps of the method of any one of claims 1-13.
Citation Information
Patent Citations
Spatio-temporal data management system, spatio-temporal data management method, and program thereof
CN103514243A
Meteorological data query method and device and storage medium
CN111090794A