https://github.com/stefanb/osmshortlink-go
Go module and command-line tool for handling OpenStreetMap shortlinks
https://github.com/stefanb/osmshortlink-go
bit-interleaving golang-library golang-package link-shortener morton-code morton-encoding-library openstreetmap osm
Last synced: 4 months ago
JSON representation
Go module and command-line tool for handling OpenStreetMap shortlinks
- Host: GitHub
- URL: https://github.com/stefanb/osmshortlink-go
- Owner: stefanb
- License: mit
- Created: 2022-11-10T07:54:26.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-02T15:44:14.000Z (4 months ago)
- Last Synced: 2025-03-02T16:31:08.905Z (4 months ago)
- Topics: bit-interleaving, golang-library, golang-package, link-shortener, morton-code, morton-encoding-library, openstreetmap, osm
- Language: Go
- Homepage:
- Size: 84 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# osmshortlink-go: Go module and command-line tool for creating, encoding & decoding of OpenStreetMap shortlinks
[](https://pkg.go.dev/github.com/stefanb/osmshortlink-go)
[](https://github.com/stefanb/osmshortlink-go/actions/workflows/test.yml)
[](https://github.com/stefanb/osmshortlink-go/actions/workflows/golangci-lint.yml)
[](https://github.com/stefanb/osmshortlink-go/actions/workflows/codeql.yml)
[](https://goreportcard.com/report/github.com/stefanb/osmshortlink-go)
[](https://codebeat.co/projects/github-com-stefanb-osmshortlink-go-main)
[](https://securityscorecards.dev/viewer/?uri=github.com/stefanb/osmshortlink-go)
[](https://github.com/stefanb/osmshortlink-go/releases/latest)Specification: https://wiki.openstreetmap.org/wiki/Shortlink
## Usage
### Creating a link in Go
```go
package mainimport "github.com/stefanb/osmshortlink-go"
func main() {
shortlink, err := osmshortlink.Create(46.05141, 14.50604, 17)
if err != nil {
panic(err)
}
print(shortlink)
}
```Prints: [`https://osm.org/go/0Ik3VNr_A-?m`](https://osm.org/go/0Ik3VNr_A-?m)
[Try it in Go playground](https://go.dev/play/p/mObcbRyGU9E)
### Command-line tool
#### Installation
##### Download the pre-built binaries
Download the pre-built binaries for your platform from [latest release](https://github.com/stefanb/osmshortlink-go/releases/latest).
##### Install using Go
````bash
$ go install github.com/stefanb/osmshortlink-go/cmd/osmshortlink@latest
$ osmshortlink 46.05141 14.50604 17
https://osm.org/go/0Ik3VNr_A-?m
````#### Run using Go without installing
````bash
$ go run github.com/stefanb/osmshortlink-go/cmd/osmshortlink@latest 46.05141 14.50604 17
https://osm.org/go/0Ik3VNr_A-?m
````#### Pre-built binaries
You can download pre-built binaries for various platforms from [latest release](https://github.com/stefanb/osmshortlink-go/releases/latest).
```bash
Usage: osmshortlink [latitude] [longitude] [zoom]
```For example:
```bash
$ osmshortlink 46.05141 14.50604 17
https://osm.org/go/0Ik3VNr_A-?m
```## Development
Run: `go run ./cmd/osmshortlink/main.go 46.05141 14.50604 17`
Testing: `go test -v -race -cover ./...`
Fuzz testing: `go test -fuzz=. -fuzztime=1m`