Skip to main content

Plan trips using the Google Maps API

Project description

Python travelling library

GitHub License Python ^3.10 GitHub Actions Workflow Status GitHub Issues or Pull Requests

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

  1. Distance and timing calculations for trips. ✔️
  2. Geocoding and decoding locations in the globe.
  3. Support for static map images.
  4. Drop googlemaps dependency.
  5. Investigate other APIs to use.
  6. ...

Getting started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

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.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_travel-0.1.tar.gz (37.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_travel-0.1-py3-none-any.whl (25.7 kB view details)

Uploaded Python 3

File details

Details for the file py_travel-0.1.tar.gz.

File metadata

  • Download URL: py_travel-0.1.tar.gz
  • Upload date:
  • Size: 37.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.11

File hashes

Hashes for py_travel-0.1.tar.gz
Algorithm Hash digest
SHA256 0744669515938a3377c79cf339ab1b179a164b3bafe55037f3b569adae8d7d78
MD5 a4108ff7f091da87b13c5b7e41eb27a2
BLAKE2b-256 1b760940008c247720b9762c0e004c5bccf430738534d705121bcb23751c0ffb

See more details on using hashes here.

File details

Details for the file py_travel-0.1-py3-none-any.whl.

File metadata

  • Download URL: py_travel-0.1-py3-none-any.whl
  • Upload date:
  • Size: 25.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.11

File hashes

Hashes for py_travel-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 02a4b9245cba5214923dd7506c038cce57873c36f93d3b904d9c072e92fa6308
MD5 b6f3959a34404500b91d394f088caa2c
BLAKE2b-256 d4d06af73fbd25140f502b0963cd366420ee41debc7717e21ee484d2c1f4cec4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page