Class Instantiation Args: mode (int): Library supports the following two modes: - 1 = Single-threaded K-D Tree - 2 = Multi-threaded K-D Tree (Default) verbose (bool): For verbose output, set to True stream (io.StringIO): An in-
(self, mode=2, verbose=True, stream=None)
| 95 | The main reverse geocoder class |
| 96 | """ |
| 97 | def __init__(self, mode=2, verbose=True, stream=None): |
| 98 | """ Class Instantiation |
| 99 | Args: |
| 100 | mode (int): Library supports the following two modes: |
| 101 | - 1 = Single-threaded K-D Tree |
| 102 | - 2 = Multi-threaded K-D Tree (Default) |
| 103 | verbose (bool): For verbose output, set to True |
| 104 | stream (io.StringIO): An in-memory stream of a custom data source |
| 105 | """ |
| 106 | self.mode = mode |
| 107 | self.verbose = verbose |
| 108 | if stream: |
| 109 | coordinates, self.locations = self.load(stream) |
| 110 | else: |
| 111 | coordinates, self.locations = self.extract(rel_path(RG_FILE)) |
| 112 | |
| 113 | if mode == 1: # Single-process |
| 114 | self.tree = KDTree(coordinates) |
| 115 | else: # Multi-process |
| 116 | self.tree = KDTree_MP.cKDTree_MP(coordinates) |
| 117 | |
| 118 | def query(self, coordinates): |
| 119 | """ |