Skip to main content

OpenStreetMap shortlink encoder and decoder

Project description

osm-shortlink

PyPI - Python Version Liberapay Patrons GitHub Sponsors

Fast and correct OpenStreetMap shortlink encoder and decoder implementation in Rust with Python bindings. Shortlinks allow you to represent a location on the map with a short code.

Installation

The recommended installation method is through the PyPI package manager. The project is implemented in Rust, offering excellent performance characteristics. Several pre-built binary wheels are available for Linux, macOS, and Windows, with support for both x64 and ARM architectures.

pip install osm-shortlink

Basic usage

from osm_shortlink import shortlink_encode
shortlink_encode(0.054, 51.510, 9)  # -> '0EEQhq--'
shortlink_encode(19.579, 51.876, 19)  # -> '0OP4tR~rx'
shortlink_encode(0, 0, 23)  # ValueError: Invalid zoom: must be between 0 and 22, got 23

from osm_shortlink import shortlink_decode
shortlink_decode('0EEQhq--')  # -> (0.054, 51.510, 9)
shortlink_decode('0OP4tR~rx')  # -> (19.579, 51.876, 19)
shortlink_decode('X')  # ValueError: Invalid shortlink: too short

Format specification

https://wiki.openstreetmap.org/wiki/Shortlink

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

osm_shortlink-1.1.0.tar.gz (14.5 kB view details)

Uploaded Source

Built Distributions

osm_shortlink-1.1.0-cp39-abi3-win_amd64.whl (118.6 kB view details)

Uploaded CPython 3.9+ Windows x86-64

osm_shortlink-1.1.0-cp39-abi3-musllinux_1_2_x86_64.whl (415.9 kB view details)

Uploaded CPython 3.9+ musllinux: musl 1.2+ x86-64

osm_shortlink-1.1.0-cp39-abi3-musllinux_1_2_aarch64.whl (433.8 kB view details)

Uploaded CPython 3.9+ musllinux: musl 1.2+ ARM64

osm_shortlink-1.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (232.2 kB view details)

Uploaded CPython 3.9+ manylinux: glibc 2.17+ x86-64

osm_shortlink-1.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (223.3 kB view details)

Uploaded CPython 3.9+ manylinux: glibc 2.17+ ARM64

osm_shortlink-1.1.0-cp39-abi3-macosx_11_0_arm64.whl (216.4 kB view details)

Uploaded CPython 3.9+ macOS 11.0+ ARM64

osm_shortlink-1.1.0-cp39-abi3-macosx_10_12_x86_64.whl (218.9 kB view details)

Uploaded CPython 3.9+ macOS 10.12+ x86-64

Supported by

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