Electric vehicle charging station searching method based on neighbor table query
By establishing a quad-tree model and neighbor table, the effective search range is quickly determined, and the problems of spatial distribution density and low search efficiency in the search of existing electric vehicle charging stations are solved, and efficient acquisition of charging station location information is achieved.
Patent Information
- Application Number
- CN202311380104.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2022-10-24
- Filing Date
- 2023-10-23
- Publication Date
- 2025-07-18
AI Technical Summary
The existing electric vehicle charging station search methods are lacking when considering the spatial distribution density and effective search range, resulting in high time complexity, long search time and high difficulty, which reduces the search efficiency.
By using a method based on neighbor table query, by establishing a quad-tree model and neighbor table, the search area is divided according to the aspect ratio of the city map area and the number of charging stations required by users, and the effective search range is quickly determined through the neighbor table. Multi-threaded parallel calculation is used to find the nearest K charging stations.
It reduces the time and space complexity of charging station searches, reduces the search scale and difficulty of algorithms, and improves the efficiency of obtaining location information of charging stations around electric vehicles.
Smart Images

Figure CN120336645A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of electric vehicles, and particularly relates to an electric vehicle charging station search method based on neighbor table query. Background Art
[0002] Electric vehicles have attracted much attention in the national low-carbon transportation construction due to their advantages of low pollution and high efficiency. Under the support of national policies and the strong layout of enterprises, the current ownership of electric vehicles maintains a growth rate of more than 50% per year. Although electric vehicles have entered a period of rapid development in recent years, their development is also affected by a series of restrictive factors. Among them, the small number of charging stations is one of the main obstacles for pure electric vehicles to be widely accepted. At present, the ratio of electric vehicles to charging piles exceeds 10:1, and the regional differences are relatively obvious. About 1 / 3 of the drivers have encountered the situation that the battery performance has seriously declined due to over-discharge of the battery caused by failure to charge in time. When searching for nearby charging stations in an unfamiliar city, usually, Baidu Map can be used to search for nearby charging stations. However, due to the possible queuing phenomenon at the charging stations, repeated searches are required.
[0003] The K-Nearest Neighbor (KNN) classification algorithm is a theoretically relatively mature method. Its idea is: in the feature space, if most of the K nearest (i.e., the nearest in the feature space) samples near a sample belong to a certain category, then this sample also belongs to this category. For the KNN problem or the K-nearest neighbor problem: given a data set and a point, find the K nearest data from the data set to the given point, which has wide application value in image classification, information acquisition, pattern recognition, etc.
[0004] Regarding the electric vehicle charging station search method, most of the current search technologies only consider the distance as a factor to determine the shortest time path between the electric vehicle and the searched charging station.
[0005] The existing electric vehicle charging station search methods lack consideration in terms of the spatial distribution density of points and the effective search range in the search area, resulting in a high time complexity, which not only increases the search time but also increases the search difficulty and reduces the search efficiency. Summary of the Invention
[0006] The present invention provides an electric vehicle charging station search method and device based on neighbor table query. This method reduces the time and space complexity of charging station search, reduces the search scale and difficulty of the algorithm, and improves the efficiency of obtaining the location information of charging stations around electric vehicles.
[0007] An electric vehicle charging station search method based on neighbor table query provided by the present invention includes:
[0008] Obtain the real-time position of the electric vehicle. Based on the position of the electric vehicle itself, obtain the map of the city where it is located and the location distribution of charging stations in that city. If the aspect ratio of the map area of the city is less than a preset value, take the map area of the city as the search area, and take the number of charging stations that the user needs to search as the K value. Establish a quadtree model according to a preset threshold. Here, this threshold is used to establish the quadtree model and usually takes a value much larger than the K value. For example, it is greater than 4 times the K value. Divide the map area of the city into node areas corresponding to the quadtree model according to the threshold, and establish a neighbor table based on the spatial position. According to the spatial position of the location selected by the user in the city map, determine the node area where this location is located, determine the effective search range by querying the neighbor table, and based on the effective search range, calculate the distances between all points in this search range and the selected location in parallel, so as to quickly find the K nearest charging stations. Moreover, as the dynamic change of the position of the vehicle in the current city, the quadtree model corresponding to the city map and its neighbor table can also be used multiple times for the search of charging stations.
[0009] According to an electric vehicle charging station search method based on neighbor table query provided by the present invention, the step of establishing a quadtree model according to a preset threshold includes: dividing the spatial area layer by layer in the quadtree manner. First, divide the initial search area into four sub-areas. If the number of points in a sub-area is greater than the preset threshold, further divide this sub-area into four smaller sub-areas, and recursively do so until the number of points in each sub-area does not exceed the preset threshold, so as to ensure that the distribution density of points in each leaf node area is relatively uniform.
[0010] According to an electric vehicle charging station search method based on neighbor table query provided by the present invention, during the process of establishing the quadtree model, store the boundary point coordinates of each sub-area, as well as information such as the spatial positions and quantities of all included data points, so as to correspondingly divide all data points in the specified area into the areas corresponding to the leaf nodes of the quadtree model.
[0011] According to an electric vehicle charging station search method based on neighbor table query provided by the present invention, the step of dividing the map area of the city into node areas corresponding to the quadtree model according to the threshold includes: according to the spatial position of the selected location, search and determine the leaf node in the quadtree to which it belongs, that is, determine the leaf node area where it is located; if the number of points in this leaf node > K value, take it as the node for querying the neighbor table; if the number of points in this leaf node < K value, take its parent node as the node for querying the neighbor table.
[0012] According to an electric vehicle charging station search method based on neighbor table query provided by the present invention, the step of determining the effective search range by querying the neighbor table includes:
[0013] Preliminarily determine the search range; query in the neighbor table based on the nodes in the query neighbor table to find the neighbor nodes directly adjacent to the node, and use these nodes as the preliminary first search range.
[0014] According to an electric vehicle charging station search method based on neighbor table query provided by the present invention, after preliminarily determining the first search range, use the maximum distance from a given point to the boundary of the nodes in the query neighbor table as the search radius, query in the neighbor table based on the nodes within the first search range to find the neighbor nodes directly adjacent to these nodes, and use the nodes that are in or partially in the search radius as the second search range;
[0015] Based on the first search range and the second search range, determine the effective search range.
[0016] According to an electric vehicle charging station search method based on neighbor table query provided by the present invention, based on the effective search range, use multiple threads to parallelly calculate the distances between all points within this range and the selected location, and then the K nearest charging stations to the selected location can be found by sorting according to the distances.
[0017] According to an electric vehicle charging station search method based on neighbor table query provided by the present invention, when finding the K nearest charging stations to a specific point in a specified planar area, set the node threshold of the quadtree model to be greater than the K value. When determining the effective search range according to the search radius, if the number of data points contained in the node area where the given point is located is less than K, use its parent node as the node for querying the neighbor table to ensure that the K nearest neighbor points of the given point are all included in the effective search range.
[0018] According to an electric vehicle charging station search method based on neighbor table query provided by the present invention, the judgment of whether the aspect ratio of the specified search area is less than a preset value includes: judging whether the aspect ratio of the urban map area is less than a preset value, including: assuming that the length and width of the area represented by a certain leaf node are x and y respectively, then the longest search radius is the hypotenuse of the area represented by this leaf node, that is Since the search radius is not greater than twice the length or twice the width of this leaf node, that is, the inequality is expressed as Or After simplification, 3 * x 2 ≥y 2 Or 3 * y 2 ≥x 2 , that is Or Among them, the preset value is
[0019] It can be seen that after the aspect ratio of the length and width of the map area of the city where the present invention is located is determined to be less than a preset value, the nearest K charging stations can be quickly searched, and the latest nearest charging stations can also be quickly searched multiple times according to the dynamic change of the vehicle position. And as the vehicle dynamically changes its position in the current city, the quadtree model corresponding to the city map and its neighbor table can also be used multiple times for the search of charging stations.
[0020] Furthermore, the present invention can reasonably divide the search space according to the spatial distribution density of points, and screen out the effective search range through different methods to improve the query efficiency; by establishing the neighbor table and calculating the search radius through preprocessing, the range determined according to the search radius can further refine the search range, thereby improving the search efficiency.
[0021] In a second aspect, the present invention further provides an electronic device, including:
[0022] a memory storing computer-executable instructions;
[0023] a processor configured to run the computer-executable instructions,
[0024] wherein, when the computer-executable instructions are run by the processor, the steps of any one of the above-mentioned electric vehicle charging station search methods based on neighbor table query are implemented.
[0025] In a third aspect, the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, the steps of any one of the above-mentioned electric vehicle charging station search methods based on neighbor table query are implemented.
[0026] It can be seen that the present invention provides an electronic device and a storage medium for an electric vehicle charging station search method based on neighbor table query, which include: one or more memories and one or more processors. The memory is used for storing program codes, intermediate data generated during program operation, storage of model output results, and storage of models and model parameters; the processor is used for the processor resources occupied by code operation and multiple processor resources occupied during model training.
[0027] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 is a flowchart of an embodiment of an electric vehicle charging station search method based on neighbor table query of the present invention.
[0029] Figure 2It is a schematic diagram of establishing a quadtree model (threshold value is 10) in the search space in an embodiment of an electric vehicle charging station search method based on neighbor table query according to the present invention.
[0030] Figure 3 It is a schematic diagram of establishing a neighbor table in an embodiment of an electric vehicle charging station search method based on neighbor table query according to the present invention.
[0031] Figure 4 It is a schematic diagram of determining a search range according to a search radius in an embodiment of an electric vehicle charging station search method based on neighbor table query according to the present invention. Detailed implementation manners
[0032] To make the objectives, technical solutions and advantages of the present invention clearer, the technical solutions in the present invention will be clearly and completely described below with reference to the accompanying drawings in the present invention. Apparently, the described embodiments are some but not all of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art without making creative efforts based on the embodiments in the present invention belong to the scope of protection of the present invention.
[0033] See Figure 1 , an electric vehicle charging station search method based on neighbor table query, includes the following steps:
[0034] Step S1, obtain the real-time position of the electric vehicle, and based on the position where the electric vehicle itself is located, obtain the map of the city where it is located and the location distribution of the charging stations in the city;
[0035] Step S2, judge whether the aspect ratio of the map area of the city where it is located is less than a preset value;
[0036] Step S3, if the aspect ratio of the map area of the city where it is located is less than the preset value, use the map area of the city as the search area, and use the number of charging stations that the user needs to search as the value of K, and establish a quadtree model according to a preset threshold value; wherein, this threshold value is used to establish the quadtree model, and usually takes a value much larger than the value of K, for example, greater than 4 times the value of K;
[0037] Step S4, divide the map area of the city into node areas corresponding to the quadtree model according to the threshold value, and establish a neighbor table based on the spatial position, wherein this neighbor table is used to quickly determine the effective search range when searching for the K nearest charging stations;
[0038] Step S5, determine the node area where this location is located;
[0039] Step S6, determine the effective search range by querying the neighbor table;
[0040] Step S7: Based on the effective search range, calculate the distances between all points within this search range and the selected location in parallel, and then quickly find the K nearest charging stations.
[0041] Specifically, based on the location of the vehicle itself, obtain the map of the city where it is located and the location distribution of charging stations in this city. If the aspect ratio of the city area is less than a preset value, then take the city as the search area in this embodiment, and use the number of charging stations that the user needs to search for (such as 5) as the value of K, determine the threshold (4 times K value = 20) to establish a quadtree model, that is, divide the city area into node areas corresponding to the quadtree model according to the threshold (number of charging stations), and establish a neighbor table based on the spatial location. According to the spatial location (latitude and longitude) of the location selected by the user on the map, determine the node area where this location is located, and determine the effective search range by querying the neighbor table, and then quickly find the K nearest charging stations.
[0042] In the above step S2, the establishing a quadtree model according to a preset threshold includes: using the quadtree method to divide the spatial area layer by layer. First, divide the initial search area into four sub-areas. If the number of points in a sub-area is greater than the preset threshold, then further divide this sub-area into four smaller sub-areas, and continue to recurse in this way until the number of points in each sub-area does not exceed the preset threshold, so as to ensure that the distribution density of points in each leaf node area is relatively uniform.
[0043] Among them, during the process of establishing the quadtree model, store the boundary point coordinates of each sub-area, as well as information such as the spatial location and quantity of all data points included, so as to divide all data points in the specified area into the areas corresponding to the leaf nodes of the quadtree model accordingly.
[0044] In the above step S4, dividing the map area of the city into node areas corresponding to the quadtree model according to the threshold includes: according to the spatial location of the selected location, search and determine the leaf node in the quadtree to which it belongs, that is, determine the leaf node area where it is located; if the number of points in this leaf node > K value, then use it as the node for querying the neighbor table; if the number of points in this leaf node < K value, then use its parent node as the node for querying the neighbor table. Among them, when searching and determining the leaf node in the quadtree to which it belongs, it can be searched through a parallel search engine, or other search algorithms can also be used.
[0045] In the above step S5, based on determining the effective search range by querying the neighbor table, it includes:
[0046] Preliminarily determine the search range; based on the node querying the neighbor table, search in the neighbor table to find the neighbor nodes directly adjacent to this node, and use these nodes as the preliminary first search range.
[0047] After initially determining the first search range, based on the maximum distance from a given point to the node boundary of the query neighbor table as the search radius, query in the neighbor table based on the nodes within the first search range to find the neighbor nodes directly adjacent to these nodes, and use the nodes that are within or partially within the search radius as the second search range. Then, based on the first search range and the second search range, the effective search range is determined.
[0048] In the above step S6, based on the effective search range, use multiple threads to calculate the distances between all points within this range and the selected location in parallel, and then the K nearest charging stations to the selected location can be found by sorting according to the distances.
[0049] In this embodiment, when finding the K nearest charging stations to a specific point within a specified planar region, set the quadtree model node threshold to be greater than the K value (it is recommended to set the threshold to be greater than 4 times the K value). When determining the effective search range according to the search radius, if the number of data points contained in the node region where the given point is located is less than K, use its parent node as the node to query the neighbor table to ensure that the K nearest neighbor points of the given point are all included in the effective search range.
[0050] In this embodiment, determining whether the aspect ratio of the map region of the city where it is located is less than a preset value includes: assuming that the length and width of the region represented by a certain leaf node are x and y respectively, then the longest search radius is the hypotenuse length of the region represented by this leaf node, that is Since the search radius is not greater than twice the length or twice the width of this leaf node, that is, the inequality is expressed as Or After simplification, 3 * x 2 ≥y 2 Or 3 * y 2 ≥x 2 , that is Or
[0051] Specifically, when the aspect ratio of the map region of the city where it is located satisfies being less than Use the specified region as the search range and establish a quadtree according to a preset threshold. Layer by layer, divide the spatial region into four sub-regions. If the number of points in a sub-region is greater than the threshold, further divide it into four smaller sub-regions until the number of points in each sub-region does not exceed the threshold. During the tree-building process, store information such as the boundary point coordinates of the sub-region, the spatial positions and quantities of all the points it contains, so as to correspondingly divide all the points in the specified region into the regions corresponding to the leaf nodes of the quadtree, ensuring that the distribution density of points in each node region is relatively uniform, as Figure 2 shown.
[0052] Next, a neighbor table is established. Based on the node regions divided by the established quadtree, all neighbor nodes directly adjacent to each node are found according to the spatial position (each node has at most 8 direct neighbors), and a neighbor table including all nodes is constructed in parallel to quickly determine the effective search range when looking for neighboring points. The neighbor table is as shown in Figure 3 shown.
[0053] Then, the leaf node where the given point is located is determined. According to the spatial position of the given point, its leaf node in the quadtree is determined by parallel search, that is, its leaf node region is determined. If the number of points in this leaf node > K value, then it is used as the node to query the neighbor table; if the number of points in this leaf node < K value, then its parent node is used as the node to query the neighbor table.
[0054] Then, the search range is initially determined. Query the neighbor table according to the node determined for query in the previous step to find the neighbor nodes directly adjacent to this node, and use these nodes as the initial search range.
[0055] Then, the search range is determined. To further accurately find the search range of neighboring points, based on the farthest distance from the given point to the boundary of the node querying the neighbor table as the search radius, the node region within the search radius is used as a more accurate search range. Remove the areas that do not need to be searched from the initial search range, and add the neighbor nodes of the given point to the direct neighbors of the leaf node where it is located as the effective search range, as shown in Figure 3 shown.
[0056] Finally, calculate the distances to find the K nearest neighbors. Based on the search range, multiple threads are used to calculate the distances between all points within this range and the given point in parallel, so as to sort by distance to find the K charging stations closest to the given point.
[0057] Furthermore, for the description of the quadtree node threshold: The quadtree node threshold is a very important parameter in the quadtree data structure, which represents the maximum number of two-dimensional data points that can be stored in a quadtree leaf node. In the traditional quadtree construction process, when a new data point is inserted into a quadtree leaf node whose contained data points reach the quadtree node threshold, this quadtree leaf node will be split, generating four child leaf nodes, and the original contained data points will also be respectively transferred to its child leaf nodes. From another perspective, for any non-leaf node of the quadtree, the total number of data points contained in its descendant leaf nodes must be greater than the quadtree node threshold.
[0058] In a GPU-oriented quadtree, the setting of the node threshold is related to the relevant applications. For example, when the quadtree is used for the KNN problem, the quadtree node threshold is required to be larger than K (it is recommended to set the threshold to be greater than 4 times the value of K), because in this way, it can be ensured that when determining the search range according to the search radius (such as Figure 4 as shown), there is at least one non-leaf node within the range, thus ensuring that there are more than K data points within the range, and K nearest charging stations can be selected from them.
[0059] Furthermore, for the description of the specified area with an aspect ratio less than , it includes: when using the quadtree neighbor table for KNN search, for the feasibility of the algorithm, it is necessary to limit the search for K nearest neighbors only within the same-level neighbors in the first two rings (the first ring refers to the direct neighbors, and the second ring refers to the neighbors of the neighbors) of the node used for query. The meaning of the first two rings of neighbors is as shown in Figure 4 . The leaf node where the point to be searched is located is 12. Its first-ring neighbors are the nodes directly connected to node 12 (up, down, left, right, upper left, lower left, upper right, lower right), such as nodes 9, 13, 11, 7, 10, 14, 6, 18. Its second-ring neighbors are the first-ring neighbors of each of the first-ring neighbors of node 12, such as nodes 15, 16, 19, 20, 17, 8, 5, etc.
[0060] Assume that the length and width of the area represented by leaf node 12 are x and y respectively. Then the longest search radius is the hypotenuse of the area represented by the leaf node, that is Because it is necessary to limit the search for K nearest neighbors only within the same-level neighbors in the first two rings, the search radius should not be greater than twice the length or twice the width of node 12, that is, the inequality or must hold. After simplification, we can get 3 * x 2 ≥ y 2 or 3 * y 2 ≥ x 2 , that is or According to the properties of the quadtree, the aspect ratios of the ranges represented by all nodes (including the root node) are the same. Therefore, in this embodiment, it is obtained that the specified area of the KNN algorithm based on the quadtree neighbor table is preferably to meet the condition that the aspect ratio is less than .
[0061] In practical applications, when finding K nearest neighbors in the specified area as the selected location ( Figure 4 is a small triangle in), it includes the following steps:
[0062] (1) Build a quadtree for the specified area according to the threshold, and obtain the area division result as shown in Figure 2 .
[0063] (2) Establish a neighbor table based on the quadtree result built in (1), as Figure 3 shown;
[0064] (3) Determine that the position of the given point is in the area corresponding to node 12;
[0065] (4) It can be obtained by checking the neighbor table that the direct neighbor nodes of node 12 are: 10, 11, 14, 13, 18, 7, 6, 9;
[0066] (5) Further accurately search the range based on the search radius: Remove node 10; Add new nodes: 16, 19 (i.e., the neighbors of the neighbor nodes); As Figure 4 shown, the finally determined search range: 11, 14, 13, 18, 7, 6, 9, 16, 19.
[0067] (6) Calculate the distances between all points (the small dots in the figure) in the search range and the given point in parallel, and find the K charging stations with the shortest distances to the given point.
[0068] It can be seen that after determining that the aspect ratio of the length and width of the map area of the city where the present invention is located is less than the preset value, the K nearest charging stations can be quickly searched, and the latest nearest charging stations can also be quickly searched multiple times according to the dynamic change of the vehicle position. And as the vehicle dynamically changes at the current location in the city, the quadtree model and its neighbor table corresponding to the city map can also be used multiple times for the search of charging stations.
[0069] Furthermore, the present invention can reasonably divide the search space according to the spatial distribution density of points, and screen out the effective search range through different methods to improve the query efficiency; By establishing a neighbor table through preprocessing and calculating the search radius, the search range can be further accurately determined according to the range determined by the search radius, thereby improving the search efficiency.
[0070] In one embodiment, an electronic device is provided, and the electronic device may be a server. The computer device includes a processor, a memory, and a network interface connected through a system bus. Among them, the processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the electronic device is used to store data. The network interface of the electronic device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, it implements a method for searching for an electric vehicle charging station based on neighbor table query.
[0071] Those skilled in the art can understand that the structure of the electronic device shown in this embodiment is only a part of the structure related to the solution of this application, and does not constitute a limitation on the electronic device to which the solution of this application is applied. The specific electronic device may include more or fewer components than those shown in this embodiment, or combine certain components, or have different component arrangements.
[0072] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above method embodiments are implemented.
[0073] Those of ordinary skill in the art can understand that all or part of the processes of implementing the methods in the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the above method embodiments. Among them, any reference to a memory, storage, database, or other medium used in the various embodiments provided in this application can include at least one of non-volatile and volatile memories. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.
[0074] In addition, when the logical instructions in the above-mentioned memory are implemented in the form of software functional units and sold or used as an independent product, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs that can store program codes.
[0075] As can be seen, the present invention provides an electronic device and a storage medium for an electric vehicle charging station search method based on neighbor table query, which includes: one or more memories and one or more processors. The memory is used for storing program codes, intermediate data generated during program operation, storage of model output results, and storage of models and model parameters; the processor is used for the processor resources occupied by code operation and multiple processor resources occupied during model training.
[0076] The technical features of the above embodiments can be combined arbitrarily. For the sake of concise description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.
[0077] The above embodiments are only the preferred embodiments of the present invention and cannot be used to limit the scope of protection of the present invention. Any non-substantive changes and substitutions made by those skilled in the art on the basis of the present invention belong to the scope of protection required by the present invention.
Claims
1. An electric vehicle charging station search method based on neighbor table query, characterized in that Including: Obtain the real-time position of the electric vehicle. Based on the position of the electric vehicle itself, obtain the map of the city where it is located and the location distribution of charging stations in the city. If the aspect ratio of the map area of the city is less than a preset value, take the map area of the city as the search area, and take the number of charging stations that the user needs to search as the value of K. Establish a quadtree model according to a preset threshold, where the threshold is used to establish the quadtree model; divide the map area of the city into node areas corresponding to the quadtree model according to the threshold, and establish a neighbor table based on the spatial position. According to the spatial position of the location selected by the user in the city map, determine the node area where the location is located, determine the effective search range by querying the neighbor table, and based on the effective search range, calculate the distances between all points in the search range and the selected location in parallel, so as to quickly find the K nearest charging stations.
2. The method according to claim 1, wherein: The establishing a quadtree model according to a preset threshold includes: dividing the spatial area layer by layer in the quadtree manner. First, divide the initial search area into four sub-areas. If the number of points in the sub-area is greater than the preset threshold, further divide the sub-area into four smaller sub-areas, and continuously recurse in this way until the number of points in each sub-area does not exceed the preset threshold, so as to ensure that the distribution density of points in each leaf node area is relatively uniform.
3. The method according to claim 2, wherein: During the process of establishing the quadtree model, store the boundary point coordinates of each sub-area, and store information such as the spatial positions and quantities of all data points included, so as to divide all data points in the specified area into the areas corresponding to the leaf nodes of the quadtree model accordingly.
4. The method according to claim 3, wherein: The dividing the map area of the city into node areas corresponding to the quadtree model according to the threshold includes: according to the spatial position of the selected location, search and determine the leaf node in the quadtree to which it belongs, that is, determine the leaf node area where it is located; if the number of points in the leaf node > K value, use it as the node for querying the neighbor table; if the number of points in the leaf node < K value, use its parent node as the node for querying the neighbor table.
5. The method according to claim 4, wherein: The determining the effective search range by querying the neighbor table includes: Preliminarily determine the search range; query in the neighbor table based on the node for querying the neighbor table, find the neighbor nodes directly adjacent to this node, and take these nodes as the preliminary first search range.
6. The method according to claim 5, wherein: After preliminarily determining the first search range, take the farthest distance from the given point to the boundary of the node for querying the neighbor table as the search radius, query in the neighbor table based on the nodes within the first search range, find the neighbor nodes directly adjacent to these nodes, and take the nodes that are or partially within the search radius as the second search range; Based on the first search range and the second search range, determine the effective search range.
7. The method according to claim 6, wherein: Based on the effective search range, multiple threads are used to calculate the distances between all points within this range and the selected location in parallel, and then the K nearest charging stations to the selected location can be found by sorting according to the distances.
8. The method according to any one of claims 1 to 7, wherein: When finding the K nearest charging stations to a specific point within a specified planar region, the threshold of the quadtree model node is set to be greater than the K value. When determining the effective search range according to the search radius, if the number of data points contained in the node region where the given point is located is less than K, then its parent node is used as the node for querying the neighbor table to ensure that the K nearest neighbor points of the given point are all included in the effective search range.
9. The method according to any one of claims 1 to 7, wherein: Determine whether the aspect ratio of the map area of the current city is less than a preset value, including: assuming that the length and width of the area represented by a certain leaf node are x and y respectively, the longest search radius is the hypotenuse of the area represented by this leaf node, that is Since the search radius is not greater than twice the length or twice the width of this leaf node, that is, the inequality is expressed as Or After simplification, we can get 3 * x 2 ≥y 2 Or 3 * y 2 ≥x 2 , that is Or Among them, the preset value is