go-nomi

module
v0.0.0-...-92659f3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2019 License: ISC

README

go-nomi

Library to access Nominatim webservice from OpenStreetMaps.

ISC License GoDoc Build Status Go Report Card Contributions welcome

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)
}

Directories

Path Synopsis
Package nomi provides a client to the Nominatiom webservice from OpenStreetMaps.org.
Package nomi provides a client to the Nominatiom webservice from OpenStreetMaps.org.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL