go-nomi
Library to access Nominatim webservice from OpenStreetMaps.
This is work in progress
The development on this library just started. Only the "Search" endpoint and Redis caching is supported now. There is no extensive test suite and the docs are uncommented yet.
If you are in urgent need of specific functionality, get in touch with the developer or contribute your own work.
Features
- Search
- Reverse Geocoding
- Address Lookup
- Optional caching with Redis
- Respect Nominatim Usage Policy
- Attach email to every request
- Provide a valid HTTP Referer or User-Agent identifying the application
- Default rate limit of 1 req/s
Terms of the OSM Nominatim
Please refer to the Nominatim Wiki
if you plan to use the Nominatim webservice.
Installation
$ go get -u github.com/louis77/go-nomi/nomi
Quick Start
package main
import (
"fmt"
"log"
"github.com/louis77/go-nomi/nomi"
)
func main() {
c, err := nomi.NewClient(&nomi.ClientOptions{
// Email and UserAgent must be provided according to
// Nominatim Usage Policy
Email: "foo@bar.com",
UserAgent: "mycoolapp.com/v1.0",
})
if err != nil {
log.Fatal(err)
}
// Optionally enable redis backed caching
if err := c.UseCache("redis://localhost:6379/0"); err != nil {
log.Fatal(err)
}
resp, err := c.Search(nomi.SearchParams{
Query: "Zürich, Switzerland",
}, nomi.SearchOptions{
AcceptLanguage: "en",
Limit: 1,
Dedupe: true,
})
if err != nil {
log.Fatal(err)
}
fmt.Println(resp)
}