Plan trips using the Google Maps API
Project description
Python travelling library
This is a Python library to use in conjunction with the Google Maps API (at least for now) in order to plan trips and much more! It tries to bring a less JSON-oriented way of using the API.
Roadmap
- Distance and timing calculations for trips. ✔️
- Geocoding and decoding locations in the globe.
- Support for static map images.
- Drop
googlemapsdependency. - Investigate other APIs to use.
- ...
Getting started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Local installation
Prerequisites
You will need the following:
- Python >= 3.10
- A Google Maps API key (for testing outside the testing environment)
Installing
For a local installation, just clone this repository inside the parent directory of your project.
git clone https://github.com/diagmatrix/py-travel.git
git checkout main
Then install the dependencies of py-travel.
pip install -r requirements.txt
And there you have it! You can now use this library freely.
Installation
This project is available in PyPy, so you can install it using pip.
pip install py-travel
Usage
There are currently two ways of using the classes provided in the package: by using the built-in
Google Maps API clients or by using the googlemaps client directly. The first method will initialize an API client for
each of the classes of py-travel that use them, while the second approach will give you more control on which ones
can access it.
Using built-in client
from py_travel import init_clients
from py_travel.trip import Trip
init_clients(api_key="<API KEY>") # Initialize all API clients
my_trip = Trip(origin=(39.25, -4.47), destination="Aveiro, Portugal", config={'mode': 'walking'})
# Get the kms between the points
kms = my_trip.distance
Using googlemaps directly
from py_travel.trip import Trip
import googlemaps
cli = googlemaps.Client(key="<API KEY>")
Trip.set_client(cli) # Initialize client for the trip class
my_trip = Trip(origin=(39.25, -4.47), destination="Aveiro, Portugal", config={'mode': 'walking'})
# Get the kms between the points
kms = my_trip.distance
Running the tests
In order to run the tests you will first need to install the python package pytest. Then, place yourself in the parent
branch of the repository and run the following command:
pytest
For linting tests, this project uses the default ruff configuration.
Contributing
Work in progress
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_travel-0.1.1.tar.gz.
File metadata
- Download URL: py_travel-0.1.1.tar.gz
- Upload date:
- Size: 25.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8194d080ab999ffd18dcfec29858118a8970fcc7246d43f335ef0def5f7abe72
|
|
| MD5 |
bc7974e8570b00e4b90326c3c3a2a226
|
|
| BLAKE2b-256 |
1fabd676e590b795ab3437f2094a177c015e674f158aea8f85e69d2b41e3f8c9
|
File details
Details for the file py_travel-0.1.1-py3-none-any.whl.
File metadata
- Download URL: py_travel-0.1.1-py3-none-any.whl
- Upload date:
- Size: 25.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9cbef4ed206ad8304eca48cb670f13e7b26933a93f5594395c8297abe8f575f5
|
|
| MD5 |
e6c1445ca4253f408a124535db8c627e
|
|
| BLAKE2b-256 |
487312da689caa7ea71703b9fc510a9c3fdaa05cc8baf85bd609ecbfa1784819
|