Skip to main content

pluscodepy

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

Quickstart

  1. pip install pluscodepy
  2. list_of_places = [{'name': 'Some place string', 'latitude': 1.921313, 'longitude': 207.124523}, ...]
  3. converter = pluscodepy.Converter(filestream)
  4. latitude, longitude = converter.decode('GM83+2X Skudai, Johor')

Install

pip install pluscodepy

Usage

Parameters

__init__(index: list[dict])

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 Nominatim OSM 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 pluscodepy 0.0.11

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

Source distribution (sdist)

Source distribution for pluscodepy 0.0.11
File Size Uploaded
pluscodepy-0.0.11.tar.gz 3.7 kB Details

Built distribution (wheel)

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

Total release size: 7.6 kB

Release files / pluscodepy-0.0.11.tar.gz

Download URL pluscodepy-0.0.11.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ae2fe7c9afadb9566f3729b107c9284924bdceeb8bf3d53813f95dc1b280183e
BLAKE2b-256 checksum
How to use checksums
9884692dad88bb54c38a40303e0bcb50f8857284229a7cf7f8469bae64cbc029
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 / pluscodepy-0.0.11-py3-none-any.whl

Download URL pluscodepy-0.0.11-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eaf8957f2e96dad9660bda6c9640eb93eef9a640b466a6b82a577f71743a623c
BLAKE2b-256 checksum
How to use checksums
3c1b9981bffebbe34ebf95b476a4435641e8df5f57a249d5216ef4b9a08bfd94
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.11 This release

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

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