Reverse- and geocoding with nominatim in go

grindhold eecda9fb9b Merge pull request #8 from alaminopu/master 6 سال پیش
example 53f08eb6db * Easier to read example. No need for ptrs. 10 سال پیش
.gitignore 37cd7b6198 * Updated .gitignore to contain example. 10 سال پیش
.travis.yml 282fa7a198 build: update path for cover dependency 8 سال پیش
README.md 1b75996822 updated readme to show correct response object 6 سال پیش
nominatim.go becc2dd4e0 Added missing address fields 6 سال پیش
nominatim_reverse.go 63a0dfe971 Update nominatim_reverse.go 7 سال پیش
nominatim_reverse_test.go 50777d270b added zoom test 10 سال پیش
nominatim_search.go a1616bc2e4 Use accept-language instead of accept_language 10 سال پیش
nominatim_search_test.go becc2dd4e0 Added missing address fields 6 سال پیش

README.md

Gominatim - Go library to access nominatim geocoding services

Buildstatus Coverage Status

Geocoding? WTF?

If you want to determine the coordinates of a certain location by only having its name, you can do this via a geocoding service. If you want to do this in go, you probably want to use gominatim to do it.

License

LGPLv3

Features

The plan is to cover everything, this site documents: Nominatim Wiki

  • Search
  • Reverese Geocoding

Contributions–

…Are welcome :)

If you want to add anyting, do it and submit a pullrequest. Please add Tests for your additions

Usage of the Openstreetmaps-Nominatim Server

Please refer to the Nominatim Wiki if you plan to use the nominatim service of openstreetmaps. If you plan to generate high loads with geoqueries, it would be nice if you did it on your own infrastructure, not on their server

Examples

package main

import (
	"fmt"
	"github.com/grindhold/gominatim"
)

func main() {
	gominatim.SetServer("http://nominatim.openstreetmap.org/")

	//Get by a Querystring
	qry := gominatim.SearchQuery{
		Q: "Hamburg",
	}
	resp, _ := qry.Get() // Returns []gominatim.SearchResult
	fmt.Printf("Found location: %s (%s, %s)\n", resp[0].DisplayName, resp[0].Lat, resp[0].Lon)

	//Get by City
	qry = gominatim.SearchQuery{
		City: "Berlin",
	}
	resp, _ = qry.Get()
	fmt.Printf("Found location: %s (%s, %s)\n", resp[0].DisplayName, resp[0].Lat, resp[0].Lon)

	//Reverse Geocoding
	rqry := gominatim.ReverseQuery{
		Lat: "52.5170365",
		Lon: "13.3888599",
	}
	rresp, _ := rqry.Get()
	fmt.Printf("Found %s\n", rresp.DisplayName)
}