https://github.com/iwpnd/go-geofabrik
unoffical geofabrik api client
https://github.com/iwpnd/go-geofabrik
Last synced: 7 months ago
JSON representation
unoffical geofabrik api client
- Host: GitHub
- URL: https://github.com/iwpnd/go-geofabrik
- Owner: iwpnd
- License: mit
- Created: 2023-05-03T12:05:27.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-15T07:19:13.000Z (about 1 year ago)
- Last Synced: 2024-10-07T06:05:39.140Z (about 1 year ago)
- Language: Go
- Size: 50.8 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# go-geofabrik
unofficial api client for [Geofabrik](https://download.geofabrik.de).
## Installation
### cli
```bash
go install github.com/iwpnd/go-geofabrik/cmd/geofabrik@latest
``````bash
➜ geofabrik --help
NAME:
geofabrik - geofabrikUSAGE:
geofabrik [global options] command [command options] [arguments...]COMMANDS:
md5 get latest md5 of geofabrik dataset
polygon get extent of dataset as geojson feature
download download dataset to outputpath
download-if-changed download dataset to outputpath if md5 changed
help, h Shows a list of commands or help for one commandGLOBAL OPTIONS:
--help, -h show help
```### package
### MD5
Get latest md5 of a dataset by name
```go
import (
"contxt"
"fmt""github.com/iwpnd/go-geofabrik"
"github.com/iwpnd/rip"
)func main() {
g, err := geofabrik.New("http://download.geofabrik.de", false)
if err != nil {
panic("wuaah!")
}ctx := context.Background()
name := "europe/germany/berlin"
md5, err := g.MD5(ctx, name)
if err != nil {
panic(err)
}
fmt.Println(md5)
// >> 379b462358f660744c1a9eed6f46b031
}
```### Download
Get a dataset by name to output path
```go
import (
"contxt"
"fmt""github.com/iwpnd/go-geofabrik"
"github.com/iwpnd/rip"
)func main() {
g, err := geofabrik.New("http://download.geofabrik.de", false)
if err != nil {
panic("wuaah!")
}ctx := context.Background()
name := "europe/germany/berlin"
outputPath := "./tmp"
err := g.Download(ctx, name, outputPath)
if err != nil {
panic(err)
}
}
```### Polygon
Get a dataset extend as Polygon Feature
```go
import (
"contxt"
"fmt""github.com/iwpnd/go-geofabrik"
"github.com/iwpnd/rip"
)func main() {
g, err := geofabrik.New("http://download.geofabrik.de", false)
if err != nil {
panic("wuaah!")
}ctx := context.Background()
name := "europe/germany/berlin"
polygon, err := g.Polygon(ctx, name)
if err != nil {
panic(err)
}
f, err := polygon.ToFeature()
if err != nil {
panic(err)
}fmt.Println(f)
// > {"type":"Feature"...}
}
```## License
MIT
## Acknowledgement
awesome folks at [Geofabrik](https://geofabrik.de)
## Maintainer
Benjamin Ramser - [@iwpnd](https://github.com/iwpnd)
Project Link: [https://github.com/iwpnd/go-geofabrik](https://github.com/iwpnd/go-geofabrik)