Function to query the K-D tree to find the nearest city Args: coordinates (list): List of tuple coordinates, i.e. [(latitude, longitude)]
(self, coordinates)
| 116 | self.tree = KDTree_MP.cKDTree_MP(coordinates) |
| 117 | |
| 118 | def query(self, coordinates): |
| 119 | """ |
| 120 | Function to query the K-D tree to find the nearest city |
| 121 | Args: |
| 122 | coordinates (list): List of tuple coordinates, i.e. [(latitude, longitude)] |
| 123 | """ |
| 124 | if self.mode == 1: |
| 125 | _, indices = self.tree.query(coordinates, k=1) |
| 126 | else: |
| 127 | _, indices = self.tree.pquery(coordinates, k=1) |
| 128 | return [self.locations[index] for index in indices] |
| 129 | |
| 130 | def load(self, stream): |
| 131 | """ |