https://github.com/zaczero/osm-shortlink
OpenStreetMap shortlink encoder and decoder
https://github.com/zaczero/osm-shortlink
decoder encoder openstreetmap shortlink
Last synced: 5 months ago
JSON representation
OpenStreetMap shortlink encoder and decoder
- Host: GitHub
- URL: https://github.com/zaczero/osm-shortlink
- Owner: Zaczero
- License: 0bsd
- Created: 2024-09-09T18:20:42.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-18T20:02:23.000Z (over 1 year ago)
- Last Synced: 2025-04-05T22:55:29.226Z (about 1 year ago)
- Topics: decoder, encoder, openstreetmap, shortlink
- Language: Rust
- Homepage: https://pypi.org/p/osm-shortlink
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# osm-shortlink

[](https://pypi.org/project/osm-shortlink)
[](https://liberapay.com/Zaczero/)
[](https://github.com/sponsors/Zaczero)
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
Pre-built binary wheels are available for Linux, macOS, and Windows, with support for both x64 and ARM architectures.
```sh
pip install osm-shortlink
```
## Basic usage
```py
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