Carte is a flexible, extensible reverse-geocode library implemented in Python.
Installation
From PyPI via pip
Carte is available from PyPI via pip.
pip install carte
From source using poetry
Note: It is recommended to build carte in a virtual environment due to dependency version requirements.
From the root of the repository, install the necessary dependencies via poetry:
poetry install
Then, build the wheel:
poetry build
Finally, outside of your virtual environment, install the wheel using pip:
pip install dist/carte-<version>-py3-none-any.whl
Usage
Carte is built using resources which inherit from the Resource class. A Carte instance is instantiated with a list of the Resource types it will query:
import carte
carte_instance = carte.Carte([my_resource_type])
results = carte_instance.query(List of coordinates as tuples...)
Multiple Carte instances may be created, and resources will be shared between them by a backing ResourceStore.
Custom Resources
The flexibility of Carte lies in the Resource class, which queries are passed to sequentially via the query method. The results of each resource query are aggregated and passed to the next, allowing the creation of resources that mutate previous resources' results, such as translating a country's ISO 3166-1 identifier code into a full name.
For examples of Resource classes, see the resources submodule.
Defining your own Resource is as simple as inheriting from the Resource superclass, and implementing the load and query methods.
from carte.resources import resource
class MyCustomResource(resource.Resource):
def load(self):
# do stuff...
def query(self, coordinates, results) -> dict:
# do other stuff...
return results
Testing
To run tests, execute the following from the root of the project:
poetry run pytest tests/
License
Carte is licensed under the GNU Lesser General Public License.
Attribution
Carte is inspired by reverse-geocode.
Metadata
Release files for carte 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| carte-0.2.2.tar.gz | 21.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| carte-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 44.8 kB
Release files / carte-0.2.2.tar.gz
| Download URL | carte-0.2.2.tar.gz |
|---|---|
| Size | 21.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
67c0ebbf75954c5a952e256729fe3d128e06916bd4731fdb7c121c8a227269f5
|
|
BLAKE2b-256 checksum How to use checksums |
891dbf7b118aa1d6be7e6fd8b388d1894a13a29ab1077f1d48e5a69d9c784df9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.2 CPython/3.8.0 Darwin/18.7.0
|
Release files / carte-0.2.2-py3-none-any.whl
| Download URL | carte-0.2.2-py3-none-any.whl |
|---|---|
| Size | 23.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
12474c409084e113e205ec097ab686e0e8de9dbcbc5900399144389ff18f97ee
|
|
BLAKE2b-256 checksum How to use checksums |
74d872e9cca5a2aecdcffc994c5b1fc36df042bc5fd755a10242438706efdd53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.2 CPython/3.8.0 Darwin/18.7.0
|