Photon Python client
Project description
🗺 Light Photon client written in Python
Install
pip install pyphoton
Usage
If you need some code ready to use, spike.py is a good starting point
Execute queries
Python Photon client allows you to make queries to Photon service easily.
from pyphoton import Photon
client = Photon()
location = client.query('berlin', limit=1)
print (location.city)
print (location.latitude)
print (location.longitude)
Photon object accepts two parameters:
host: the url where Photon instance is running (default https://photon.komoot.de)
language: the preferred language (default is en)
You can pass to the query method the following parameters along the query string:
limit: limit number of results
language: force language in the query
latitude and longitude: use them to search with priority to a geo position
location_bias_scale: use to search with location bias
osm_tags: a string or list containing osm tags filters
Location object (or objects if you don’t set limit=1) is generated from the json returned and contains all the information you need: name, state, street, city, osm attributes, extent_from.latitude, extent_from.longitude, extent_to.latitude, extent_to.longitude …
Reverse search
Python Photon client allows you to make reverse search.
from pyphoton import Photon
client = Photon()
locations = client.reverse(latitude=52, longitude=10)
for location in locations:
print ('🌉 Location #{0}\n{1}\n'.format(location.osm_id, location))
You can pass to the reverse method the following parameters:
latitude and longitude: use them to search using a geo position
limit: limit number of results
Deal with errors
If there’s an error in your query, a PhotonException will be raised
from pyphoton import Photon
from pyphoton.errors import PhotonException
client = Photon()
try:
location = client.query('', limit=1)
except PhotonException as ex:
print (ex)
WIP Features
BBox search
Method to fetch latest data
Run tests
pip install -r requirements-dev.txt
make test
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
Built Distribution
File details
Details for the file pyphoton-0.9.2.tar.gz
.
File metadata
- Download URL: pyphoton-0.9.2.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/18.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96d1177d8496c1ce34733110c9d5d18157fb19b8c320a02e5058c538354560cb |
|
MD5 | bd3bdbc34562132b92df46bbfe822b22 |
|
BLAKE2b-256 | 601710614797a954d2f561ff0d2088f877c12fd36a574dc1c4cb3e459425f61a |
File details
Details for the file pyphoton-0.9.2-py3-none-any.whl
.
File metadata
- Download URL: pyphoton-0.9.2-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/18.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea61717fe6f3eae2352351fc8013ffb5d7673aef16a906303514e96881803216 |
|
MD5 | 706796234f424d00adadd44af2108fae |
|
BLAKE2b-256 | becf3f37eb6a8c531261d6d813f8a21c327cf3811724605ffe2c903a744ec1bf |