Skip to main content

gpluscodepy

Simple plus code to lat/long decoder written for White Flag Project.

Quickstart

  1. pip install gpluscodepy
  2. list_of_places = [{'name': 'Some place string', 'latitude': 1.921313, 'longitude': 207.124523}, ...]
  3. converter = gpluscodepy.Converter(filestream)
  4. 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).

Release files for gpluscodepy 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gpluscodepy 0.0.1
File Size Uploaded
gpluscodepy-0.0.1.tar.gz 3.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gpluscodepy 0.0.1
File Interpreter ABI Platform
gpluscodepy-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 7.8 kB

Release files / gpluscodepy-0.0.1.tar.gz

Download URL gpluscodepy-0.0.1.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
71f419036d6a189b657b33ac2294e354ccb0a562c450e531250c77c1284aa86f
BLAKE2b-256 checksum
How to use checksums
4e75e6b0d87ca91c83031b352f7c59cc24a90e42decc5b3b5bd7785212b19bb4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.2

Release files / gpluscodepy-0.0.1-py3-none-any.whl

Download URL gpluscodepy-0.0.1-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bddf80e74d82b89eba0618f5f185ccbe1a5733256dfc2a0fec8c581bb842fef1
BLAKE2b-256 checksum
How to use checksums
8a10963d109e8fc329a1dff1cc0f8728fd7bf8cac1f82d91e2d3c13b72b0b4a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.2

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page