Simple plus code to lat/long decoder written for White Flag Project
Project description
gpluscodepy
Simple plus code to lat/long decoder written for White Flag Project.
Quickstart
pip install gpluscodepy
list_of_places = [{'name': 'Some place string', 'latitude': 1.921313, 'longitude': 207.124523}, ...]
converter = gpluscodepy.Converter(filestream)
latitude, longitude = converter.decode('GM83+2X Skudai, Johor')
Install
pip install gpluscodepy
Usage
Methods
__init__(api_key: string, index: list[dict] = [])
api_key: str
Google API key with access to the Geocoding API.
index: list[dict]
List of dictionaries with a name field for the place string, a longitude field, and a latitude field.
decode(pluscode: str)
pluscode: str
Plus code to be decoded.
Return
Union[(float, float), False]
Returns a float of tuples representing latitude and longitude OR returns false if the pluscode cannot be decoded.
getCities()
Return
list[dict]
List of dictionaries with a name field for the place string, a longitude field, and a latitude field.
How it works
The converter makes use of the Google Open Location Code library to decode and works with both full code and short code. The converter will try to work offline whenever possible.
If the input is a full code, it will just decode without any preprocessing. If a place string is detected in the code, it'll first check for the place's lat/long in the index file, and convert that to the 4 digit prefix. If the place is not yet indexed, it'll search on the Google Geocoding API and index valid result's lat/long into the index file for future use. And then the lat/long values are returned as a tuple (latitude, longitude)
.
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
Hashes for gpluscodepy-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bddf80e74d82b89eba0618f5f185ccbe1a5733256dfc2a0fec8c581bb842fef1 |
|
MD5 | 0dfa5fb89db0964a39be1ec422277e7d |
|
BLAKE2b-256 | 8a10963d109e8fc329a1dff1cc0f8728fd7bf8cac1f82d91e2d3c13b72b0b4a8 |